Working With Pixels and Colors
The lcd.setpixel method allows you to set the color of a single pixel. The method accepts a 16-bit color word, and the interpretation of this word is controller/panel-specific (see Understanding Controller Properties). In the following example, we determine the proper value for the green color and put a single green dot in the middle of the display:
Dim color_green As word
...
lcd_green=val("&b"+strgen(lcd.greenbits/&hFF,"1")+strgen(lcd.greenbits And &hFF,"0"))
lcd.setpixel(lcd_green,lcd.width/2,lcd.height/2)
lcd.setpixel is the only method that accepts the color directly. All other methods rely on two color properties: lcd.forecolor and lcd.backcolor. Each property is a 16-bit value, just like the one used by lcd.setpixel. The forecolor is the color of the "drawing pen" and the backcolor is the color of the background. In the following example, we set lcd.forecolor to the brightest color available and lcd.backcolor to the darkest color available:
lcd.forecolor=&hFFFF
lcd.backcolor=0
The following methods are provided to output data onto the screen, and they all use lcd.forecolor and, where necessary, lcd.backcolor:
- lcd.line, lcd.verline, lcd.horline — the line is drawn using the forecolor.
- lcd.rectangle — the border is drawn using the forecolor and the internal area of the rectangle is not filled.
- lcd.filledrectangle — the border is drawn using the forecolor and the internal area is filled with the backcolor.
- lcd.fill — the entire area is filled with the forecolor.
- lcd.print and lcd.printaligned — print text, where each "on" dot of each character is displayed in the forecolor, while each "off" dot is displayed in backcolor.
The following two sections — Lines, Rectangles, and Fills and Working With Text — discuss the above methods in more details.