@@ -10,7 +10,7 @@ BaseMouth::BaseMouth(uint16_t min_width, uint16_t max_width,
1010 min_height_{min_height},
1111 max_height_{max_height} {}
1212
13- void BaseMouth::update (M5Canvas *spi , BoundingRect rect, DrawContext *ctx) {
13+ void BaseMouth::update (M5Canvas *canvas , BoundingRect rect, DrawContext *ctx) {
1414 primary_color_ = ctx->getColorDepth () == 1
1515 ? 1
1616 : ctx->getColorPalette ()->get (COLOR_PRIMARY );
@@ -25,57 +25,82 @@ void BaseMouth::update(M5Canvas *spi, BoundingRect rect, DrawContext *ctx) {
2525 open_ratio_ = ctx->getMouthOpenRatio ();
2626}
2727
28- void OmegaMouth::draw (M5Canvas *spi , BoundingRect rect, DrawContext *ctx) {
29- this ->update (spi , rect, ctx); // update drawing cache
28+ void OmegaMouth::draw (M5Canvas *canvas , BoundingRect rect, DrawContext *ctx) {
29+ this ->update (canvas , rect, ctx); // update drawing cache
3030 uint32_t h = min_height_ + (max_height_ - min_height_) * open_ratio_;
3131 uint32_t w = min_width_ + (max_width_ - min_width_) * (1 - open_ratio_);
3232
3333 // inner mouse
34- spi ->fillEllipse (center_x_, center_y_ - max_height_ / 2 , max_width_ / 4 ,
35- static_cast <int32_t >(max_height_ * open_ratio_),
36- primary_color_);
34+ canvas ->fillEllipse (center_x_, center_y_ - max_height_ / 2 , max_width_ / 4 ,
35+ static_cast <int32_t >(max_height_ * open_ratio_),
36+ primary_color_);
3737
3838 // omega
39- spi ->fillEllipse (center_x_ - 16 , center_y_ - max_height_ / 2 , 20 , 15 ,
40- primary_color_); // outer
41- spi ->fillEllipse (center_x_ + 16 , center_y_ - max_height_ / 2 , 20 , 15 ,
42- primary_color_);
43- spi ->fillEllipse (center_x_ - 16 , center_y_ - max_height_ / 2 , 18 , 13 ,
44- background_color_); // inner
45- spi ->fillEllipse (center_x_ + 16 , center_y_ - max_height_ / 2 , 18 , 13 ,
46- background_color_);
39+ canvas ->fillEllipse (center_x_ - 16 , center_y_ - max_height_ / 2 , 20 , 15 ,
40+ primary_color_); // outer
41+ canvas ->fillEllipse (center_x_ + 16 , center_y_ - max_height_ / 2 , 20 , 15 ,
42+ primary_color_);
43+ canvas ->fillEllipse (center_x_ - 16 , center_y_ - max_height_ / 2 , 18 , 13 ,
44+ background_color_); // inner
45+ canvas ->fillEllipse (center_x_ + 16 , center_y_ - max_height_ / 2 , 18 , 13 ,
46+ background_color_);
4747 // mask for omega
48- spi ->fillRect (center_x_ - max_width_ / 2 , center_y_ - max_height_ * 1.5 ,
49- max_width_, max_height_, background_color_);
48+ canvas ->fillRect (center_x_ - max_width_ / 2 , center_y_ - max_height_ * 1.5 ,
49+ max_width_, max_height_, background_color_);
5050
5151 // cheek
52- spi->fillEllipse (center_x_ - 132 , center_y_ - 23 , 24 , 10 , secondary_color_);
53- spi->fillEllipse (center_x_ + 132 , center_y_ - 23 , 24 , 10 , secondary_color_);
52+ canvas->fillEllipse (center_x_ - 132 , center_y_ - 23 , 24 , 10 ,
53+ secondary_color_);
54+ canvas->fillEllipse (center_x_ + 132 , center_y_ - 23 , 24 , 10 ,
55+ secondary_color_);
5456}
5557
56- void UShapeMouth::draw (M5Canvas *spi , BoundingRect rect, DrawContext *ctx) {
57- this ->update (spi , rect, ctx); // update drawing cache
58+ void UShapeMouth::draw (M5Canvas *canvas , BoundingRect rect, DrawContext *ctx) {
59+ this ->update (canvas , rect, ctx); // update drawing cache
5860 uint32_t h = min_height_ + (max_height_ - min_height_) * open_ratio_;
5961 uint32_t w = min_width_ + (max_width_ - min_width_) * (1 - open_ratio_);
6062
6163 auto ellipse_center_y = center_y_ - max_height_ / 2 ;
6264 uint16_t thickness = 6 ;
6365
6466 // back
65- spi ->fillEllipse (center_x_, ellipse_center_y, max_width_ / 2 , max_height_ ,
66- primary_color_);
67+ canvas ->fillEllipse (center_x_, ellipse_center_y, max_width_ / 2 ,
68+ max_height_, primary_color_);
6769 // rect mask
68- spi ->fillRect (center_x_ - max_width_ / 2 , ellipse_center_y - max_height_,
69- max_width_ + 1 , max_height_, background_color_);
70+ canvas ->fillRect (center_x_ - max_width_ / 2 , ellipse_center_y - max_height_,
71+ max_width_ + 1 , max_height_, background_color_);
7072
7173 // inner mouse
72- spi ->fillEllipse (center_x_, ellipse_center_y, max_width_ / 2 - thickness,
73- (max_height_ - thickness) * (1 .0f - open_ratio_),
74- background_color_);
74+ canvas ->fillEllipse (center_x_, ellipse_center_y, max_width_ / 2 - thickness,
75+ (max_height_ - thickness) * (1 .0f - open_ratio_),
76+ background_color_);
7577
7678 // cheek
77- spi->fillEllipse (center_x_ - 132 , center_y_ - 23 , 24 , 10 , secondary_color_);
78- spi->fillEllipse (center_x_ + 132 , center_y_ - 23 , 24 , 10 , secondary_color_);
79+ canvas->fillEllipse (center_x_ - 132 , center_y_ - 23 , 24 , 10 ,
80+ secondary_color_);
81+ canvas->fillEllipse (center_x_ + 132 , center_y_ - 23 , 24 , 10 ,
82+ secondary_color_);
83+ }
84+
85+ void DoggyMouth::draw (M5Canvas *canvas, BoundingRect rect, DrawContext *ctx) {
86+ this ->update (canvas, rect, ctx);
87+
88+ uint32_t h = min_height_ + (max_height_ - min_height_) * open_ratio_;
89+ uint32_t w = min_width_ + (max_width_ - min_width_) * (1 - open_ratio_);
90+ if (h > min_height_) {
91+ canvas->fillEllipse (center_x_, center_y_, w / 2 , h / 2 , primary_color_);
92+ canvas->fillEllipse (center_x_, center_y_, w / 2 - 4 , h / 2 - 4 ,
93+ TFT_RED );
94+ canvas->fillRect (center_x_ - w / 2 , center_y_ - h / 2 , w, h / 2 ,
95+ background_color_);
96+ }
97+ canvas->fillEllipse (center_x_, center_y_ - 15 , 10 , 6 , primary_color_);
98+ canvas->fillEllipse (center_x_ - 28 , center_y_, 30 , 15 , primary_color_);
99+ canvas->fillEllipse (center_x_ + 28 , center_y_, 30 , 15 , primary_color_);
100+ canvas->fillEllipse (center_x_ - 29 , center_y_ - 4 , 27 , 15 ,
101+ background_color_);
102+ canvas->fillEllipse (center_x_ + 29 , center_y_ - 4 , 27 , 15 ,
103+ background_color_);
79104}
80105
81106} // namespace m5avatar
0 commit comments