From fc2aca59aad18e749bc0927309eb561608716ed6 Mon Sep 17 00:00:00 2001 From: Prokhorov Kirill Date: Sun, 25 May 2025 14:29:00 +0300 Subject: [PATCH] Fix luminosity drawing --- DesktopEditor/graphics/BooleanOperations.cpp | 24 ++++++++++++++++++-- DocxRenderer/src/logic/Page.cpp | 17 +++++++------- DocxRenderer/src/logic/Page.h | 2 +- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/DesktopEditor/graphics/BooleanOperations.cpp b/DesktopEditor/graphics/BooleanOperations.cpp index 05d7a991d3..cb187c8ec8 100644 --- a/DesktopEditor/graphics/BooleanOperations.cpp +++ b/DesktopEditor/graphics/BooleanOperations.cpp @@ -1020,18 +1020,35 @@ void CBooleanOperations::TracePaths() { size_t length = Segments1.size(); Result.StartFigure(); + bool first_start = true; for (size_t i = 0; i < length + Segments2.size(); i++) { Segment s = i >= length ? Segments2[i - length] : Segments1[i]; bool valid = s.IsValid(Op), - start = true; + start = true; + PointD start_point; while (valid) { if (!start || (Op == Intersection && s.Inters && !GetNextSegment(s).Inters)) SetVisited(s); - if (start) + if (first_start) + { Result.MoveTo(s.P.X, s.P.Y); + start_point = s.P; + } + else if (start) + { + double x, y; + Result.GetLastPoint(x, y); + if (isZero(start_point.X - x) && isZero(start_point.Y - y)) + { + Result.MoveTo(s.P.X, s.P.Y); + start_point = s.P; + } + else + Result.LineTo(s.P.X, s.P.Y); + } else if (s.IsCurve) Result.CurveTo(s.HI.X + s.P.X, s.HI.Y + s.P.Y, s.HO.X + s.P.X, s.HO.Y + s.P.Y, @@ -1065,6 +1082,9 @@ void CBooleanOperations::TracePaths() if (start) start = false; + + if (first_start) + first_start = false; } if (!start && AllOverlap()) break; diff --git a/DocxRenderer/src/logic/Page.cpp b/DocxRenderer/src/logic/Page.cpp index b53d1c75e6..bcbd7aa074 100644 --- a/DocxRenderer/src/logic/Page.cpp +++ b/DocxRenderer/src/logic/Page.cpp @@ -250,7 +250,7 @@ namespace NSDocxRenderer shape->m_dRotation = rotation; if (info) - DrawImage(shape, info); + DrawImage(shape, info, image_vector); else shape->m_eType = CShape::eShapeType::stVectorGraphics; @@ -2108,17 +2108,16 @@ namespace NSDocxRenderer oWriter.WriteString(L""); } - void CPage::DrawImage(shape_ptr_t pShape, std::shared_ptr oImgInfo) + void CPage::DrawImage(shape_ptr_t pShape, std::shared_ptr oImgInfo, CVectorGraphics& imageVector) { pShape->m_pImageInfo = oImgInfo; pShape->m_eType = CShape::eShapeType::stVectorTexture; - auto image_vector = pShape->m_oVector; - image_vector.RotateAt(-pShape->m_dRotation, pShape->m_oVector.GetCenter()); + imageVector.RotateAt(-pShape->m_dRotation, pShape->m_oVector.GetCenter()); - pShape->m_dImageBot = image_vector.GetBottom(); - pShape->m_dImageTop = image_vector.GetTop(); - pShape->m_dImageLeft = image_vector.GetLeft(); - pShape->m_dImageRight = image_vector.GetRight(); + pShape->m_dImageBot = imageVector.GetBottom(); + pShape->m_dImageTop = imageVector.GetTop(); + pShape->m_dImageLeft = imageVector.GetLeft(); + pShape->m_dImageRight = imageVector.GetRight(); } void CPage::DrawGradient(shape_ptr_t pShape) @@ -2178,7 +2177,7 @@ namespace NSDocxRenderer auto info = m_oManagers.pImageManager->WriteImage(&img, pShape->m_dTop, pShape->m_dBaselinePos, pShape->m_dWidth, pShape->m_dHeight); pShape->m_dRotation = 0; - DrawImage(pShape, info); + DrawImage(pShape, info, pShape->m_oVector); RELEASEINTERFACE(g_renderer) } diff --git a/DocxRenderer/src/logic/Page.h b/DocxRenderer/src/logic/Page.h index 8f83939481..379a394b8e 100644 --- a/DocxRenderer/src/logic/Page.h +++ b/DocxRenderer/src/logic/Page.h @@ -190,7 +190,7 @@ namespace NSDocxRenderer static shape_ptr_t CreateSingleLineShape(line_ptr_t& pLine); static shape_ptr_t CreateSingleParagraphShape(paragraph_ptr_t& pParagraph); - void DrawImage(shape_ptr_t pShape, std::shared_ptr oImg); + void DrawImage(shape_ptr_t pShape, std::shared_ptr oImg, CVectorGraphics& imageVector); void DrawGradient(shape_ptr_t pShape); void FillLuminosityShapes();