Drawing

From uGFX Wiki
Revision as of 00:39, 3 July 2014 by Tectu (Talk | contribs)

Jump to: navigation, search

The GDISP module offers many high-level API calls to draw single pixels, primitive shapes, fonts and even whole pictures to a display. 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 to gdispXxx().

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 reference 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