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 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:


The following methods are provided to output data onto the screen, and they all use lcd.forecolor and, where necessary, lcd.backcolor:

The following two sections — Lines, Rectangles, and Fills and Working With Text — discuss the above methods in more details.