Hardware Reference
In-Depth Information
The
xPos
and
yPos
parameters are
int
values and specify the center of the
circle. The
radius
parameter, also an
int
, is the radius of the circle to print, in
pixels.
Coloring
All the graphical functions take coordinates and parameters to dei ne their size
and shape but do not take parameters for color. This is done through different
functions. The philosophy is this: you tell the controller what color you want
to use, and all subsequent drawing will use that color.
Color functions aren't used only for lines but also for any i lled spaces. A rect-
angle can have one color for the lines dei ning its boundary, while the interior
of the rectangle could be a different color. By specifying a i ll color, anything
present inside the rectangle would be erased by a solid color. The color can be
any RGB value. It's also possible to declare no color, in which case the color is
“transparent”; where any existing pixels are left untouched.
This is accomplished using two functions:
stroke()
and
fill().
To dei ne
the color of points and lines, use
stroke()
:
screen.stroke(red, green, blue);
This function takes three
int
values; 8-bit values for the red, green, and blue
components. Again, these values are scaled down to what the TFT screen is
capable of displaying. When this function is called, no previous drawings are
modii ed; only future calls to drawing elements will be affected. This function
works only on points, lines, and outline graphics for circles and rectangles. To
specify how to i ll a circle or rectangle, use
fill()
:
screen.fill(red, green, blue);
Again, it takes three
int
values: the red, green, and blue components expressed
as 8-bit values.
To set the outline color as transparent, use the
noStroke()
function:
screen.noStroke();
To set the i ll color as transparent, use the
noFill()
function:
screen.noFill();
Graphic Images
If you were creating a weather station with graphic icons on an LCD screen,
it would be possible to create a basic geometric image representing the Sun.
Lightning would be a little more difi cult to render and clouds are quite com-
plicated. It is much easier to use a ready-made image i le to load and display
on the screen. The TFT library can do this off of an SD card.
Search WWH ::
Custom Search