Difference between revisions of "Drawing"

From uGFX Wiki
Jump to: navigation, search
(Created page with "ToDo Category:GDISP")
 
Line 1: Line 1:
ToDo
+
The GDISP module offers many high-level API calls to draw single pixels, primitive shapes, fonts and even whole pictures to a display. Please refer to the GDISP API documentation to learn about the provided calls.
 +
An important note at this point: All the provided functions that eventually access the displays use the <code>gdispGXxx()</code> naming convention. The first parameter represents the display that shall be accessed. If you don't use the multiple displays support, just leave the G out of the call. Every <code>gdispGXxx()</code> call has it's own wrapper macro.
 +
 
 +
== Colors ==
 +
The application automatically uses the color format of the used display controller. There are many different macros that allow you to inspect the used color format, retrive a certain color or blend colors together. Please refer to the GDISP API documentation to learn about these features.
 +
 
 +
== Streaming ==
 +
If you're dealing with animations, you might want to use the streaming API to directly manipulate the pixels within a certain area on your display.
 +
You have to enable the streaming capabilities in your [[gfxconf.h]]:
 +
<syntaxhighlight lang=c>
 +
#define GDISP_NEED_STREAMING TRUE
 +
</syntaxhighlight>
 +
Streaming to a display is a three steps process:
 +
 
 +
#Define the area to which you want to streaming using <code>gdispStreamStart()</code>
 +
#Stream as many pixels as you want to the given area by using <code>gdispStreamColor()</code>
 +
#Once you streamed everything you want to, close the stream by calling <code>gdispStreamStop()</code>
 +
Each call of <code>gdispStreamColor()</code> will automatically increment the cursor position by one pixel. Once you hit the right border of the streaming window, it will automatically jump to the next line.
 +
 
 +
== Primitives ==
 +
The following illustrations give an overview about the most important primitives that can be drawn. The color parameter is used on the blue areas. The grey dots will not be drawn, they are just used to illustrate coordinates.
 +
=== Pixel ===
 +
<syntaxhighlight lang=c>
 +
void gdispDrawPixel(coord_t x, coord_t y, color_t color);
 +
</syntaxhighlight>
 +
draw pixel
 +
 
 +
=== Line ===
 +
<syntaxhighlight lang=c>
 +
void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
 +
</syntaxhighlight>
 +
draw line
 +
 
 +
=== Rectangle ===
 +
<syntaxhighlight lang=c>
 +
void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
 +
</syntaxhighlight>
 +
draw rect
 +
 
 +
<syntaxhighlight lang=c>
 +
void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
 +
</syntaxhighlight>
 +
fill rect
 +
 
 +
=== Circle ===
 +
<syntaxhighlight lang=c>
 +
void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color);
 +
</syntaxhighlight>
 +
draw circle
 +
 
 +
<syntaxhighlight lang=c>
 +
void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color);
 +
</syntaxhighlight>
 +
fill circle
 +
 
 +
=== Arc ===
 +
<syntaxhighlight lang=c>
 +
void gdispDrawArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
 +
</syntaxhighlight>
 +
draw arc
 +
 
 +
<syntaxhighlight lang=c>
 +
void gdispFillArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
 +
</syntaxhighlight>
 +
fill arc
 +
 
 +
=== Ellipse ===
 +
<syntaxhighlight lang=c>
 +
void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
 +
</syntaxhighlight>
 +
draw ellipse
 +
 
 +
<syntaxhighlight lang=c>
 +
void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
 +
</syntaxhighlight>
 +
fill ellipse
 +
 
  
  
  
 
[[Category:GDISP]]
 
[[Category:GDISP]]

Revision as of 00:32, 3 July 2014

The GDISP module offers many high-level API calls to draw single pixels, primitive shapes, fonts and even whole pictures to a display. Please refer to the GDISP API documentation to learn about the provided calls. An important note at this point: All the provided functions that eventually access the displays use the gdispGXxx() naming convention. The first parameter represents the display that shall be accessed. If you don't use the multiple displays support, just leave the G out of the call. Every gdispGXxx() call has it's own wrapper macro.

Colors

The application automatically uses the color format of the used display controller. There are many different macros that allow you to inspect the used color format, retrive a certain color or blend colors together. Please refer to the GDISP API documentation to learn about these features.

Streaming

If you're dealing with animations, you might want to use the streaming API to directly manipulate the pixels within a certain area on your display. You have to enable the streaming capabilities in your gfxconf.h:

#define GDISP_NEED_STREAMING		TRUE

Streaming to a display is a three steps process:

  1. Define the area to which you want to streaming using gdispStreamStart()
  2. Stream as many pixels as you want to the given area by using gdispStreamColor()
  3. Once you streamed everything you want to, close the stream by calling gdispStreamStop()

Each call of gdispStreamColor() will automatically increment the cursor position by one pixel. Once you hit the right border of the streaming window, it will automatically jump to the next line.

Primitives

The following illustrations give an overview about the most important primitives that can be drawn. The color parameter is used on the blue areas. The grey dots will not be drawn, they are just used to illustrate coordinates.

Pixel

void gdispDrawPixel(coord_t x, coord_t y, color_t color);

draw pixel

Line

void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);

draw line

Rectangle

void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);

draw rect

void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);

fill rect

Circle

void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color);

draw circle

void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color);

fill circle

Arc

void gdispDrawArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);

draw arc

void gdispFillArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);

fill arc

Ellipse

void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);

draw ellipse

void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);

fill ellipse