Working With Pixels and Colors
|Top Previous Next|
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:
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:
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.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.