Round the location of single-pixel lines to the nearest pixel.

Should hopefully help #14204.
This commit is contained in:
Henrik Rydgård committed 2021-09-08 00:19:01 +02:00
1 parent f239d79f66
commit 68f7c9e9ff
2 files changed
+4 -5

No files matched your search

+4 -4
View File
@@ -123,17 +123,17 @@ void DrawBuffer::Rect(float x, float y, float w, float h, uint32_t color, int al
}
void DrawBuffer::hLine(float x1, float y, float x2, uint32_t color) {
// Round Y to the closest full pixel, since we're making it 1-pixel-thin.
y -= fmodf(y, pixel_in_dps_y);
Rect(x1, y, x2 - x1, pixel_in_dps_y, color);
}
void DrawBuffer::vLine(float x, float y1, float y2, uint32_t color) {
// Round X to the closest full pixel, since we're making it 1-pixel-thin.
x -= fmodf(x, pixel_in_dps_x);
Rect(x, y1, pixel_in_dps_x, y2 - y1, color);
}
void DrawBuffer::vLineAlpha50(float x, float y1, float y2, uint32_t color) {
Rect(x, y1, pixel_in_dps_x, y2 - y1, (color | 0xFF000000) & 0x7F000000);
}
void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32_t colorTop, uint32_t colorBottom) {
V(x, y, 0, colorTop, 0, 0);
V(x + w, y, 0, colorTop, 1, 0);
-1
View File
@@ -73,7 +73,6 @@ public:
void Rect(float x, float y, float w, float h, uint32_t color, int align = ALIGN_TOPLEFT);
void hLine(float x1, float y, float x2, uint32_t color);
void vLine(float x, float y1, float y2, uint32_t color);
void vLineAlpha50(float x, float y1, float y2, uint32_t color);
void Line(ImageID atlas_image, float x1, float y1, float x2, float y2, float thickness, uint32_t color);