@@ -23,11 +23,15 @@ void BaseEyebrow::update(M5Canvas *canvas, BoundingRect rect,
2323 ctx->getColorDepth () == 1 ? ERACER_COLOR : cp->get (COLOR_BACKGROUND );
2424 center_x_ = rect.getCenterX ();
2525 center_y_ = rect.getCenterY ();
26+ expression_ = ctx->getExpression ();
2627}
2728
2829void EllipseEyebrow::draw (M5Canvas *canvas, BoundingRect rect,
2930 DrawContext *ctx) {
3031 this ->update (canvas, rect, ctx);
32+ if (width_ == 0 || height_ == 0 ) {
33+ return ; // draw nothing
34+ }
3135
3236 canvas->fillEllipse (center_x_, center_y_, this ->width_ / 2 ,
3337 this ->height_ / 2 , primary_color_);
@@ -43,4 +47,22 @@ void BowEyebrow::draw(M5Canvas *canvas, BoundingRect rect, DrawContext *ctx) {
4347 angle0, angle0 + stroke_angle, primary_color_);
4448}
4549
50+ void RectEyebrow::draw (M5Canvas *canvas, BoundingRect rect, DrawContext *ctx) {
51+ this ->update (canvas, rect, ctx);
52+
53+ if (width_ == 0 || height_ == 0 ) {
54+ return ;
55+ }
56+ float angle = 0 .0f ;
57+ if (expression_ == Expression::Angry) {
58+ angle = is_left_ ? -M_PI / 6 .0f : M_PI / 6 .0f ;
59+ }
60+ if (expression_ == Expression::Sad) {
61+ angle = is_left_ ? M_PI / 6 .0f : -M_PI / 6 .0f ;
62+ }
63+
64+ fillRotatedRect (canvas, center_x_, center_y_, width_, height_, angle,
65+ primary_color_);
66+ }
67+
4668} // namespace m5avatar
0 commit comments