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:
** Tibbo Basic **
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 the 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 the lcd.forecolor to the brightest color available, and the lcd.backcolor to the darkest color available:
** Tibbo Basic **
The following methods are provided to output data onto the screen, and they all use the lcd.forecolor and, where necessary, the lcd.backcolor:
- Lcd.line, lcd.verline, lcd.horline — the line is drawn using the forecolor.
- Lcd.rectangle — the border is drawn using the forecolor, the internal area of the rectangle is not filled.
- Lcd.filledrectangle — the border is drawn using the forecolor, 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 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.