Skip to content

Commit e4e07b1

Browse files
committed
Fixed a bug that caused strange colors when 8bitColor was specified.
1 parent 79de1d3 commit e4e07b1

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/Effect.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ namespace m5avatar {
1414
class Effect final : public Drawable {
1515
private:
1616
void drawBubbleMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
17-
uint32_t color) {
17+
uint16_t color) {
1818
drawBubbleMark(spi, x, y, r, color, 0);
1919
}
2020

2121
void drawBubbleMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
22-
uint32_t color, float offset) {
22+
uint16_t color, float offset) {
2323
r = r + floor(r * 0.2 * offset);
2424
spi->drawCircle(x, y, r, color);
2525
spi->drawCircle(x - (r / 4), y - (r / 4), r / 4, color);
2626
}
2727

2828
void drawSweatMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
29-
uint32_t color) {
29+
uint16_t color) {
3030
drawSweatMark(spi, x, y, r, color, 0);
3131
}
3232

3333
void drawSweatMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
34-
uint32_t color, float offset) {
34+
uint16_t color, float offset) {
3535
y = y + floor(5 * offset);
3636
r = r + floor(r * 0.2 * offset);
3737
spi->fillCircle(x, y, r, color);
@@ -41,25 +41,25 @@ class Effect final : public Drawable {
4141
}
4242

4343
void drawChillMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
44-
uint32_t color) {
44+
uint16_t color) {
4545
drawChillMark(spi, x, y, r, color, 0);
4646
}
4747

4848
void drawChillMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
49-
uint32_t color, float offset) {
49+
uint16_t color, float offset) {
5050
uint32_t h = r + abs(r * 0.2 * offset);
5151
spi->fillRect(x - (r / 2), y, 3, h / 2, color);
5252
spi->fillRect(x, y, 3, h * 3 / 4, color);
5353
spi->fillRect(x + (r / 2), y, 3, h, color);
5454
}
5555

5656
void drawAngerMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
57-
uint32_t color, uint32_t bColor) {
57+
uint16_t color, uint32_t bColor) {
5858
drawAngerMark(spi, x, y, r, color, bColor, 0);
5959
}
6060

6161
void drawAngerMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
62-
uint32_t color, uint32_t bColor, float offset) {
62+
uint16_t color, uint32_t bColor, float offset) {
6363
r = r + abs(r * 0.4 * offset);
6464
spi->fillRect(x - (r / 3), y - r, (r * 2) / 3, r * 2, color);
6565
spi->fillRect(x - r, y - (r / 3), r * 2, (r * 2) / 3, color);
@@ -68,12 +68,12 @@ class Effect final : public Drawable {
6868
}
6969

7070
void drawHeartMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
71-
uint32_t color) {
71+
uint16_t color) {
7272
drawHeartMark(spi, x, y, r, color, 0);
7373
}
7474

7575
void drawHeartMark(M5Canvas *spi, uint32_t x, uint32_t y, uint32_t r,
76-
uint32_t color, float offset) {
76+
uint16_t color, float offset) {
7777
r = r + floor(r * 0.4 * offset);
7878
spi->fillCircle(x - r / 2, y, r / 2, color);
7979
spi->fillCircle(x + r / 2, y, r / 2, color);
@@ -90,8 +90,8 @@ class Effect final : public Drawable {
9090
Effect(const Effect &other) = default;
9191
Effect &operator=(const Effect &other) = default;
9292
void draw(M5Canvas *spi, BoundingRect rect, DrawContext *ctx) override {
93-
uint32_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
94-
uint32_t bgColor = ctx->getColorDepth() == 1 ? ERACER_COLOR : ctx->getColorPalette()->get(COLOR_BACKGROUND);
93+
uint16_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
94+
uint16_t bgColor = ctx->getColorDepth() == 1 ? ERACER_COLOR : ctx->getColorPalette()->get(COLOR_BACKGROUND);
9595
float offset = ctx->getBreath();
9696
Expression exp = ctx->getExpression();
9797
switch (exp) {

src/Eye.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void Eye::draw(M5Canvas *spi, BoundingRect rect, DrawContext *ctx) {
1818
float openRatio = ctx->getEyeOpenRatio();
1919
uint32_t offsetX = g.getHorizontal() * 3;
2020
uint32_t offsetY = g.getVertical() * 3;
21-
uint32_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
22-
uint32_t backgroundColor = ctx->getColorDepth() == 1 ? 0 : ctx->getColorPalette()->get(COLOR_BACKGROUND);
21+
uint16_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
22+
uint16_t backgroundColor = ctx->getColorDepth() == 1 ? 0 : ctx->getColorPalette()->get(COLOR_BACKGROUND);
2323

2424
if (openRatio > 0) {
2525
spi->fillCircle(x + offsetX, y + offsetY, r, primaryColor);

src/Eyeblow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void Eyeblow::draw(M5Canvas *spi, BoundingRect rect, DrawContext *ctx) {
1212
Expression exp = ctx->getExpression();
1313
uint32_t x = rect.getLeft();
1414
uint32_t y = rect.getTop();
15-
uint32_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
15+
uint16_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
1616
if (width == 0 || height == 0) {
1717
return;
1818
}

src/Mouth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Mouth::Mouth(uint16_t minWidth, uint16_t maxWidth, uint16_t minHeight,
1414
maxHeight{maxHeight} {}
1515

1616
void Mouth::draw(M5Canvas *spi, BoundingRect rect, DrawContext *ctx) {
17-
uint32_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
17+
uint16_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
1818
float breath = _min(1.0f, ctx->getBreath());
1919
float openRatio = ctx->getMouthOpenRatio();
2020
int h = minHeight + (maxHeight - minHeight) * openRatio;

0 commit comments

Comments
 (0)