GLIB - Graphics Library#
Silicon Labs Graphics Library.
Graphics Library
Silicon Labs Graphics Library. Feature rich graphics library for memory constrained applications.
Introduction#
GLIB is a graphics library that can be used to draw pixels, common shapes, text or bitmaps to a display connected to an MCU. The main goal of this library is easy of use and small code and memory footprint. In this way GLIB can be used on even the smallest Cortex-M0 devices.
GLIB treats the display as a matrix of pixels which is a model of the physical display. This matrix is exposed to GLIB via an API called DMD (Dot Matrix Display). So in order to draw something on a physical display the user application needs to provide GLIB with a single implementation of the DMD interface. Sample DMD implementations are provided for the displays that are connected to the Silicon Labs Starter Kits and the Silicon Labs Development Kits.
Initialization#
There are two things that must be initialized before GLIB can be used to draw pixels on the display. First the user needs to initialize the DMD implementation for the actual hardware display which is used. This initialization is display hardware specific.
After the DMD is initialized the user needs to initialize a GLIB_Context_t that can be used for all the drawing operations. A GLIB_Context_t structure is initialized using the GLIB_contextInit() function.
Every GLIB drawing function will require a GLIB_Context_t as one of the functions arguments. The GLIB context contains important configuration values that all the drawing functions use. It contains the foreground and background color, and it also contains information on what font to use when rendering text on the display.
Color#
GLIB represent color in a pixel as three 8 bit color values representing red, green and blue, giving the user support for a 24 bit color depth. The GLIB_rgbColor() function can be used to convert from distinct red, green and blue values to an 32-bit integer representing the color of single pixel. Similarly the GLIB_colorTranslate24bpp() function can be used to convert from the 32-bit integer representation into the 3 separate red, green and blue components. The 32-bit integer representation of a pixel color is used when configuring the foreground and background color.
GLIB also contains some common predefined colors for use in places where a 32-bit integer is used to represent the color. These predefined colors include White, Black, Brown, Orange, and many more. See the GLIB Colors for the full list of colors.
Some displays are monochrome, meaning that they only support 2 colors. When using GLIB to draw shapes on these displays the applications should use only the 2 colors White and Black.
Draw Shapes#
GLIB contains functions for drawing common shapes to a display. Here is a list containing all the drawing functions.
GLIB_drawCircle(). Draw a circle outline with the foreground color.
GLIB_drawCircleFilled(). Draw a circle filled with the foreground color.
GLIB_drawPartialCircle(). Draw specific octants of a circle with the foreground color.
GLIB_drawLine(). Draw line with the foreground color.
GLIB_drawLineH(). Draw a horizontal line.
GLIB_drawLineV(). Draw a vertical line.
GLIB_drawRect(). Draw a rectangle outline with the foreground color.
GLIB_drawRectFilled(). Draw a filled rectangle using the foreground color.
GLIB_drawPolygon(). Draw lines between all the points in the given set using the foreground color.
GLIB_drawPolygonFilled(). Draw filled polygon between points.
Draw Pixels#
These are functions that GLIB provides for drawing one pixel.
GLIB_drawPixel(). Draw a pixel using the foreground color.
GLIB_drawPixelRGB(). Draw a single pixel using a specific color.
GLIB_drawPixelColor(). Draw a single pixel using a specific color.
Font rendering#
GLIB Supports fixed width font rendering. The functions GLIB_drawString() and GLIB_drawChar() are used to render text on the display.
GLIB provides these fonts for the user
GLIB_FontNormal8x8 A normal 8x8 pixel font which is the default font if nothing else is configured.
GLIB_FontNarrow6x8 A narrow 6x8 pixel font which can be used if the default font is to wide.
GLIB_FontNumber16x20 A large font for use with only numbers. This font is 16x20 pixels.
To change the font the user calls GLIB_setFont() with a pointer to a GLIB_Font_t structure which describes the whole font. The GLIB_Font_t structure contains a pointer to the bitmap for each character and it describes attributes of the font like the width and height of each character and it also contains the bitmap of each character.
Draw Bitmap#
To draw an image or custom bitmaps on the display the GLIB_drawBitmap() function can be used. The color displays typically use a bitmap format where each pixel is represented by 3 consecutive bytes representing the red, green and blue color components. While monochrome displays typically use a bitmap format where 1 byte represents 8 pixels where a 1 bit is white and a 0 bit is black. Note that bitmaps are insensitive to the foreground and background color settings, and that the format of the bitmap depends on the DMD implementation of the display.
Example#
This examples shows how to initialize a GLIB context and draw something on a display.
static GLIB_Context_t context;
static const char * msg = "Hello GLIB!";
void glibExample(void)
{
// Setup the dot matrix and initialize the GLIB context - these should be called once
DMD_init(0);
GLIB_contextInit(&context);
// Write our message into the GLIB instance.
GLIB_drawString(&context, msg, strlen(msg), 10, 10, true);
// Needs to be called each time there is a change to GLIB to mirror
// GLIB context data model changes to the physical LCD.
DMD_updateDisplay();
}
Modules#
Functions#
Define the default font.
Returns the display from sleep mode.
Sets the display in sleep mode.
Clears the display with the background color of the GLIB_Context_t.
Clears the clipping region by filling it with the background color of the GLIB_Context_t.
Reset the display driver clipping area to the whole display.
Reset the GLIB_Context_t clipping region to the whole display.
Apply the clipping region from the GLIB_Context_t in the DMD driver.
Extracts the color components from the 32-bit color passed and puts them in the passed in 8-bits ints.
Convert 3 uint8_t color components into a 24-bit color.
Checks if the point passed in is in the interior of the rectangle passed in.
Normalize the rectangle that is passed in.
Sets the clippingRegion of the passed in GLIB_Context_t.
Draws a circle with center at x, y, and a radius.
Draws a filled circle with center at x, y, and a radius.
Draws a partial circle with center at x, y, and a radius.
Set new font for the library.
Draws a string using the font supplied with the library.
Draws a string on the specified line on the display.
Draws a char using the font supplied with the library.
Draws a bitmap.
Inverts each bit of the bitmap.
Draws a line from x1,y1 to x2, y2.
Draws a horizontal line from x1, y1 to x2, y2.
Draws a vertical line from x1, y1 to x1, y2.
Draws a rectangle outline defined by the passed in rectangle.
Draws a filled rectangle defined by the passed in rectangle.
Draws a polygon using Bresnham's Midpoint Line Algorithm.
Draws a filled polygon using a scan line algorithm.
Draws a pixel at x, y with color defined by red, green and blue 1 byte per channel.
Draws a pixel at x, y using foregroundColor defined in the GLIB_Context_t.
Draws a pixel at x, y using the color parameter.
Macros#
GLIB Base error code.
Successful call.
Function did not draw.
Invalid char.
Coordinates out of bounds.
Invalid coordinates (ex.
Invalid argument.
Out of memory.
File not supported.
General IO Error.
Invalid file.
Enumeration Documentation#
GLIB_Font_Class#
GLIB_Font_Class
Font classes.
Enumerator | |
---|---|
InvalidFont | Invalid font. |
FullFont | Characters and numbers font. |
NumbersOnlyFont | Numbers only font. |
230
of file platform/middleware/glib/glib/glib.h
GLIB_Align_t#
GLIB_Align_t
Alignment types.
Enumerator | |
---|---|
GLIB_ALIGN_LEFT | |
GLIB_ALIGN_CENTER | |
GLIB_ALIGN_RIGHT |
238
of file platform/middleware/glib/glib/glib.h
Function Documentation#
GLIB_contextInit#
EMSTATUS GLIB_contextInit (GLIB_Context_t * pContext)
Define the default font.
N/A | pContext | Pointer to a GLIB_Context_t |
An application can override the default font by defining GLIB_NO_DEFAULT_FONT and by providing a custom GLIB_DEFAULT_FONT macro that points to a GLIB_Font_t structure that should be used as a default font.
Initialize the GLIB_Context_t
The context is set to default values and gets information about the display from the display driver.
Returns
Returns GLIB_OK on success, or else error code
310
of file platform/middleware/glib/glib/glib.h
GLIB_displayWakeUp#
EMSTATUS GLIB_displayWakeUp (void )
Returns the display from sleep mode.
N/A |
Returns
Returns DMD_OK on success, or else error code
312
of file platform/middleware/glib/glib/glib.h
GLIB_displaySleep#
EMSTATUS GLIB_displaySleep (void )
Sets the display in sleep mode.
N/A |
Returns
Returns DMD_OK on success, or else error code
314
of file platform/middleware/glib/glib/glib.h
GLIB_clear#
EMSTATUS GLIB_clear (GLIB_Context_t * pContext)
Clears the display with the background color of the GLIB_Context_t.
N/A | pContext | Pointer to a GLIB_Context_t which holds the background color. |
Returns
Returns GLIB_OK on success, or else error code
316
of file platform/middleware/glib/glib/glib.h
GLIB_clearRegion#
EMSTATUS GLIB_clearRegion (const GLIB_Context_t * pContext)
Clears the clipping region by filling it with the background color of the GLIB_Context_t.
N/A | pContext | Pointer to a GLIB_Context_t which holds the background color. |
Returns
Returns GLIB_OK on success, or else error code
318
of file platform/middleware/glib/glib/glib.h
GLIB_resetDisplayClippingArea#
EMSTATUS GLIB_resetDisplayClippingArea (GLIB_Context_t * pContext)
Reset the display driver clipping area to the whole display.
N/A | pContext | Pointer to a GLIB_Context_t |
Returns
Returns GLIB_OK on success, or else error code
320
of file platform/middleware/glib/glib/glib.h
GLIB_resetClippingRegion#
EMSTATUS GLIB_resetClippingRegion (GLIB_Context_t * pContext)
Reset the GLIB_Context_t clipping region to the whole display.
N/A | pContext | Pointer to a GLIB_Context_t |
Returns
Returns GLIB_OK on success, or else error code
322
of file platform/middleware/glib/glib/glib.h
GLIB_applyClippingRegion#
EMSTATUS GLIB_applyClippingRegion (const GLIB_Context_t * pContext)
Apply the clipping region from the GLIB_Context_t in the DMD driver.
N/A | pContext | Pointer to a GLIB_Context_t |
Returns
Returns GLIB_OK on success, or else error code
324
of file platform/middleware/glib/glib/glib.h
GLIB_colorTranslate24bpp#
void GLIB_colorTranslate24bpp (uint32_t color, uint8_t * red, uint8_t * green, uint8_t * blue)
Extracts the color components from the 32-bit color passed and puts them in the passed in 8-bits ints.
N/A | color | The color which is to be translated |
N/A | red | Pointer to a uint8_t holding the red component |
N/A | green | Pointer to a uint8_t holding the green component |
N/A | blue | Pointer to a uint8_t holding the blue component |
The color is 24-bit RGB.
Example: color = 0x00FFFF00 -> red = 0xFF, green = 0xFF, blue = 0x00.
326
of file platform/middleware/glib/glib/glib.h
GLIB_rgbColor#
uint32_t GLIB_rgbColor (uint8_t red, uint8_t green, uint8_t blue)
Convert 3 uint8_t color components into a 24-bit color.
N/A | red | Red component |
N/A | green | Green component |
N/A | blue | Blue component |
Example: red = 0xFF, green = 0xFF, blue = 0x00 -> 0x00FFFF00 = Yellow
Returns
Returns a 32-bit unsigned integer representing the color. The 8 LSB is blue, the next 8 is green and the next 8 is red. 0x00RRGGBB
328
of file platform/middleware/glib/glib/glib.h
GLIB_rectContainsPoint#
bool GLIB_rectContainsPoint (const GLIB_Rectangle_t * pRect, int32_t x, int32_t y)
Checks if the point passed in is in the interior of the rectangle passed in.
N/A | pRect | Pointer to a rectangle structure |
N/A | x | X-coordinate of point |
N/A | y | Y-coordinate of point |
If the point is on the edge of the rectangle the function returns 1.
Returns
Returns false if coordinate is outside the rectangle
Returns true otherwise
330
of file platform/middleware/glib/glib/glib.h
GLIB_normalizeRect#
void GLIB_normalizeRect (GLIB_Rectangle_t * pRect)
Normalize the rectangle that is passed in.
N/A | pRect | Pointer to a rectangle structure |
Sets yMin to the minimum value of yMin and yMax. Sets yMax to the maximum value of yMin and yMax. And the same for xMin and xMax
332
of file platform/middleware/glib/glib/glib.h
GLIB_setClippingRegion#
EMSTATUS GLIB_setClippingRegion (GLIB_Context_t * pContext, const GLIB_Rectangle_t * pRect)
Sets the clippingRegion of the passed in GLIB_Context_t.
N/A | pContext | Pointer to a GLIB_Context_t |
N/A | pRect | Pointer to a GLIB_Rectangle_t which is the clipping region to be set. |
Returns
Returns GLIB_OK on success
Returns GLIB_ERROR_INVALID_CLIPPINGREGION if invalid coordinates
Returns GLIB_OUT_OF_BOUNDS if clipping region is bigger than display clipping area
334
of file platform/middleware/glib/glib/glib.h
GLIB_drawCircle#
EMSTATUS GLIB_drawCircle (GLIB_Context_t * pContext, int32_t xCenter, int32_t yCenter, uint32_t radius)
Draws a circle with center at x, y, and a radius.
N/A | pContext | Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color. |
N/A | xCenter | Center x-coordinate |
N/A | yCenter | Center y-coordinate |
N/A | radius | Radius of the circle |
Draws a circle using the Midpoint Circle Algorithm. See Wikipedia for algorithm. Algorithm is optimized to use only integer arithmetic, so no floating point arithmetic is needed.
Returns
Returns GLIB_OK on success, or else error code
336
of file platform/middleware/glib/glib/glib.h
GLIB_drawCircleFilled#
EMSTATUS GLIB_drawCircleFilled (GLIB_Context_t * pContext, int32_t xCenter, int32_t yCenter, uint32_t radius)
Draws a filled circle with center at x, y, and a radius.
N/A | pContext | Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color. |
N/A | xCenter | Center x-coordinate |
N/A | yCenter | Center y-coordinate |
N/A | radius | Radius of the circle |
Draws a circle using the Midpoint Circle Algorithm and using horizontal lines. See Wikipedia for algorithm.
Returns
Returns GLIB_OK on succes. Returns GLIB_ERROR_NOTHING_TO_DRAW if none of the pixel coordinates were inside the clipping region. Returns error code otherwise.
339
of file platform/middleware/glib/glib/glib.h
GLIB_drawPartialCircle#
EMSTATUS GLIB_drawPartialCircle (GLIB_Context_t * pContext, int32_t xCenter, int32_t yCenter, uint32_t radius, uint8_t bitMask)
Draws a partial circle with center at x, y, and a radius.
N/A | pContext | Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color. |
N/A | xCenter | Center x-coordinate |
N/A | yCenter | Center y-coordinate |
N/A | radius | Radius of the circle |
N/A | bitMask | Bitmask which decides which octants pixels should be drawn. The LSB is 1. octant, and the MSB is 8. octant. |
Draws a partial circle using the Midpoint Circle Algorithm. Algorithm is optimized to use only integer arithmetic, so no floating point arithmetic is needed. The bitMask passed in decides which octant that should be drawn. The octants is numbered 1 to 8 in counterclockwise order.
Example: bitMask == 4 draws only pixels in 3. octant (00000100). bitMask == 5 draws only pixels in 3. and 1. octant (00000101).
Returns
Returns GLIB_OK on success, or else error code
342
of file platform/middleware/glib/glib/glib.h
GLIB_setFont#
EMSTATUS GLIB_setFont (GLIB_Context_t * pContext, GLIB_Font_t * pFont)
Set new font for the library.
N/A | pContext | Pointer to the GLIB_Context_t |
N/A | pFont | Pointer to the new font |
Note that GLIB defines a default font in glib.c. Redefine GLIB_DEFAULT_FONT to change the default font.
Returns
Returns GLIB_OK on success, or else error code
345
of file platform/middleware/glib/glib/glib.h
GLIB_drawString#
EMSTATUS GLIB_drawString (GLIB_Context_t * pContext, const char * pString, uint32_t sLength, int32_t x0, int32_t y0, bool opaque)
Draws a string using the font supplied with the library.
N/A | pContext | Pointer to a GLIB_Context_t |
N/A | pString | Pointer to the string that is drawn |
N/A | sLength | number of characters in the string |
N/A | x0 | Start x-coordinate for the string (Upper left corner) |
N/A | y0 | Start y-coordinate for the string (Upper left corner) |
N/A | opaque | Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == 1, the background color is used. |
Returns
Returns GLIB_OK on success, or else error code
347
of file platform/middleware/glib/glib/glib.h
GLIB_drawStringOnLine#
EMSTATUS GLIB_drawStringOnLine (GLIB_Context_t * pContext, const char * pString, uint8_t line, GLIB_Align_t align, int32_t xOffset, int32_t yOffset, bool opaque)
Draws a string on the specified line on the display.
N/A | pContext | Pointer to a GLIB_Context_t |
N/A | pString | Pointer to the string that is drawn |
N/A | line | Specifies which line on the display to draw on. |
N/A | align | Horizontal alignment of the string on the line. This can be left, right or center. Note that left alignment is default. |
N/A | xOffset | This parameter can be used to create a margin on the left or right side of the string. Note that this argument accepts a negative value which can be useful when aligning the string to the right. |
N/A | yOffset | This parameter can be used to move the string further down or up a certain number of pixels. A positive value would move the string down, while a negative value would move the string up. |
N/A | opaque | Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == 1, the background color is used. |
Returns
Returns GLIB_OK on success, or else error code
350
of file platform/middleware/glib/glib/glib.h
GLIB_drawChar#
EMSTATUS GLIB_drawChar (GLIB_Context_t * pContext, char myChar, int32_t x, int32_t y, bool opaque)
Draws a char using the font supplied with the library.
N/A | pContext | Pointer to the GLIB_Context_t |
N/A | myChar | Char to be drawn |
N/A | x | Start x-coordinate for the char (Upper left corner) |
N/A | y | Start y-coordinate for the char (Upper left corner) |
N/A | opaque | Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == true, the background color is used. |
Returns
Returns GLIB_OK on success, or else error code
353
of file platform/middleware/glib/glib/glib.h
GLIB_drawBitmap#
EMSTATUS GLIB_drawBitmap (GLIB_Context_t * pContext, int32_t x, int32_t y, uint32_t width, uint32_t height, const uint8_t * picData)
Draws a bitmap.
N/A | pContext | Pointer to a GLIB_Context_t in which the bitmap is drawn. |
N/A | x | Start x-coordinate for bitmap |
N/A | y | Start y-coordinate for bitmap |
N/A | width | Width of picture |
N/A | height | Height of picture |
N/A | picData | Bitmap data |
Sets up a bitmap that starts at x0,y0 and draws bitmap.
For monochrome displays, each 8-bit element contains 8 pixel values. A bit value of 1 indicates a white pixel, while 0 indicates a black pixel. Note that this format may vary with the DMD implementation.
For 3-bit RGB displays, each bit in the array are one color component (red, green and blue) of the pixel, so that 3 bits represent one pixel (0xBGR). Pixel 0: Bits 2:0 (0bBGR) of byte 0 Pixel 1: Bits 5:3 (0bBGR) of byte 0 Pixel 2: Bits 7:6 (0bGR) of byte 0 and bit 0 (0bB) of byte 1 Pixel 3: Bits 3:1 (0bBGR) of byte 1 ...
For RGB displays with 8-bits per color, each pixel is represented by 24-bits, with one byte for each of the red, green and blue components. The data has to be organized like this: picData = { R, G, B, R, G, B, R, G, B ... }
The pixels are ordered by increasing x coordinate, after the last pixel of a row, the next pixel will be the first pixel on the next row.
Returns
Returns GLIB_OK on success, or else error code
356
of file platform/middleware/glib/glib/glib.h
GLIB_invertBitmap#
void GLIB_invertBitmap (GLIB_Context_t * pContext, uint32_t bitmapSize, uint8_t * picData)
Inverts each bit of the bitmap.
N/A | pContext | Pointer to a GLIB_Context_t in which the bitmap is drawn. |
N/A | bitmapSize | Size of the bitmap array in terms of bytes. |
N/A | picData | Bitmap data. |
For monochrome displays, the result is an inversion of the image.
For RGB displays, the result is the negative of the input image.
Note
The function inverts entire bytes, meaning that any bits contained within the array that may not be part of the image will also be inverted.
359
of file platform/middleware/glib/glib/glib.h
GLIB_drawLine#
EMSTATUS GLIB_drawLine (GLIB_Context_t * pContext, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
Draws a line from x1,y1 to x2, y2.
N/A | pContext | Pointer to the GLIB_Context_t which holds the clipping region |
N/A | x1 | Start x-coordinate |
N/A | y1 | Start y-coordinate |
N/A | x2 | End x-coordinate |
N/A | y2 | End y-coordinate |
Draws a straight line using the Bresnham's Midpoint Line Algorithm. Checks for vertical and horizontal line.
Returns
Returns GLIB_OK on success, or else error code
362
of file platform/middleware/glib/glib/glib.h
GLIB_drawLineH#
EMSTATUS GLIB_drawLineH (GLIB_Context_t * pContext, int32_t x1, int32_t y1, int32_t x2)
Draws a horizontal line from x1, y1 to x2, y2.
N/A | pContext | Pointer to a GLIB_Context_t in which the line is drawn. The line is drawn using the foreground color. |
N/A | x1 | Start x-coordinate |
N/A | y1 | Start y-coordinate |
N/A | x2 | End x-coordinate |
Returns
Returns GLIB_OK on success, or else error code
365
of file platform/middleware/glib/glib/glib.h
GLIB_drawLineV#
EMSTATUS GLIB_drawLineV (GLIB_Context_t * pContext, int32_t x1, int32_t y1, int32_t y2)
Draws a vertical line from x1, y1 to x1, y2.
N/A | pContext | Pointer to a GLIB_Context_t which the line is drawn. The line is drawn using the foreground color. |
N/A | x1 | Start x-coordinate |
N/A | y1 | Start y-coordinate |
N/A | y2 | End y-coordinate |
Returns
Returns GLIB_OK on success, or else error code
368
of file platform/middleware/glib/glib/glib.h
GLIB_drawRect#
EMSTATUS GLIB_drawRect (GLIB_Context_t * pContext, const GLIB_Rectangle_t * pRect)
Draws a rectangle outline defined by the passed in rectangle.
N/A | pContext | Pointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is drawn using the foreground color. |
N/A | pRect | Pointer to a rectangle structure |
Returns
Returns GLIB_OK on success, or else error code
371
of file platform/middleware/glib/glib/glib.h
GLIB_drawRectFilled#
EMSTATUS GLIB_drawRectFilled (GLIB_Context_t * pContext, const GLIB_Rectangle_t * pRect)
Draws a filled rectangle defined by the passed in rectangle.
N/A | pContext | Pointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is filled with the foreground color. |
N/A | pRect | Pointer to a rectangle structure |
The filled rectangle is drawn from (xMin, yMin) to (xMax, yMax), inclusive, of the rectangle passed in.
Returns
Returns GLIB_OK on success, or else error code
373
of file platform/middleware/glib/glib/glib.h
GLIB_drawPolygon#
EMSTATUS GLIB_drawPolygon (GLIB_Context_t * pContext, uint32_t numPoints, const int32_t * polyPoints)
Draws a polygon using Bresnham's Midpoint Line Algorithm.
N/A | pContext | Pointer to a GLIB_Context_t which the line is drawn. The lines are drawn using the foreground color. |
N/A | numPoints | Number of points in the polygon ( Has to be greater than 1 ) |
N/A | polyPoints | Pointer to array of polygon points. The points are laid out like this: polyPoints = {x1,y1,x2,y2 ... } Polypoints has to contain at least (numPoints * 2) entries |
This function draws a line between all points outlining the polygon. The first and last point doesn't have to be the same. The function automatically draws a line from the start point to the end point.
Returns
Returns GLIB_OK on if at least one element was drawn, or else error code
376
of file platform/middleware/glib/glib/glib.h
GLIB_drawPolygonFilled#
EMSTATUS GLIB_drawPolygonFilled (GLIB_Context_t * pContext, uint32_t numPoints, const int32_t * polyPoints)
Draws a filled polygon using a scan line algorithm.
N/A | pContext | Pointer to a GLIB_Context_t where the polygon is drawn. The polygon drawn using the foreground color. |
N/A | numPoints | Number of points in the polygon ( Has to be greater than 1 ) |
N/A | polyPoints | Pointer to array of polygon points. The points are laid out like this: polyPoints = {x1,y1,x2,y2 ... } Polypoints has to contain at least (numPoints * 2) entries |
This function draws a line between all points outlining the polygon. The first and last point doesn't have to be the same. The function automatically draws a line from the start point to the end point.
Returns
Returns GLIB_OK on success, otherwise a GLIB error code.
379
of file platform/middleware/glib/glib/glib.h
GLIB_drawPixelRGB#
EMSTATUS GLIB_drawPixelRGB (GLIB_Context_t * pContext, int32_t x, int32_t y, uint8_t red, uint8_t green, uint8_t blue)
Draws a pixel at x, y with color defined by red, green and blue 1 byte per channel.
N/A | pContext | Pointer to a GLIB_Context_t which holds the clipping region |
N/A | x | X-coordinate |
N/A | y | Y-coordinate |
N/A | red | 8-bit red code |
N/A | green | 8-bit green code |
N/A | blue | 8-bit blue code |
Example: To draw a yellow pixel at (10, 10). x = 10, y = 10, red = 0xFF, green = 0xFF, blue = 0x00
Returns
Returns DMD_OK on success, or else error code
382
of file platform/middleware/glib/glib/glib.h
GLIB_drawPixel#
EMSTATUS GLIB_drawPixel (GLIB_Context_t * pContext, int32_t x, int32_t y)
Draws a pixel at x, y using foregroundColor defined in the GLIB_Context_t.
N/A | pContext | Pointer to a GLIB_Context_t which holds the foreground color and clipping region |
N/A | x | X-coordinate |
N/A | y | Y-coordinate |
Returns
Returns GLIB_OK on success, or else error code
385
of file platform/middleware/glib/glib/glib.h
GLIB_drawPixelColor#
EMSTATUS GLIB_drawPixelColor (GLIB_Context_t * pContext, int32_t x, int32_t y, uint32_t color)
Draws a pixel at x, y using the color parameter.
N/A | pContext | Pointer to a GLIB_Context_t which holds the clipping region |
N/A | x | X-coordinate |
N/A | y | Y-coordinate |
N/A | color | 32-bit int defining the RGB color. The 24 LSB defines the RGB color like this: RRRRRRRRGGGGGGGGBBBBBBBB. Example: Yellow = 0x00FFFF00 |
Returns
Returns DMD_OK on success, or else error code
387
of file platform/middleware/glib/glib/glib.h
Macro Definition Documentation#
ECODE_GLIB_BASE#
#define ECODE_GLIB_BASEValue:
0x00000000
GLIB Base error code.
204
of file platform/middleware/glib/glib/glib.h
GLIB_OK#
#define GLIB_OKValue:
0x00000000
Successful call.
208
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_NOTHING_TO_DRAW#
#define GLIB_ERROR_NOTHING_TO_DRAWValue:
(ECODE_GLIB_BASE | 0x0001)
Function did not draw.
210
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_INVALID_CHAR#
#define GLIB_ERROR_INVALID_CHARValue:
(ECODE_GLIB_BASE | 0x0002)
Invalid char.
212
of file platform/middleware/glib/glib/glib.h
GLIB_OUT_OF_BOUNDS#
#define GLIB_OUT_OF_BOUNDSValue:
(ECODE_GLIB_BASE | 0x0003)
Coordinates out of bounds.
214
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_INVALID_CLIPPINGREGION#
#define GLIB_ERROR_INVALID_CLIPPINGREGIONValue:
(ECODE_GLIB_BASE | 0x0004)
Invalid coordinates (ex.
xMin > xMax)
216
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_INVALID_ARGUMENT#
#define GLIB_ERROR_INVALID_ARGUMENTValue:
(ECODE_GLIB_BASE | 0x0005)
Invalid argument.
218
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_OUT_OF_MEMORY#
#define GLIB_ERROR_OUT_OF_MEMORYValue:
(ECODE_GLIB_BASE | 0x0006)
Out of memory.
220
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_FILE_NOT_SUPPORTED#
#define GLIB_ERROR_FILE_NOT_SUPPORTEDValue:
(ECODE_GLIB_BASE | 0x0007)
File not supported.
222
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_IO#
#define GLIB_ERROR_IOValue:
(ECODE_GLIB_BASE | 0x0008)
General IO Error.
224
of file platform/middleware/glib/glib/glib.h
GLIB_ERROR_INVALID_FILE#
#define GLIB_ERROR_INVALID_FILEValue:
(ECODE_GLIB_BASE | 0x0009)
Invalid file.
226
of file platform/middleware/glib/glib/glib.h
GLIB_NO_DEFAULT_FONT#
#define GLIB_NO_DEFAULT_FONT
394
of file platform/middleware/glib/glib/glib.h