Cosmetics

This commit is contained in:
3djc
2020-10-15 16:00:15 +02:00
parent dc747da1fa
commit 9d28df4aec
+40 -39
View File
@@ -264,7 +264,7 @@ void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius, LcdFla
} }
class Slope { class Slope {
public: public:
explicit Slope(int angle) { explicit Slope(int angle) {
if (angle < 0) if (angle < 0)
angle += 360; angle += 360;
@@ -339,11 +339,49 @@ public:
return *this; return *this;
} }
protected: protected:
bool left; bool left;
int value; int value;
}; };
void BitmapBuffer::drawBitmapPatternPie(coord_t x, coord_t y, const uint8_t * img, LcdFlags flags, int startAngle, int endAngle)
{
if (endAngle == startAngle) {
endAngle += 1;
}
Slope startSlope(startAngle);
Slope endSlope(endAngle);
pixel_t color = lcdColorTable[COLOR_IDX(flags)];
APPLY_OFFSET();
coord_t width = *((uint16_t *)img);
coord_t height = *(((uint16_t *)img) + 1);
const uint8_t * q = img + 4;
int w2 = width / 2;
int h2 = height / 2;
for (int y1 = h2 - 1; y1 >= 0; y1--) {
for (int x1 = w2 - 1; x1 >= 0; x1--) {
Slope slope(false, x1 == 0 ? 99000 : y1 * 100 / x1);
if (slope.isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 + x1, y + h2 - y1, q[(h2 - y1) * width + w2 + x1], color);
}
if (slope.invertVertical().isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 + x1, y + h2 + y1, q[(h2 + y1) * width + w2 + x1], color);
}
if (slope.invertHorizontal().isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 - x1, y + h2 + y1, q[(h2 + y1) * width + w2 - x1], color);
}
if (slope.invertVertical().isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 - x1, y + h2 - y1, q[(h2 - y1) * width + w2 - x1], color);
}
}
}
}
void BitmapBuffer::drawAnnulusSector(coord_t x, coord_t y, coord_t internalRadius, coord_t externalRadius, int startAngle, int endAngle, LcdFlags flags) void BitmapBuffer::drawAnnulusSector(coord_t x, coord_t y, coord_t internalRadius, coord_t externalRadius, int startAngle, int endAngle, LcdFlags flags)
{ {
if (endAngle == startAngle) { if (endAngle == startAngle) {
@@ -667,43 +705,6 @@ void drawSolidRect(BitmapBuffer * dc, coord_t x, coord_t y, coord_t w, coord_t h
// } // }
//} //}
// //
void BitmapBuffer::drawBitmapPatternPie(coord_t x, coord_t y, const uint8_t * img, LcdFlags flags, int startAngle, int endAngle)
{
if (endAngle == startAngle) {
endAngle += 1;
}
Slope startSlope(startAngle);
Slope endSlope(endAngle);
pixel_t color = lcdColorTable[COLOR_IDX(flags)];
APPLY_OFFSET();
coord_t width = *((uint16_t *)img);
coord_t height = *(((uint16_t *)img) + 1);
const uint8_t * q = img + 4;
int w2 = width / 2;
int h2 = height / 2;
for (int y1 = h2 - 1; y1 >= 0; y1--) {
for (int x1 = w2 - 1; x1 >= 0; x1--) {
Slope slope(false, x1 == 0 ? 99000 : y1 * 100 / x1);
if (slope.isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 + x1, y + h2 - y1, q[(h2 - y1) * width + w2 + x1], color);
}
if (slope.invertVertical().isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 + x1, y + h2 + y1, q[(h2 + y1) * width + w2 + x1], color);
}
if (slope.invertHorizontal().isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 - x1, y + h2 + y1, q[(h2 + y1) * width + w2 - x1], color);
}
if (slope.invertVertical().isBetween(startSlope, endSlope)) {
drawAlphaPixel(x + w2 - x1, y + h2 - y1, q[(h2 - y1) * width + w2 - x1], color);
}
}
}
}
BitmapBuffer * BitmapBuffer::loadBitmap(const char * filename) BitmapBuffer * BitmapBuffer::loadBitmap(const char * filename)
{ {