ui.c 891 B

123456789101112131415161718192021222324252627282930
  1. /* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
  2. * See the LICENSE file for information about the license. */
  3. #include "app.h"
  4. void canvas_draw_str_with_border(Canvas* canvas, uint8_t x, uint8_t y, const char* str, Color text_color, Color border_color)
  5. {
  6. struct {
  7. uint8_t x; uint8_t y;
  8. } dir[8] = {
  9. {-1,-1},
  10. {0,-1},
  11. {1,-1},
  12. {1,0},
  13. {1,1},
  14. {0,1},
  15. {-1,1},
  16. {-1,0}
  17. };
  18. /* Rotate in all the directions writing the same string to create a
  19. * border, then write the actual string in the other color in the
  20. * middle. */
  21. canvas_set_color(canvas, border_color);
  22. for (int j = 0; j < 8; j++)
  23. canvas_draw_str(canvas,x+dir[j].x,y+dir[j].y,str);
  24. canvas_set_color(canvas, text_color);
  25. canvas_draw_str(canvas,x,y,str);
  26. canvas_set_color(canvas, ColorBlack);
  27. }