From 45e2296c690bad30b8857e3fe1272298b3f08fd2 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Sun, 24 Dec 2023 16:37:07 +0100 Subject: [PATCH] Painter: Last minute fixes... --- examples/PainterExamples/OnPath.cpp | 3 ++- uppsrc/Painter/Mask.cpp | 3 ++- uppsrc/Painter/Painter.cpp | 11 +++++------ uppsrc/Painter/Render.cpp | 4 ++++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/PainterExamples/OnPath.cpp b/examples/PainterExamples/OnPath.cpp index 83677a478..3cef371c1 100644 --- a/examples/PainterExamples/OnPath.cpp +++ b/examples/PainterExamples/OnPath.cpp @@ -44,7 +44,8 @@ void TextOnPath(Painter& sw) sw.BeginOnPath(pos + w / 2, true); sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt) .Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue()) - .Stroke(1, Black()); + .Stroke(1, Black()) + ; sw.End(); pos += w; } diff --git a/uppsrc/Painter/Mask.cpp b/uppsrc/Painter/Mask.cpp index 51575d6ee..2270822c6 100644 --- a/uppsrc/Painter/Mask.cpp +++ b/uppsrc/Painter/Mask.cpp @@ -4,11 +4,12 @@ namespace Upp { void BufferPainter::BeginMaskOp() { + Finish(); attr.mask = true; Size sz = ip->GetSize(); mask.Add() = *ip; ip->Create(sz); - Clear(RGBAZero()); + UPP::Fill(~*ip, RGBAZero(), ip->GetLength()); Begin(); } diff --git a/uppsrc/Painter/Painter.cpp b/uppsrc/Painter/Painter.cpp index 9d7426984..90a151ae4 100644 --- a/uppsrc/Painter/Painter.cpp +++ b/uppsrc/Painter/Painter.cpp @@ -47,14 +47,13 @@ void PaintCharacter(Painter& sw, const Pointf& p, int chr, Font font) sw.EvenOdd(true); } -Xform2D GetLineSzXform(const Pointf& p1, const Pointf& p2, Pointf p3, const Sizef& sz) -{ - return Xform2D::Map(Pointf(0, 0), Pointf(sz.cx, 0), Pointf(sz.cx, sz.cy), p1, p2, p3); -} - Xform2D GetLineSzXform(const Pointf& p1, const Pointf& p2, const Sizef& sz) { - return GetLineSzXform(p1, p2, Pointf(p2.x, p2.y + Distance(p1, p2) / sz.cx * sz.cy), sz); + Xform2D m = Xform2D::Scale(Distance(p1, p2) / sz.cx); + if(p1.y != p2.y) + m = m * Xform2D::Rotation(Bearing(p2 - p1)); + m = m * Xform2D::Translation(p1.x, p1.y); + return m; } Painter& Painter::Fill(const Image& image, Pointf p1, Pointf p2, dword flags) diff --git a/uppsrc/Painter/Render.cpp b/uppsrc/Painter/Render.cpp index 666927467..c424c25a6 100644 --- a/uppsrc/Painter/Render.cpp +++ b/uppsrc/Painter/Render.cpp @@ -284,6 +284,10 @@ Buffer BufferPainter::RenderPath(double width, One& ss int y = (co ? co->Next() : ii++) + rasterizer.MinY(); if(y > rasterizer.MaxY()) break; + if(!doclip && co_clear && co_clear[y]) { + UPP::Fill((*ip)[y], co_clear_color, ip->GetWidth()); + co_clear[y] = false; + } solid_filler.t = subpixel_filler.t = span_filler.t = (*ip)[y]; subpixel_filler.end = subpixel_filler.t + ip->GetWidth(); span_filler.y = subpixel_filler.y = y;