canvas.h 2.0 KB

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