From cbcf317e760c3370d10cfc525f0f528abd44e820 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sat, 18 Apr 2020 13:21:32 +0200 Subject: [PATCH] LibGfx: Fix draw_triangle() clipping calculations --- Libraries/LibGfx/Painter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp index 140d3fce23..b1d80ea7db 100644 --- a/Libraries/LibGfx/Painter.cpp +++ b/Libraries/LibGfx/Painter.cpp @@ -360,8 +360,8 @@ void Painter::draw_triangle(const Point& a, const Point& b, const Point& c, Colo int top = p0.y(); if (top < clip.top()) { - x01 += dx01 * clip.top() - top; - x02 += dx02 * clip.top() - top; + x01 += dx01 * (clip.top() - top); + x02 += dx02 * (clip.top() - top); top = clip.top(); } @@ -381,8 +381,8 @@ void Painter::draw_triangle(const Point& a, const Point& b, const Point& c, Colo top = p1.y(); if (top < clip.top()) { - x02 += dx02 * clip.top() - top; - x12 += dx12 * clip.top() - top; + x02 += dx02 * (clip.top() - top); + x12 += dx12 * (clip.top() - top); top = clip.top(); }