canvas.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <stdint.h>
  3. #include <u8g2.h>
  4. #include <gui/icon.h>
  5. #include <assets_icons_i.h>
  6. typedef enum {
  7. ColorWhite = 0x00,
  8. ColorBlack = 0x01,
  9. } Color;
  10. typedef enum { FontPrimary = 0x00, FontSecondary = 0x01, FontGlyph = 0x02 } Font;
  11. typedef struct Canvas Canvas;
  12. /*
  13. * Canvas width
  14. * @return width in pixels.
  15. */
  16. uint8_t canvas_width(Canvas* canvas);
  17. /*
  18. * Canvas height
  19. * @return height in pixels.
  20. */
  21. uint8_t canvas_height(Canvas* canvas);
  22. /*
  23. * Clear canvas, clear rendering buffer
  24. */
  25. void canvas_clear(Canvas* canvas);
  26. /*
  27. * Set drawing color
  28. */
  29. void canvas_set_color(Canvas* canvas, Color color);
  30. /*
  31. * Set drawing font
  32. */
  33. void canvas_set_font(Canvas* canvas, Font font);
  34. /*
  35. * Draw string at position of baseline defined by x, y.
  36. */
  37. void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str);
  38. /*
  39. * Draw stateful icon at position defined by x,y.
  40. */
  41. void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, Icon* icon);
  42. /*
  43. * Draw stateless icon at position defined by x,y.
  44. */
  45. void canvas_draw_icon_name(Canvas* canvas, uint8_t x, uint8_t y, IconName name);
  46. /*
  47. * Draw xbm icon of width, height at position defined by x,y.
  48. */
  49. void canvas_draw_xbm(
  50. Canvas* canvas,
  51. uint8_t x,
  52. uint8_t y,
  53. uint8_t w,
  54. uint8_t h,
  55. const uint8_t* bitmap);
  56. /*
  57. * Draw dot at x,y
  58. */
  59. void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y);
  60. /*
  61. * Draw box of width, height at x,y
  62. */
  63. void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
  64. /*
  65. * Draw frame of width, height at x,y
  66. */
  67. void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
  68. /*
  69. * Draw line from x1,y1 to x2,y2
  70. */
  71. void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
  72. /*
  73. * Draw glyph
  74. */
  75. void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);