PicoVGA  1.2-cmake
VGA/TV display on Raspberry Pico
canvas.h
Go to the documentation of this file.
1 
8 #ifndef _CANVAS_H
9 #define _CANVAS_H
10 
11 #define DRAW_HWINTER 1 // 1=use hardware interpolator to draw images
12 
29 // canvas format
30 // Note: do not use enum, symbols could not be used by the preprocessor
31 #define CANVAS_8 0
32 #define CANVAS_4 1
33 #define CANVAS_2 2
34 #define CANVAS_1 3 // 1-bit pixels
35 #define CANVAS_PLANE2 4
36 #define CANVAS_ATTRIB8 5
39 
41 typedef struct {
42  u8* img;
43  u8* img2;
44  int w;
45  int h;
46  int wb;
47  u8 format;
48 } sCanvas;
49 
59 void DrawRect(sCanvas* canvas, int x, int y, int w, int h, u8 col);
60 
70 void DrawFrame(sCanvas* canvas, int x, int y, int w, int h, u8 col);
71 
76 void DrawClear(sCanvas* canvas);
77 
85 void DrawPoint(sCanvas* canvas, int x, int y, u8 col);
86 
96 void DrawLine(sCanvas* canvas, int x1, int y1, int x2, int y2, u8 col);
97 
114 void DrawFillCircle(sCanvas* canvas, int x0, int y0, int r, u8 col, u8 mask=0xff);
115 
132 void DrawCircle(sCanvas* canvas, int x0, int y0, int r, u8 col, u8 mask=0xff);
133 
146 void DrawText(sCanvas* canvas, const char* text, int x, int y, u8 col,
147  const void* font, int fontheight=8, int scalex=1, int scaley=1);
148 
162 void DrawTextBg(sCanvas* canvas, const char* text, int x, int y, u8 col, u8 bgcol,
163  const void* font, int fontheight=8, int scalex=1, int scaley=1);
164 
176 void DrawImg(sCanvas* canvas, sCanvas* src, int xd, int yd, int xs, int ys, int w, int h);
177 
191 void DrawBlit(sCanvas* canvas, sCanvas* src, int xd, int yd, int xs, int ys, int w, int h, u8 col);
192 
194 enum {
201 };
202 
216 void DrawImgMat(sCanvas* canvas, const sCanvas* src, int x, int y, int w, int h,
217  const class cMat2Df* m, u8 mode, u8 color);
218 
234 void DrawTileMap(sCanvas* canvas, const sCanvas* src, const u8* map, int mapwbits, int maphbits,
235  int tilebits, int x, int y, int w, int h, const cMat2Df* mat, u8 horizon);
236 
249 void DrawImgLine(sCanvas* canvas, sCanvas* src, int xd, int yd, int xs, int ys, int wd, int ws);
250 
252 
253 #endif // _CANVAS_H
2D Transformation Matrix
Definition: mat2d.h:263
void DrawFrame(sCanvas *canvas, int x, int y, int w, int h, u8 col)
Draw frame of 1 pixel thickness.
Definition: canvas.cpp:342
void DrawImg(sCanvas *canvas, sCanvas *src, int xd, int yd, int xs, int ys, int w, int h)
Draw image (without transparency)
Definition: canvas.cpp:1002
void DrawCircle(sCanvas *canvas, int x0, int y0, int r, u8 col, u8 mask=0xff)
Draw circle.
Definition: canvas.cpp:837
void DrawLine(sCanvas *canvas, int x1, int y1, int x2, int y2, u8 col)
Draw a line.
Definition: canvas.cpp:533
void DrawClear(sCanvas *canvas)
Clear canvas (fill with black color)
Definition: canvas.cpp:352
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)
Definition: canvas.cpp:870
void DrawBlit(sCanvas *canvas, sCanvas *src, int xd, int yd, int xs, int ys, int w, int h, u8 col)
Draw image with transparency.
Definition: canvas.cpp:1480
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.
void DrawPoint(sCanvas *canvas, int x, int y, u8 col)
Draw a pixel.
Definition: canvas.cpp:359
void DrawImgLine(sCanvas *canvas, sCanvas *src, int xd, int yd, int xs, int ys, int wd, int ws)
Draw image line interpolated.
Definition: canvas.cpp:2299
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.
Definition: canvas.cpp:2137
void DrawFillCircle(sCanvas *canvas, int x0, int y0, int r, u8 col, u8 mask=0xff)
Draw filled circle.
Definition: canvas.cpp:708
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.
Definition: canvas.cpp:937
void DrawRect(sCanvas *canvas, int x, int y, int w, int h, u8 col)
Draw rectangle.
Definition: canvas.cpp:16
@ DRAWIMG_PERSP
Perspective floor.
Definition: canvas.h:200
@ DRAWIMG_CLAMP
Clamp image (use last pixel as border)
Definition: canvas.h:197
@ DRAWING_COLOR
Color border.
Definition: canvas.h:198
@ DRAWIMG_NOBORDER
No border (transparent border)
Definition: canvas.h:196
@ DRAWIMG_WRAP
Wrap image.
Definition: canvas.h:195
@ DRAWIMG_TRANSP
Transparent image with key color.
Definition: canvas.h:199
Canvas descriptor.
Definition: canvas.h:41
u8 * img2
Image data 2 (2nd plane of CANVAS_PLANE2, attributes of CANVAS_ATTRIB8)
Definition: canvas.h:43
int w
Width.
Definition: canvas.h:44
u8 format
Canvas format CANVAS_*.
Definition: canvas.h:47
u8 * img
Image data.
Definition: canvas.h:42
int wb
Pitch (bytes between lines)
Definition: canvas.h:46
int h
Height.
Definition: canvas.h:45