Providing utility nodes to deal with nugets that can draw on SKCanvas

Problem Description

Hi! I was hoping to use a C# nuget that can draw charts on a Skia Canvas. I tried Microcharts and ScottPlot.

Here are those WIP patches:

micocharts-try-1.vl (72.4 KB)
microcharts-try-2.vl (103.8 KB)
scottplot.vl (76.3 KB)

I’m unable to do few things at all. Unlike a Skia Rectangle node I’m unable to:

  • pass it a Size and have it sized properly on each Common Space (DIP, Normalized, etc.)
  • pass it Position have it position properly
  • apply rotation, scale using TransformSRT have the output coming out of TransformSRT have the proper transform applied

Feature request

Essentially if I’m passing Size, Position, Anchor, and later (say) rotation using TransformSRT node to my node that draws a chart, I want its output to get sized/positioned/transformed exactly like a Rectangle node does.

My request is to add helper nodes (and a help patch) that can give us first-class support for 3rd party libaries which can draw on Skia.

1 Like

Have a look at the implementation of LottiePlayer (FrameBased Skia) [Video]. Does that help?

TL;DR: I’m still facing issues.

While it didn’t help much, it made me look if there’s a way to pass an SKRect to their render/draw methods somehow. ScottPlot has a way to pass SKRect (more below), but Microcharts does not. I expect that other C# libs that can draw on a Skia Canvas will also lack a way to pass a rectangle and will only accept width and height in integers.

In ScottPlot, one can pass SKRect to ToPixelRect node which then can be passed to its Render. However, all I see now is a white rectangle, not the graph. I’m attaching the updated patch here:

charts.vl (50.4 KB)

I’m not sure what’s happening here: if the graph has been exploded in the view so much that all I’m seeing is white, or if the graph is positioned someplace else and it isn’t in the view.