Fix transparent background frame accumulation with axis rules#5029
Fix transparent background frame accumulation with axis rules#5029swharden merged 5 commits intoScottPlot:mainfrom
Conversation
Update: Fixed SVG test failureThe initial implementation caused the Fixed by adding condition: // Only clear when background is transparent
if (Plot.FigureBackground?.Color.A < 255)
{
canvas. Clear();
} |
|
Hi @diluculo, thanks for researching this! I don't know much about WinUI so I really value input from people who are a lot more familiar with it and are able to test it for edge cases like this. I'm going to extend your PR to add code comments about why clearing is on by default... I'm pretty sure it's to prevent SVGs from containing several overlapping plots when a plot is rendered multiple times and exported as SVG. A better solution is to add a flag to enable/disable this behavior, and we can disable it by default in the WinUI control. I'll look into it now and follow-up shortly... |
|
... quick follow-up, I now realize your fix shouldn't affect SVG output. My bad for responding too quickly 😅 Sorry for the noise! I think this fix will be good and I'll merge shortly Thanks again! |
Fixes #5026
Problem
Transparent backgrounds in WinUI3 cause frame accumulation when using axis rules (
SquareZoomOut,SquarePreserveX, etc.) due to improper canvas clearing between iterations.Solution
Add
canvas.Clear()before each render iteration inRenderManager.Render()to force proper clearing of WinUI3's transparent rendering pipeline.