canvas.h 1.7 KB

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