stackchan-display
Loading...
Searching...
No Matches
Decorator.h
1#pragma once
2
3#include "Drawable.h"
4
5namespace stackchan::display
6{
7 void drawBubble(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
8 uint16_t color, float offset)
9 {
10 r = r + floor(r * 0.2 * offset);
11 canvas.drawCircle(x, y, r, color); // outer circle
12 canvas.drawCircle(x - (r / 4), y - (r / 4), r / 4, color); // inner circle
13 }
14
15 void drawBubble(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
16 uint16_t color)
17 {
18 drawBubble(canvas, x, y, r, color, 0);
19 }
20
21 void drawWaterDrop(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
22 uint16_t color, float offset)
23 {
24 y = y + floor(5 * offset);
25 r = r + floor(r * 0.2 * offset);
26 canvas.fillCircle(x, y, r, color);
27 uint32_t a = (sqrt(3) * r) / 2;
28 canvas.fillTriangle(x, y - r * 2, x - a, y - r * 0.5, x + a, y - r * 0.5,
29 color);
30 }
31
32 void drawWaterDrop(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
33 uint16_t color)
34 {
35 drawWaterDrop(canvas, x, y, r, color, 0);
36 }
37
38 void drawPaleMark(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
39 uint16_t color, float offset)
40 {
41 uint32_t h = r + abs(r * 0.2 * offset);
42 canvas.fillRect(x - (r / 2), y, 3, h / 2, color);
43 canvas.fillRect(x, y, 3, h * 3 / 4, color);
44 canvas.fillRect(x + (r / 2), y, 3, h, color);
45 }
46
47 void drawPaleMark(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
48 uint16_t color)
49 {
50 drawPaleMark(canvas, x, y, r, color, 0);
51 }
52
53 void drawAngerMark(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
54 uint16_t color, uint16_t background_color, float offset)
55 {
56 r = r + abs(r * 0.4 * offset);
57 canvas.fillRect(x - (r / 3), y - r, (r * 2) / 3, r * 2, color);
58 canvas.fillRect(x - r, y - (r / 3), r * 2, (r * 2) / 3, color);
59 canvas.fillRect(x - (r / 3) + 2, y - r, ((r * 2) / 3) - 4, r * 2, background_color);
60 canvas.fillRect(x - r, y - (r / 3) + 2, r * 2, ((r * 2) / 3) - 4, background_color);
61 }
62
63 void drawAngerMark(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
64 uint16_t color, uint16_t background_color)
65 {
66 drawAngerMark(canvas, x, y, r, color, background_color, 0);
67 }
68
69 void drawHeart(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
70 uint16_t color, float offset)
71 {
72 r = r + floor(r * 0.4 * offset);
73 canvas.fillCircle(x - r / 2, y, r / 2, color);
74 canvas.fillCircle(x + r / 2, y, r / 2, color);
75 float a = (sqrt(2) * r) / 4.0;
76 canvas.fillTriangle(x, y, x - r / 2 - a, y + a, x + r / 2 + a, y + a, color);
77 canvas.fillTriangle(x, y + (r / 2) + 2 * a, x - r / 2 - a, y + a,
78 x + r / 2 + a, y + a, color);
79 }
80
81 void drawHeart(M5Canvas &canvas, uint32_t x, uint32_t y, uint32_t r,
82 uint16_t color)
83 {
84 drawHeart(canvas, x, y, r, color, 0);
85 }
86
87}