Modifications

Sauter à la navigation Sauter à la recherche
2 316 octets ajoutés ,  22 juin 2012 à 19:46
Ligne 58 : Ligne 58 :     
== Primitives graphiques ==
 
== Primitives graphiques ==
xxx
+
Each device-specific display library will have its own constructors and initialization functions. These are documented in the individual tutorials for each display type, or oftentimes are evident in the specific library header file. The remainder of this tutorial covers the common graphics functions that work the same regardless of the display type.
 +
 
 +
The function descriptions below are merely prototypes — there’s an assumption that a display object is declared and initialized as needed by the device-specific library. Look at the example code with each library to see it in actual use. For example, where we show print(1234.56), your actual code would place the object name before this, e.g. it might read screen.print(1234.56) (if you have declared your display object with the name screen).
 +
 
 +
=== Dessiner des pixels (points) ===
 +
First up is the most basic pixel pusher. You can call this with X, Y coordinates and a color and it will make a single dot:
 +
 
 +
void drawPixel(uint16_t x, uint16_t y, uint16_t color);
 +
 
 +
[[Fichier:GLX-DrawPixel.jpg]]
 +
 
 +
=== Dessiner une ligne ===
 +
You can also draw lines, with a starting and end point and color:
 +
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
 +
 
 +
[[Fichier:GLX-DrawLine1.jpg]]
 +
 
 +
[[Fichier:GLX-DrawLine2.jpg]]
 +
 
 +
For horizontal or vertical lines, there are optimized line-drawing functions that avoid the angular calculations:
 +
 
 +
void drawFastVLine(uint16_t x0, uint16_t y0, uint16_t length, uint16_t color);
 +
void drawFastHLine(uin86_t x0, uin86_t y0, uint8_t length, uint16_t color);
 +
 
 +
=== Dessiner un rectangle ===
 +
 
 +
Next up, rectangles and squares can be drawn and filled using the following procedures. Each accepts an X, Y pair for the top-left corner of the rectangle, a width and height (in pixels), and a color. drawRect() renders just the frame (outline) of the rectangle — the interior is unaffected — while fillRect() fills the entire area with a given color:
 +
 
 +
void drawRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);
 +
void fillRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);
 +
 
 +
[[Fichier:GLX-DrawRect1.jpg]]
 +
 
 +
[[Fichier:GLX-DrawRect2.jpg]]
 +
 
 +
To create a solid rectangle with a contrasting outline, use fillRect() first, then drawRect() over it.
 +
 
 +
=== Dessiner des cercles ===
    
== Références ==
 
== Références ==
30 894

modifications

Menu de navigation