From 759723795eb0da59411b175c0e9aad638385e1c7 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 1 Mar 2020 22:17:41 +0100 Subject: [PATCH] Support transparency for brush patterns in wxSVGFileDC Include the alpha value in the pattern name. --- src/common/dcsvg.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 02b4a99d31..cd1d678ebe 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -270,6 +270,9 @@ wxString GetBrushStyleName(const wxBrush& brush) break; } + if (!brushStyle.empty()) + brushStyle += wxString::Format(wxS("%s%02X"), Col2SVG(brush.GetColour()).substr(1), brush.GetColour().Alpha()); + return brushStyle; } @@ -279,7 +282,7 @@ wxString GetBrushPattern(const wxBrush& brush) wxString brushStyle = GetBrushStyleName(brush); if (!brushStyle.empty()) - s = wxS("fill=\"url(#") + brushStyle + Col2SVG(brush.GetColour()).substr(1) + wxS(")\""); + s = wxString::Format(wxS("fill=\"url(#%s)\""), brushStyle); return s; } @@ -339,13 +342,14 @@ wxString CreateBrushFill(const wxBrush& brush, wxSVGShapeRenderingMode mode) break; } - wxString brushColourStr = Col2SVG(brush.GetColour()); + float opacity; + wxString brushColourStr = Col2SVG(brush.GetColour(), &opacity); wxString brushStrokeStr = wxS("stroke-width:1; stroke-linecap:round; stroke-linejoin:round;"); - s += wxString::Format(wxS(" \n"), - patternName, brushColourStr.substr(1)); - s += wxString::Format(wxS(" \n"), - brushColourStr, brushStrokeStr, pattern, GetRenderMode(mode)); + s += wxString::Format(wxS(" \n"), + patternName); + s += wxString::Format(wxS(" \n"), + brushColourStr, NumStr(opacity), brushStrokeStr, pattern, GetRenderMode(mode)); s += wxS(" \n"); }