muteki
Loading...
Searching...
No Matches
canvas.h
Go to the documentation of this file.
1/*
2 * Copyright 2021-present dogtopus
3 * SPDX-License-Identifier: MIT
4 */
5
13#ifndef __MUTEKI_UI_CANVAS_H__
14#define __MUTEKI_UI_CANVAS_H__
15
16#include <muteki/ui/common.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
29extern short GetFontType(void);
30
38extern void SetFontType(short font_type);
39
59extern void WriteAlignString(short x, short y, const void *s, short max_length, int align, unsigned int flags);
60
71extern void WriteChar(short x, short y, UTF16 c, unsigned int flags);
72
85extern void WriteString(short x, short y, const void *s, unsigned int flags);
86
95extern void Printf(const char *format, ...) SYS_IS_PRINTF(1, 2);
96
106extern void PrintfXY(short x, short y, const char *format, ...) SYS_IS_PRINTF(3, 4);
107
121extern int ShowGraphic(short x, short y, lcd_surface_t *surface, unsigned short flags);
122
129extern unsigned int SetCursorSize(unsigned int new_size);
130
137extern unsigned int GetCursorSize(void);
138
146extern void SetCursorPosition(short x, short y);
147
155extern void GetCursorPosition(short *x, short *y);
156
164extern short SetCursorType(short new_type);
165
173extern short GetCursorType(void);
174
180extern void CursorLock(void);
181
187extern void CursorUnlock(void);
188
196extern int SetTransparentColor(int color);
197
204extern int rgbSetBkColor(int color);
205
212extern int rgbSetColor(int color);
213
227short SetPenStyle(short dash, unsigned int *dash_pattern);
228
235short GetPenStyle(unsigned int *dash_pattern);
236
243short GetPenSize(void);
244
251short SetPenSize(short size);
252
261int GetPixel(short x, short y);
262
273int SetPixel(short x, short y, int color);
274
288extern size_t GetImage(short x0, short y0, short x1, short y1, lcd_surface_t *surface);
289
303extern void PutImage(short x, short y, lcd_surface_t *surface, unsigned short flags);
304
317extern void SetDrawArea(short x0, short y0, short x1, short y1);
318
328extern void GetDrawArea(short *x0, short *y0, short *x1, short *y1);
329
340extern void DrawLine(short x0, short y0, short x1, short y1, unsigned int flags);
341
352extern void DrawRect(short x0, short y0, short x1, short y1, unsigned int flags);
353
364extern void FillRect(short x0, short y0, short x1, short y1, unsigned int flags);
365
378extern void DrawRoundRect(short x0, short y0, short x1, short y1, short rx, short ry, unsigned int flags);
379
389extern void DrawCircle(short x, short y, short r, unsigned int flags);
390
401extern void FillCircle(short x, short y, short r, unsigned int flags);
402
413extern void DrawEllipse(short x, short y, short rx, short ry, unsigned int flags);
414
425extern void FillEllipse(short x, short y, short rx, short ry, unsigned int flags);
426
436extern void InverseSetArea(short x0, short y0, short x1, short y1);
437
444extern void ClearScreen(bool fill_with_fg);
445
456extern void ScrollDown(short x0, short y0, short x1, short y1, short amount);
457
468extern void ScrollLeft(short x0, short y0, short x1, short y1, short amount);
469
480extern void ScrollRight(short x0, short y0, short x1, short y1, short amount);
481
492extern void ScrollUp(short x0, short y0, short x1, short y1, short amount);
493
505extern lcd_t *CreateVirtualLCD(short width, short height, short width_bytes);
506
513extern void DeleteVirtualLCD(lcd_t *lcd);
514
521extern lcd_t *SetActiveLCD(lcd_t *new_lcd);
522
529extern lcd_t *GetActiveLCD(void);
530
544
558extern lcd_surface_t *SetDCObject(lcd_t *lcd, lcd_surface_t *new_surface);
559
569extern short GetMaxScrX(void);
570
580extern short GetMaxScrY(void);
581
582#ifdef __cplusplus
583} // extern "C"
584#endif
585
586#endif // __MUTEKI_UI_CANVAS_H__
void PutImage(short x, short y, lcd_surface_t *surface, unsigned short flags)
Copy pixels from a surface to current active LCD.
void GetCursorPosition(short *x, short *y)
Get the cursor position on the current canvas.
void DrawRect(short x0, short y0, short x1, short y1, unsigned int flags)
Stroke a rectangle on the current active LCD.
void SetFontType(short font_type)
Set the current font type to font_type.
void Printf(const char *format,...) SYS_IS_PRINTF(1
Format and draw a string.
short GetPenSize(void)
Get the stroke width.
void DrawCircle(short x, short y, short r, unsigned int flags)
Stroke a circle on the current active LCD.
void SetDrawArea(short x0, short y0, short x1, short y1)
Set the drawing area of the current active LCD.
short GetPenStyle(unsigned int *dash_pattern)
Get the stroke dash pattern.
int rgbSetColor(int color)
Set display canvas foreground fill color.
void WriteString(short x, short y, const void *s, unsigned int flags)
Draw a string s aligned to the top left corner at (x, y) px.
void DrawRoundRect(short x0, short y0, short x1, short y1, short rx, short ry, unsigned int flags)
Stroke a rounded corner rectangle on the current active LCD.
void ScrollUp(short x0, short y0, short x1, short y1, short amount)
Move a rectangle up by amount pixels.
void InverseSetArea(short x0, short y0, short x1, short y1)
Invert color within a rectangle.
short GetMaxScrY(void)
Get Y coordinate of the bottom-most visible pixels on the current canvas.
void ScrollDown(short x0, short y0, short x1, short y1, short amount)
Move a rectangle down by amount pixels.
int SetPixel(short x, short y, int color)
Set the pixel color on the current active surface with the given pixel.
void FillCircle(short x, short y, short r, unsigned int flags)
Fill a circle on the current active LCD.
void FillRect(short x0, short y0, short x1, short y1, unsigned int flags)
Fill a rectangle on the current active LCD.
void void PrintfXY(short x, short y, const char *format,...) SYS_IS_PRINTF(3
Format and draw a string aligned to the top left corner at (x, y) px.
unsigned int GetCursorSize(void)
Get the size of the cursor on the current canvas.
lcd_surface_t * SetDCObject(lcd_t *lcd, lcd_surface_t *new_surface)
Link a surface (device context) to an LCD descriptor.
size_t GetImage(short x0, short y0, short x1, short y1, lcd_surface_t *surface)
Copy a rectangle of pixels from current active LCD and save it to the specified buffer.
lcd_t * SetActiveLCD(lcd_t *new_lcd)
Set an LCD descriptor as active.
void WriteAlignString(short x, short y, const void *s, short max_length, int align, unsigned int flags)
Draw a string s with specified alignment at (x, y) px.
int rgbSetBkColor(int color)
Set display canvas background fill color.
void FillEllipse(short x, short y, short rx, short ry, unsigned int flags)
Fill an ellipse on the current active LCD.
void WriteChar(short x, short y, UTF16 c, unsigned int flags)
Draw a UTF-16 character c aligned to the top left corner at (x, y) px.
short SetCursorType(short new_type)
Set the type of the cursor on the current canvas.
void CursorUnlock(void)
Unlock the cursor on the current canvas.
short SetPenSize(short size)
Set the stroke width.
lcd_t * CreateVirtualLCD(short width, short height, short width_bytes)
Create a virtual LCD descriptor.
void CursorLock(void)
Lock the cursor on the current canvas.
short GetFontType(void)
Get the current font type.
void ClearScreen(bool fill_with_fg)
Fill the current display canvas with background color, effectively clearing it.
void SetCursorPosition(short x, short y)
Move the cursor position on the current canvas to the specified coordinate.
short GetMaxScrX(void)
Get X coordinate of the rightmost visible pixels on the current canvas.
int SetTransparentColor(int color)
Set display canvas transparent color.
void void int ShowGraphic(short x, short y, lcd_surface_t *surface, unsigned short flags)
Draw a surface onto current active LCD.
void ScrollLeft(short x0, short y0, short x1, short y1, short amount)
Move a rectangle left by amount pixels.
void DeleteVirtualLCD(lcd_t *lcd)
Dispose a previously created virtual LCD descriptor.
lcd_t * GetActiveLCD(void)
Get the current active LCD descriptor.
void DrawLine(short x0, short y0, short x1, short y1, unsigned int flags)
Stroke a line on the current active LCD.
short GetCursorType(void)
Get the type of the cursor on the current canvas.
void GetDrawArea(short *x0, short *y0, short *x1, short *y1)
Get the drawing area of the current active LCD.
lcd_t * CreateCompatibleLCD(lcd_t *source)
Copy an LCD descriptor (excluding surface).
unsigned int SetCursorSize(unsigned int new_size)
Set the size of the cursor on the current canvas.
int GetPixel(short x, short y)
Get the RGB value of a pixel on the current active surface.
void DrawEllipse(short x, short y, short rx, short ry, unsigned int flags)
Stroke an ellipse on the current active LCD.
void ScrollRight(short x0, short y0, short x1, short y1, short amount)
Move a rectangle right by amount pixels.
short SetPenStyle(short dash, unsigned int *dash_pattern)
Set the stroke dash pattern.
#define UTF16
"Portable" Besta UTF-16 type used by other headers.
Definition common.h:54
#define SYS_IS_PRINTF(arg_index_str, arg_index_fmt)
Attribute for opting a function in for printf static checking.
Definition common.h:92
The LCD descriptor.
Definition common.h:901
Descriptor of an LCD drawing surface or hardware framebuffer.
Definition common.h:728
Common data structures and definitions for the UI subsystem.