21 #ifndef COSA_CANVAS_HH 22 #define COSA_CANVAS_HH 152 m_canvas_color(
WHITE),
166 return (m_canvas_color);
177 m_canvas_color =
color;
187 return (m_pen_color);
208 return (m_text_color);
219 m_text_color =
color;
239 Font* previous = m_font;
250 return (m_text_scale);
261 uint8_t previous = m_text_scale;
262 m_text_scale = (scale > 0 ? scale : 1);
347 Image(uint16_t width = 0, uint16_t height = 0) :
360 virtual bool read(
color16_t* buf,
size_t count) = 0;
363 static const size_t BUFFER_MAX = 32;
374 } __attribute__((packed));
395 virtual bool begin() = 0;
591 virtual void draw_pixel(uint16_t x, uint16_t y);
614 virtual void draw_bitmap(uint16_t x, uint16_t y,
const uint8_t* bp,
615 uint16_t width, uint16_t height,
627 uint16_t width, uint16_t height,
646 virtual void draw_icon(uint16_t x, uint16_t y,
const uint8_t* bp,
647 uint16_t width, uint16_t height,
659 virtual void draw_icon(uint16_t x, uint16_t y,
const uint8_t* bp,
670 uint16_t width = pgm_read_byte(bp++);
671 uint16_t height = pgm_read_byte(bp++);
674 draw_icon(x, y, bp, width, height, scale);
706 virtual void draw_line(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
771 virtual void draw_poly_P(
const int8_t* poly, uint8_t scale = 1);
782 virtual void draw_stroke_P(
const int8_t* stroke, uint8_t scale = 1);
792 virtual void draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
814 virtual void fill_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
838 uint16_t width, uint16_t height,
864 uint16_t width, uint16_t height,
887 virtual void draw_circle(uint16_t x, uint16_t y, uint16_t radius);
907 virtual void fill_circle(uint16_t x, uint16_t y, uint16_t radius);
927 virtual void draw_char(uint16_t x, uint16_t y,
char c);
965 virtual bool end() = 0;
995 } __attribute__((packed));
1021 #define CANVAS_BEGIN_SCRIPT(name) const uint8_t name[] __PROGMEM = { 1022 #define CANVAS_CALL_SCRIPT(ix) Canvas::CALL_SCRIPT, ix, 1023 #define CANVAS_SET_CANVAS_COLOR(r, g, b) Canvas::SET_CANVAS_COLOR, r, g, b, 1024 #define CANVAS_SET_PEN_COLOR(r, g, b) Canvas::SET_PEN_COLOR, r, g, b, 1025 #define CANVAS_SET_TEXT_COLOR(r, g, b) Canvas::SET_TEXT_COLOR, r, g, b, 1026 #define CANVAS_SET_TEXT_SCALE(s) Canvas::SET_TEXT_SCALE, s, 1027 #define CANVAS_SET_TEXT_PORT(x, y, w, h) Canvas::SET_TEXT_PORT, x, y, w, h, 1028 #define CANVAS_SET_TEXT_FONT(ix) Canvas::SET_TEXT_FONT, ix, 1029 #define CANVAS_SET_CURSOR(x, y) Canvas::SET_CURSOR, x, y, 1030 #define CANVAS_MOVE_CURSOR(dx, dy) Canvas::MOVE_CURSOR, (uint8_t) dx, (uint8_t) dy, 1031 #define CANVAS_DRAW_BITMAP(ix, w, h, s) Canvas::DRAW_BITMAP, ix, w, h, s, 1032 #define CANVAS_DRAW_ICON(ix, s) Canvas::DRAW_ICON, ix, s, 1033 #define CANVAS_DRAW_PIXEL() Canvas::DRAW_PIXEL, 1034 #define CANVAS_DRAW_LINE(x, y) Canvas::DRAW_LINE, x, y, 1035 #define CANVAS_DRAW_POLY(ix, s) Canvas::DRAW_POLY, ix, s, 1036 #define CANVAS_DRAW_STROKE(ix, s) Canvas::DRAW_STROKE, ix, s, 1037 #define CANVAS_DRAW_RECT(w, h) Canvas::DRAW_RECT, w, h, 1038 #define CANVAS_FILL_RECT(w, h) Canvas::FILL_RECT, w, h, 1039 #define CANVAS_DRAW_ROUNDRECT(w, h, r) Canvas::DRAW_ROUNDRECT, w, h, r, 1040 #define CANVAS_FILL_ROUNDRECT(w, h, r) Canvas::FILL_ROUNDRECT, w, h, r, 1041 #define CANVAS_DRAW_CIRCLE(r) Canvas::DRAW_CIRCLE, r, 1042 #define CANVAS_FILL_CIRCLE(r) Canvas::FILL_CIRCLE, r, 1043 #define CANVAS_DRAW_CHAR(c) Canvas::DRAW_CHAR, c, 1044 #define CANVAS_DRAW_STRING(ix) Canvas::DRAW_STRING, ix, 1045 #define CANVAS_FILL_SCREEN() Canvas::FILL_SCREEN, 1046 #define CANVAS_END_SCRIPT Canvas::END_SCRIPT }; color16_t set_text_color(color16_t color)
virtual uint8_t set_orientation(uint8_t direction)
color16_t get_pen_color() const
color16_t(uint16_t color)
void fill_circle(uint16_t radius)
Font * m_font
Current font.
color16_t m_canvas_color
Current background color.
void set_cursor(uint16_t x, uint16_t y)
virtual uint8_t get_orientation()
pos16_t m_cursor
Current cursor position.
virtual void draw_char(uint16_t x, uint16_t y, char c)
void fill_rect(uint16_t width, uint16_t height)
uint8_t set_text_scale(uint8_t scale)
color16_t set_text_color(color16_t color)
uint8_t get_text_scale() const
virtual void draw_circle(uint16_t x, uint16_t y, uint16_t radius)
void fill_roundrect(uint16_t width, uint16_t height, uint16_t radius)
virtual void draw_image(uint16_t x, uint16_t y, Image *image)
void draw_image(Image *image)
color16_t color(uint8_t red, uint8_t green, uint8_t blue)
void draw_rect(uint16_t width, uint16_t height)
color16_t set_pen_color(color16_t color)
IOStream & tab(IOStream &outs)
color16_t set_canvas_color(color16_t color)
Canvas(uint16_t width, uint16_t height, Context *context=&Canvas::context)
color16_t get_canvas_color() const
color16_t get_pen_color() const
virtual void draw_icon(uint16_t x, uint16_t y, const uint8_t *bp, uint16_t width, uint16_t height, uint8_t scale=1)
void run(uint8_t ix, const void_P *tab, uint8_t max)
Font * set_text_font(Font *font)
Image(uint16_t width=0, uint16_t height=0)
uint8_t get_text_scale() const
uint8_t set_text_scale(uint8_t scale)
Context(Font *font=(Font *)&system5x7)
Context * get_context() const
void move_cursor(int16_t dx, int16_t dy)
virtual void fill_circle(uint16_t x, uint16_t y, uint16_t radius)
virtual void fill_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
void draw_circle(uint16_t radius)
color16_t get_text_color() const
const class prog_str * str_P
void draw_vertical_line(uint16_t length)
Context * set_context(Context *context)
color16_t m_pen_color
Current foreground color.
color16_t m_text_color
Current text color.
void draw_roundrect(uint16_t width, uint16_t height, uint16_t radius)
void draw_icon(const uint8_t *bp, uint8_t scale=1)
void get_cursor(uint16_t &x, uint16_t &y) const
void draw_bitmap(const uint8_t *bp, uint16_t width, uint16_t height, uint8_t scale=1)
Font * get_text_font() const
virtual void fill_roundrect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius)
virtual void fill_screen()
uint8_t m_text_scale
Current text scale.
color16_t get_text_color() const
virtual void draw_string(char *s)
void draw_horizontal_line(uint16_t length)
Font * set_text_font(Font *font)
color16_t get_canvas_color() const
static color16_t shade(color16_t color, uint8_t scale)
void move_cursor(int16_t dx, int16_t dy)
color16_t set_pen_color(color16_t color)
virtual void draw_poly_P(const int8_t *poly, uint8_t scale=1)
virtual void draw_line(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
virtual void draw_vertical_line(uint16_t x, uint16_t y, uint16_t length)
virtual void draw_roundrect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius)
virtual void draw_bitmap(uint16_t x, uint16_t y, const uint8_t *bp, uint16_t width, uint16_t height, uint8_t scale=1)
void draw_line(uint16_t x1, uint16_t y1)
void get_cursor(uint16_t &x, uint16_t &y) const
color16_t set_canvas_color(color16_t color)
void set_cursor(uint16_t x, uint16_t y)
Element(Canvas *canvas, Font *font=(Font *)&system5x7)
virtual void draw_stroke_P(const int8_t *stroke, uint8_t scale=1)
virtual void draw_horizontal_line(uint16_t x, uint16_t y, uint16_t length)
color16_t(uint8_t r, uint8_t g, uint8_t b)
static color16_t blend(color16_t c1, color16_t c2)
Font * get_text_font() const
virtual void draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height)