SP5: render Legend into Image#3062
Conversation
|
Hi @KroMignon, thank you for working on #2934! At first glance this looks fantastic I see this is still "WIP" so let me know when you're ready to merge and I'll review it a little closer and merge it in good time My only suggestion is to add XML docs to |
- fix initialisation bug in PixelRects - add GetLegendImage into Plot
- add optional parameter for MaxWidth and MaxHeight - fix shadow rendering
|
Hello @swharden, sorry for the long delay since last update, I was sick with COVID 😷. I made some changes to fix shadow rendering, but I am not sure if shadow is required in this case? I would also propose to change the |
- `GetLegendImage` now returns a SKImage instance to be more flexible - fix legend shadow redering - add XML documentation
|
Hello @swharden, what do you think about this implementation? |
fix legend image shadow drawing
|
I don't think it's ideal that Instead, I think both As for |
|
@bclehmann many thanks for your feedback.
I generally try to avoid code duplication, but sometimes it is more effective. I will check your suggestion more deeply, perhaps I find a way which is not "overengineered" / overcomplicated.
I do not understand the problem here, AFAIK |
do not display legend item for hidden plotable
|
@swharden this PR comes with the following changes:
|
Allows a SVG image to be created with an exposed SKCanvas that can be drawn on and saved later
|
Hi @KroMignon, thanks for your extensive work on this! Thanks @bclehmann too for your input along the way. I reworked the code a bit and now this is possible: Plot plt = new();
var sig1 = plt.Add.Signal(Generate.Sin());
sig1.Label = "Sine";
plt.Legend.IsVisible = true;
Image img = plt.GetLegendImage();
img.Save("demo.png");
SvgImage svg = plt.GetLegendSvg();
svg.Save("demo.svg");I created a The basic functionality works now so I'm going to merge this, but there is definitely room for improvement. SkImage does not implement I don't want refining the legend to block development of the rest of ScottPlot 5 so I think this is fine to merge for now, but I welcome refinements along the way and will probably perform a deep refactor of the Legend class at some point. Thanks again, I'm glad to have this in ScottPlot 5! 🚀 |
|
I was not 100% happy with actual code, but had no time to reorganize/rewrite it. Thanks for merging it into code base. |
This is a first step to allow rendering legend alone as
Image, which can be converted into many type of picture formats (BMP, JPEG, etc.).This should fix #2934.
PixelRectsGetLegendImage()intoPlot@swharden tell me what you are thinking about this.