Canvas graphics library
0.1.0
This library is developed to perform canvas graphics in memory buffers
|
#include <canvas.h>
Public Member Functions | |
NanoCanvasOps () | |
NanoCanvasOps (lcdint_t w, lcdint_t h, uint8_t *bytes) | |
void | begin (lcdint_t w, lcdint_t h, uint8_t *bytes) |
void | setOffset (lcdint_t ox, lcdint_t oy) |
const NanoPoint | offsetEnd () const |
const NanoRect | rect () const |
void | putPixel (lcdint_t x, lcdint_t y) |
void | putPixel (const NanoPoint &p) |
void | drawVLine (lcdint_t x1, lcdint_t y1, lcdint_t y2) |
void | drawHLine (lcdint_t x1, lcdint_t y1, lcdint_t x2) |
void | drawLine (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) |
void | drawLine (const NanoRect &rect) |
void | drawRect (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline)) |
void | drawRect (const NanoRect &rect) |
void | fillRect (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline)) |
void | fillRect (const NanoRect &rect) |
void | drawBitmap1 (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline)) |
Draws monochrome bitmap in color buffer using color, specified via setColor() method Draws monochrome bitmap in color buffer using color, specified via setColor() method. More... | |
void | drawBitmap8 (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline)) |
Draws 8-bit color bitmap in color buffer. Draws 8-bit color bitmap in color buffer. More... | |
void | clear () __attribute__((noinline)) |
size_t | write (uint8_t c) |
uint8_t | printChar (uint8_t c) |
void | printFixed (lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) __attribute__((noinline)) |
void | printFixedPgm (lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) |
void | setMode (uint8_t modeFlags) |
Sets canvas drawing mode Sets canvas drawing mode. The set flags define transparency of output images. More... | |
void | setColor (uint16_t color) |
void | setFont (NanoFont &font) |
void | setFixedFont (const uint8_t *progmemFont) |
void | setFreeFont (const uint8_t *progmemFont, const uint8_t *secondaryFont=nullptr) |
uint8_t * | getData () |
lcduint_t | width () |
lcduint_t | pitch () |
lcduint_t | height () |
Public Attributes | |
NanoPoint | offset |
Static Public Attributes | |
static const uint8_t | BITS_PER_PIXEL = BPP |
Protected Attributes | |
lcduint_t | m_w |
width of NanoCanvas area in pixels | |
lcduint_t | m_h |
height of NanoCanvas area in pixels | |
lcdint_t | m_cursorX |
current X cursor position for text output | |
lcdint_t | m_cursorY |
current Y cursor position for text output | |
uint8_t | m_textMode |
Flags for current NanoCanvas mode. | |
EFontStyle | m_fontStyle |
currently active font style | |
uint8_t * | m_buf |
Canvas data. | |
uint16_t | m_color |
current color for monochrome operations | |
NanoFont * | m_font = nullptr |
current set font to use with NanoCanvas | |
NanoCanvasOps provides operations for drawing in memory buffer. Depending on BPP argument, this class can work with 1,8,16-bit canvas areas.
|
inline |
|
inline |
void NanoCanvasOps< BPP >::begin | ( | lcdint_t | w, |
lcdint_t | h, | ||
uint8_t * | bytes | ||
) |
Initializes canvas object. Width can be of any value. Height should be divided by 8. Memory buffer must be not less than w * h.
w | - width |
h | - height |
bytes | - pointer to memory buffer to use |
void NanoCanvasOps< BPP >::clear | ( | ) |
Clears canvas
void NanoCanvasOps< BPP >::drawBitmap1 | ( | lcdint_t | x, |
lcdint_t | y, | ||
lcduint_t | w, | ||
lcduint_t | h, | ||
const uint8_t * | bitmap | ||
) |
Draws monochrome bitmap in color buffer using color, specified via setColor() method Draws monochrome bitmap in color buffer using color, specified via setColor() method.
x | - position X in pixels |
y | - position Y in pixels |
w | - width in pixels |
h | - height in pixels |
bitmap | - monochrome bitmap data, located in flash |
void NanoCanvasOps< BPP >::drawBitmap8 | ( | lcdint_t | x, |
lcdint_t | y, | ||
lcduint_t | w, | ||
lcduint_t | h, | ||
const uint8_t * | bitmap | ||
) |
Draws 8-bit color bitmap in color buffer. Draws 8-bit color bitmap in color buffer.
x | - position X in pixels |
y | - position Y in pixels |
w | - width in pixels |
h | - height in pixels |
bitmap | - 8-bit color bitmap data, located in flash |
void NanoCanvasOps< BPP >::drawHLine | ( | lcdint_t | x1, |
lcdint_t | y1, | ||
lcdint_t | x2 | ||
) |
Draws horizontal or vertical line
x1 | - position X |
y1 | - position Y |
x2 | - position X |
void NanoCanvasOps< BPP >::drawLine | ( | lcdint_t | x1, |
lcdint_t | y1, | ||
lcdint_t | x2, | ||
lcdint_t | y2 | ||
) |
Draws line
x1 | - position X |
y1 | - position Y |
x2 | - position X |
y2 | - position Y |
void NanoCanvasOps< BPP >::drawLine | ( | const NanoRect & | rect | ) |
Draws line
rect | - structure, describing rectangle area |
void NanoCanvasOps< BPP >::drawRect | ( | lcdint_t | x1, |
lcdint_t | y1, | ||
lcdint_t | x2, | ||
lcdint_t | y2 | ||
) |
Draws rectangle
x1 | - position X |
y1 | - position Y |
x2 | - position X |
y2 | - position Y |
void NanoCanvasOps< BPP >::drawRect | ( | const NanoRect & | rect | ) |
Draws rectangle
rect | - structure, describing rectangle area |
void NanoCanvasOps< BPP >::drawVLine | ( | lcdint_t | x1, |
lcdint_t | y1, | ||
lcdint_t | y2 | ||
) |
Draws horizontal or vertical line
x1 | - position X |
y1 | - position Y |
y2 | - position Y |
void NanoCanvasOps< BPP >::fillRect | ( | lcdint_t | x1, |
lcdint_t | y1, | ||
lcdint_t | x2, | ||
lcdint_t | y2 | ||
) |
Fills rectangle area
x1 | - position X |
y1 | - position Y |
x2 | - position X |
y2 | - position Y |
void NanoCanvasOps< BPP >::fillRect | ( | const NanoRect & | rect | ) |
Fills rectangle area
rect | - structure, describing rectangle area |
|
inline |
|
inline |
|
inline |
Returns right-bottom point of the canvas in offset terms. If offset is (0,0), then offsetEnd() will return (width-1,height-1).
|
inline |
uint8_t NanoCanvasOps< BPP >::printChar | ( | uint8_t | c | ) |
Draws single character to canvas
c | - character code to print |
void NanoCanvasOps< BPP >::printFixed | ( | lcdint_t | xpos, |
lcdint_t | y, | ||
const char * | ch, | ||
EFontStyle | style = STYLE_NORMAL |
||
) |
Print text at specified position to canvas
xpos | position in pixels |
y | position in pixels |
ch | pointer to NULL-terminated string. |
style | specific font style to use |
void NanoCanvasOps< BPP >::printFixedPgm | ( | lcdint_t | xpos, |
lcdint_t | y, | ||
const char * | ch, | ||
EFontStyle | style = STYLE_NORMAL |
||
) |
Print text at specified position to canvas
xpos | position in pixels |
y | position in pixels |
ch | pointer to NULL-terminated string, located in flash |
style | specific font style to use |
void NanoCanvasOps< BPP >::putPixel | ( | lcdint_t | x, |
lcdint_t | y | ||
) |
Draws pixel on specified position
x | - position X |
y | - position Y |
void NanoCanvasOps< BPP >::putPixel | ( | const NanoPoint & | p | ) |
|
inline |
|
inline |
|
inline |
Sets new font to use with print functions. If multiple canvases are used in single application, this method can cause conflicts.
progmemFont | pointer to font data in flash (refer to NanoFont::loadFixedFont) |
|
inline |
|
inline |
Sets new font to use with print functions. If multiple canvases are used in single application, this method can cause conflicts.
progmemFont | pointer to font data in flash (refer to NanoFont::loadFreeFont) |
secondaryFont | pointer to font data in flash (refer to NanoFont::loadSecondaryFont) |
|
inline |
|
inline |
|
inline |
size_t NanoCanvasOps< BPP >::write | ( | uint8_t | c | ) |
Writes single character to canvas
c | - character code to print |
|
static |
NanoPoint NanoCanvasOps< BPP >::offset |
Fixed offset for all operation of NanoCanvasOps in pixels