Modifications

Sauter à la navigation Sauter à la recherche
3 092 octets ajoutés ,  24 juin 2012 à 12:36
Ligne 153 : Ligne 153 :     
=== Triangles ===
 
=== Triangles ===
 +
 +
With triangles, once again there are the draw and fill functions. Each requires a full seven parameters: the X, Y coordinates for three corner points defining the triangle, followed by a color:
 +
 +
void drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
 +
void fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
 +
 +
[[Fichier:GLX-DrawTriangle1.jpg]]
 +
 +
=== Caractères et Texte ===
 +
There are two basic string drawing procedures for adding text. The first is just for a single character. You can place this character at any location and with any color. There’s only one font (to save on space) and it’s meant to be 5x8 pixels, but an optional size parameter can be passed which scales the font by this factor (e.g. size=2 will render the text at 10x16 pixels per character). It’s a little blocky but having just a single font helps keep the program size down.
 +
 +
  void drawChar(uint16_t x, uint16_t y, char c, uint16_t color, uint8_t size);
 +
 +
[[Fichier:GLX-DrawChar1.jpg]]
 +
 +
Text is very flexible but operates a bit differently. Instead of one procedure, the text size, color and position are set up in separate functions and then the print() function is used — this makes it easy and provides all of the same string and number formatting capabilities of the familiar Serial.print() function!
 +
 +
void setCursor(uint16_t x0, uint16_t y0);
 +
void setTextColor(uint16_t color);
 +
void setTextColor(uint16_t color, uint16_t backgroundcolor);
 +
void setTextSize(uint8_t size);
 +
void setTextWrap(boolean w);
 +
 +
Begin with setCursor(x, y), which will place the top left corner of the text wherever you please. Initially this is set to (0,0) (the top-left corner of the screen). Then set the text color with setTextColor(color) — by default this is white. Text is normally drawn “clear” — the open parts of each character show the original background contents, but if you want the text to block out what’s underneath, a background color can be specified as an optional second parameter to setTextColor(). Finally, setTextSize(size) will multiply the scale of the text by a given integer factor. Below you can see scales of 1 (the default), 2 and 3. It appears blocky at larger sizes because we only ship the library with a single simple font, to save space.
 +
 +
[[Fichier:GLX-DrawChar2.jpg]]
 +
 +
After setting everything up, you can use print() or println() — just like you do with Serial printing! For example, to print a string, use print("Hello world") - that’s the first line of the image above. You can also use print() for numbers and variables — the second line above is the output of print(1234.56) and the third line is print(0xDEADBEEF, HEX).
 +
 +
By default, long lines of text are set to automatically “wrap” back to the leftmost column. To override this behavior (so text will run off the right side of the display — useful for scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored with setTextWrap(true).
 +
 +
=== Images ===
 +
xxx
    
== Références ==
 
== Références ==
29 917

modifications

Menu de navigation