Lines, Rectangles, and Fills

Top  Previous  Next

lcd_lines_rect_fills

Lines

The lcd.line method draws a line between any points. Lcd.verline and lcd.horline draw vertical and horizontal lines correspondingly. Use the last two methods whenever possible because they work faster than generic lcd.line. The line is drawn using the color set in the lcd.forecolor property (see Working With Pixels/Lines), and the line width is defined by the lcd.linewidth property. In the following example, we draw a picture as shown above, on the left:

 

 

lcd.forecolor=color_blue 'we assume we have already set color_blue

lcd.verline(0,0,20) 'vertical line, width=1 (default)

lcd.horline(0,20,0) 'horizontal line, width=1 (default)

lcd.linewidth=3 'change the width

lcd.line(2,2,20,20) 'line at 45 degrees, width=3

 

 

Defining lcd.linewidth>1 (3 for one of the lines in the above example) creates "fatter" lines. Notice how two points of the line are drawn and where each specified coordinate actually is.

Rectangles

Lcd.rectangle draws an unfilled rectangle using lcd.forecolor as "pen" color, and pen width defined by the lcd.linewidth property. Lcd.filledrectangle will additionally paint the internal area using lcd.backcolor. Example and its result:

 

 

lcd.forecolor=color_blue 'we assume we have already set color_blue

lcd.backcolor=color_green 'we assume we have already set color_green

lcd.rectangle(0,0,20,20) 'width=1 (default)

lcd.linewidth=3

lcd.filledrectangle(5,5,15,15) 'width=3, filled with background color

 

Fills

Lcd.fill paints specified area with the lcd.forecolor:

 

 

lcd.forecolor=color_blue 'we assume we have already set color_blue

lcd.fill(0,0,16,16)

lcd.forecolor=color_green 'we assume we have already set color_green

lcd.fill(5,5,16,16)