![]() |
PicoVGA
1.0-cmake
VGA/TV display on Raspberry Pico
|
Drawing board for shapes and images.
Canvas is a drawing board. It is a support library for working with graphical surfaces and images. The sCanvas structure is a set of parameters that describe the graphical surface, for use in drawing functions. A graphical surface can be either a graphical frame buffer or an image, even in Flash. To draw in a graphical surface, first attach a canvas to it as a definition describing the structure of the area. Likewise, if you want to draw an image to the surface, first create a canvas for the image with its parameters. The parameters are a pointer to the image data, the image dimensions, and the format. The drawing area can be a graphic area with a depth of 1, 2, 4, 8 bits or with attributes. In the case of drawing an image to a canvas, the source and target canvas must have the same format. In the case of transformation matrices, only an 8-bit graphic format can be drawn.
Data Structures | |
struct | sCanvas |
Canvas descriptor. More... | |
class | cMat2Df |
2D Transformation Matrix More... | |
Macros | |
#define | CANVAS_8 0 |
8-bit pixels | |
#define | CANVAS_4 1 |
4-bit pixels | |
#define | CANVAS_2 2 |
2-bit pixels | |
#define | CANVAS_1 3 |
#define | CANVAS_PLANE2 4 |
4 colors on 2 planes | |
#define | CANVAS_ATTRIB8 5 |
Enumerations | |
enum | { DRAWIMG_WRAP, DRAWIMG_NOBORDER, DRAWIMG_CLAMP, DRAWING_COLOR, DRAWIMG_TRANSP, DRAWIMG_PERSP } |
DrawImgMat mode. More... | |
Functions | |
void | DrawRect (sCanvas *canvas, int x, int y, int w, int h, u8 col) |
Draw rectangle. More... | |
void | DrawFrame (sCanvas *canvas, int x, int y, int w, int h, u8 col) |
Draw frame of 1 pixel thickness. More... | |
void | DrawClear (sCanvas *canvas) |
Clear canvas (fill with black color) More... | |
void | DrawPoint (sCanvas *canvas, int x, int y, u8 col) |
Draw a pixel. More... | |
void | DrawLine (sCanvas *canvas, int x1, int y1, int x2, int y2, u8 col) |
Draw a line. More... | |
void | DrawFillCircle (sCanvas *canvas, int x0, int y0, int r, u8 col, u8 mask=0xff) |
Draw filled circle. More... | |
void | DrawCircle (sCanvas *canvas, int x0, int y0, int r, u8 col, u8 mask=0xff) |
Draw circle. More... | |
void | DrawText (sCanvas *canvas, const char *text, int x, int y, u8 col, const void *font, int fontheight=8, int scalex=1, int scaley=1) |
Draw text (transparent background) More... | |
void | DrawTextBg (sCanvas *canvas, const char *text, int x, int y, u8 col, u8 bgcol, const void *font, int fontheight=8, int scalex=1, int scaley=1) |
Draw text with background color. More... | |
void | DrawImg (sCanvas *canvas, sCanvas *src, int xd, int yd, int xs, int ys, int w, int h) |
Draw image (without transparency) More... | |
void | DrawBlit (sCanvas *canvas, sCanvas *src, int xd, int yd, int xs, int ys, int w, int h, u8 col) |
Draw image with transparency. More... | |
void | DrawImgMat (sCanvas *canvas, const sCanvas *src, int x, int y, int w, int h, const class cMat2Df *m, u8 mode, u8 color) |
Draw 8-bit image with 2D transformation matrix. More... | |
void | DrawTileMap (sCanvas *canvas, const sCanvas *src, const u8 *map, int mapwbits, int maphbits, int tilebits, int x, int y, int w, int h, const cMat2Df *mat, u8 horizon) |
Draw tile map using perspective projection. More... | |
void | DrawImgLine (sCanvas *canvas, sCanvas *src, int xd, int yd, int xs, int ys, int wd, int ws) |
Draw image line interpolated. More... | |
#define CANVAS_ATTRIB8 5 |
2x4 bit color attributes per 8x8 pixel sample draw functions: bit 0..3 = draw color bit 4 = draw color is background color
anonymous enum |
void DrawRect | ( | sCanvas * | canvas, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
u8 | col | ||
) |
Draw rectangle.
canvas | Canvas |
x | Horizontal position |
y | Veritical position |
w | Width |
h | Height |
col | Color |
void DrawFrame | ( | sCanvas * | canvas, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
u8 | col | ||
) |
Draw frame of 1 pixel thickness.
canvas | Canvas |
x | Horizontal position |
y | Veritical position |
w | Width |
h | Height |
col | Color |
void DrawClear | ( | sCanvas * | canvas | ) |
Clear canvas (fill with black color)
canvas | Canvas |
void DrawPoint | ( | sCanvas * | canvas, |
int | x, | ||
int | y, | ||
u8 | col | ||
) |
Draw a pixel.
canvas | Canvas |
x | Horizontal position |
y | Veritical position |
col | Color |
void DrawLine | ( | sCanvas * | canvas, |
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
u8 | col | ||
) |
Draw a line.
canvas | Canvas |
x1 | Horizontal start position |
y1 | Veritical start position |
x2 | Horizontal end position |
y2 | Veritical end position |
col | Color |
void DrawFillCircle | ( | sCanvas * | canvas, |
int | x0, | ||
int | y0, | ||
int | r, | ||
u8 | col, | ||
u8 | mask = 0xff |
||
) |
Draw filled circle.
canvas | Canvas |
x0 | Horizontal center coordinate |
y0 | Veritical center coordinate |
r | Radius |
col | Color (with CANVAS_ATTRIB8 format: bit 0..3 = draw color, bit 4 = draw color is background color) |
mask | Mask. Specifies, using bits 0 to 7, which eighths of the circle are drawn. . B2|B1 . B3 . | . B0 ------o------ B4 . | . B7 . B5|B6 . |
void DrawCircle | ( | sCanvas * | canvas, |
int | x0, | ||
int | y0, | ||
int | r, | ||
u8 | col, | ||
u8 | mask = 0xff |
||
) |
Draw circle.
canvas | Canvas |
x0 | Horizontal center coordinate |
y0 | Veritical center coordinate |
r | Radius |
col | Color (with CANVAS_ATTRIB8 format: bit 0..3 = draw color, bit 4 = draw color is background color) |
mask | Mask. Specifies, using bits 0 to 7, which eighths of the circle are drawn. . B2|B1 . B3 . | . B0 ------o------ B4 . | . B7 . B5|B6 . |
void DrawText | ( | sCanvas * | canvas, |
const char * | text, | ||
int | x, | ||
int | y, | ||
u8 | col, | ||
const void * | font, | ||
int | fontheight = 8 , |
||
int | scalex = 1 , |
||
int | scaley = 1 |
||
) |
Draw text (transparent background)
canvas | Canvas |
text | C string to draw |
x | Horizontal position |
y | Verticle position |
col | Text color |
font | Pointer to 1-bit font |
fontheight | Height of font in pixels (default 8) |
scalex | Magnification scale in X dimension |
scaley | Magnification scale in Y dimension |
void DrawTextBg | ( | sCanvas * | canvas, |
const char * | text, | ||
int | x, | ||
int | y, | ||
u8 | col, | ||
u8 | bgcol, | ||
const void * | font, | ||
int | fontheight = 8 , |
||
int | scalex = 1 , |
||
int | scaley = 1 |
||
) |
Draw text with background color.
canvas | Canvas |
text | C string to draw |
x | Horizontal position |
y | Verticle position |
col | Text color |
bgcol | Background color |
font | Pointer to 1-bit font |
fontheight | Height of font in pixels (default 8) |
scalex | Magnification scale in X dimension |
scaley | Magnification scale in Y dimension |
Draw image (without transparency)
canvas | Destination canvas |
src | Source canvas |
xd | Destination horizontal postion |
yd | Destination vertical position |
xs | Source horizontal position |
ys | Source vertical position |
w | Width |
h | Height |
void DrawBlit | ( | sCanvas * | canvas, |
sCanvas * | src, | ||
int | xd, | ||
int | yd, | ||
int | xs, | ||
int | ys, | ||
int | w, | ||
int | h, | ||
u8 | col | ||
) |
Draw image with transparency.
canvas | Destination canvas |
src | Source canvas |
xd | Destination horizontal postion |
yd | Destination vertical position |
xs | Source horizontal position |
ys | Source vertical position |
w | Width |
h | Height |
col | Transparency key color |
void DrawImgMat | ( | sCanvas * | canvas, |
const sCanvas * | src, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
const class cMat2Df * | m, | ||
u8 | mode, | ||
u8 | color | ||
) |
Draw 8-bit image with 2D transformation matrix.
canvas | Destination canvas |
src | Source canvas with image |
x | Destination horizontal postion |
y | Destination vertical position |
w | Destination width |
h | Destination height |
m | Transformation matrix (should be prepared using cMat2Df::PrepDrawImg() function) |
mode | Mode enum value |
color | Key or border color |
void DrawTileMap | ( | sCanvas * | canvas, |
const sCanvas * | src, | ||
const u8 * | map, | ||
int | mapwbits, | ||
int | maphbits, | ||
int | tilebits, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
const cMat2Df * | mat, | ||
u8 | horizon | ||
) |
Draw tile map using perspective projection.
canvas | Destination canvas |
src | Source canvas with column of 8-bit square tiles (width = tile size, must be power of 2) |
map | Byte map of tile indices |
mapwbits | Number of bits of map width (number of tiles; width must be power of 2) |
maphbits | Number of bits of map height (number of tiles; height must be power of 2) |
tilebits | Number of bits of tile size (e.g. 5 = tile 32x32 pixel) |
x | Destination horizontal postion |
y | Destination vertical position |
w | Destination width |
h | Destination height |
mat | Transformation matrix (should be prepared using cMat2Df::PrepDrawImg() function) |
horizon | Horizon offset (0 = do not use perspective projection) |
void DrawImgLine | ( | sCanvas * | canvas, |
sCanvas * | src, | ||
int | xd, | ||
int | yd, | ||
int | xs, | ||
int | ys, | ||
int | wd, | ||
int | ws | ||
) |
Draw image line interpolated.
canvas | Destination canvas (8-bit pixel format) |
src | Source canvas (source image in 8-bit pixel format) |
xd | Destination horizontal postion |
yd | Destination vertical position |
xs | Source horizontal position |
ys | Source vertical position |
wd | Destination width |
ws | Source width |