kopia lustrzana https://github.com/pimoroni/pimoroni-pico
PicoGraphics: (Try to) handle non-div-2 thickness.
rodzic
83f88c034d
commit
a8a8321405
|
@ -288,21 +288,22 @@ namespace pimoroni {
|
|||
}
|
||||
|
||||
void PicoGraphics::thick_line(Point p1, Point p2, uint thickness) {
|
||||
int32_t ht = thickness / 2;
|
||||
int32_t t = (int32_t)thickness;
|
||||
|
||||
// fast horizontal line
|
||||
if(p1.y == p2.y) {
|
||||
int32_t ht = thickness / 2;
|
||||
int32_t start = std::min(p1.x, p2.x);
|
||||
int32_t end = std::max(p1.x, p2.x);
|
||||
rectangle(Rect(start, p1.y - ht, end - start, thickness));
|
||||
rectangle(Rect(start, p1.y - ht, end - start, t));
|
||||
return;
|
||||
}
|
||||
|
||||
// fast vertical line
|
||||
if(p1.x == p2.x) {
|
||||
int32_t ht = thickness / 2;
|
||||
int32_t start = std::min(p1.y, p2.y);
|
||||
int32_t length = std::max(p1.y, p2.y) - start;
|
||||
rectangle(Rect(p1.x - ht, start, thickness, length));
|
||||
rectangle(Rect(p1.x - ht, start, t, length));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -320,8 +321,7 @@ namespace pimoroni {
|
|||
int32_t x = p1.x;
|
||||
int32_t y = p1.y << 16;
|
||||
while(s--) {
|
||||
int32_t ht = thickness / 2;
|
||||
rectangle({x - ht, (y >> 16) - ht, ht * 2, ht * 2});
|
||||
rectangle({x - ht, (y >> 16) - ht, t, t});
|
||||
y += sy;
|
||||
x += sx;
|
||||
}
|
||||
|
@ -333,8 +333,7 @@ namespace pimoroni {
|
|||
int32_t y = p1.y;
|
||||
int32_t x = p1.x << 16;
|
||||
while(s--) {
|
||||
int32_t ht = thickness / 2;
|
||||
rectangle({(x >> 16) - ht, y - ht, ht * 2, ht * 2});
|
||||
rectangle({(x >> 16) - ht, y - ht, t, t});
|
||||
y += sy;
|
||||
x += sx;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue