29 int32_t *pX2, int32_t *pY2);
85 status = DMD_setClippingArea(x1, y1, length, 1);
86 if (status != DMD_OK)
return status;
89 status = DMD_writeColor(0, 0, red, green, blue, length);
90 if (status != DMD_OK)
return status;
148 length = y2 - y1 + 1;
149 status = DMD_setClippingArea(x1, y1, 1, length);
150 if (status != DMD_OK)
return status;
153 status = DMD_writeColor(0, 0, red, green, blue, length);
154 if (status != DMD_OK)
return status;
180 if (x < pContext->clippingRegion.xMin) code |= 1;
189 if (y < pContext->clippingRegion.yMin) code |= 8;
218 int32_t *pY1, int32_t *pX2, int32_t *pY2)
220 uint8_t currentCode, code1, code2;
229 if ((code1 | code2) == 0)
return true;
232 if (code1 & code2)
return false;
236 if (code1) currentCode = code1;
237 else currentCode = code2;
240 if (currentCode & 1) {
247 else if (currentCode & 2) {
254 else if (currentCode & 4) {
261 else if (currentCode & 8) {
304 int32_t x2, int32_t y2)
312 bool steepLine =
false;
329 yMotion = (y2 > y1) ? (y2 - y1) : (y1 - y2);
330 xMotion = (x2 > x1) ? (x2 - x1) : (x1 - x2);
331 if (yMotion > xMotion) {
359 deltaY = (y2 > y1) ? (y2 - y1) : (y1 - y2);
365 if (y2 < y1) yStep = -1;
368 for (; x1 <= x2; x1++) {
376 if (status !=
GLIB_OK)
return status;
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.
#define GLIB_ERROR_NOTHING_TO_DRAW
#define GLIB_ERROR_INVALID_ARGUMENT
Silicon Labs Graphics Library.
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...
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.
EMSTATUS GLIB_applyClippingRegion(const GLIB_Context_t *pContext)
Apply the clipping region from the GLIB_Context_t in the DMD driver.
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.
static bool GLIB_clipLine(GLIB_Context_t *pContext, int32_t *pX1, int32_t *pY1, int32_t *pX2, int32_t *pY2)
Clips the line if necessary, using the Cohen-Sutherland algorithm for clipping lines. See Wikipedia for algorithm.
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.
GLIB_Rectangle_t clippingRegion
static uint8_t GLIB_getClipCode(GLIB_Context_t *pContext, int32_t x, int32_t y)
Gets the clip code for the point that is used by Cohen-Sutherland algorithm.
GLIB Drawing Context (Multiple instances of GLIB_Context_t can exist)