VL.PolyTools

I agree that some nice SVG tools would be great.

I think the future of VL.PolyTools is more low level than that. It’s really about, well, polygon type scope of objects.
For example individual closed shapes, triangles, lines. (Dabbling in some 3D versions)

I think SVG would be better in its own library that looks at the specific usecases you have for it. Working with files and parsing and CSS is really a completely different paradigm than editing shapes.

It could for sure make sense if VL.PolyTools was a dependency in that project, and with nuget you can make ‘nuget install VL.SVGTools’ automatically install VL.PolyTools

2 Likes

hi, @tobyk , i was playing with the poly tools on stride i was learning how to use the nuget and feels good. now i am trying to export the Stride / poly tools - shapes to a svg file but i can’t find the way to do this, do you know how i can this can be done?

Hi @Sabme

I assume you want to use SVGs because you want the vector information? (If you just wanted pixels could of course use png, jpg whatever).

As I understand the SVGWriter is part of the Skia package.

In theory all you have to do is

  • Get your polygons and polypaths and use draw functions that will draw them directly in Skia. EG DrawPolygon (Skia) and DrawPolypath (Skia). Interally these use the Skia SKpath type.
  • Connect those layers to SVGWriter
  • Then I think SVGWriter will takes the layers with vector information (SKPaths) and uses that to write the SVG.

Problem is you said you were using Stride. I’m not sure how you are using it but a rasterised stride scene (pixels) going back to Skia and then to SVGWriter will probably only give you rastersied data in a SVG writer.

There is not much documentation on SVGwriter, maybe this thread could be useful:

hi @tobyk, yep I want the vector info. the thing is I Pass from a Ceate (poly tool ) (rendere on skia) to a CReate (Polytool stride polygon 2d plus) so I played on a 3d space, made spreads and output on scenewindow, the idea is to catch the info like the Processing pdf library to save 3d space info into a 2d space canvas (is the beggin Raw, End Raw statement). i leave my set up and the image i need in vectors maybe this can help for an accurater way to solve it.
I will try the points you write above. ;)


Ok so if you already have the points in 3D it’s just about transforming them back to screen space 2D, in the exact same way as your renderer does (with the same camera). Except we still want to access them as points.

This is nothing really to do with VL.PolyTools BUT you are in luck. It happens to be related to a series of math tutorials I just put into VL.ExtendedTutorials. It might be worth going through those to help understand what’s going on here.

So here is a solution.

Draft Explanation Camera Transform to Screen Space coords.vl (66.2 KB)

There is only one bit I’m unsure of which is a weird X scale transformation for skia. I’ve asked about it in the TransformingBrains chat channel and when I understand that I will also add this to the VL.ExtendedTutorials math series.

2 Likes

ok ok, im a lucky you are on this Math Series Tutorial. i will download the nugget to see your work ;); and looking at the file you sent me, I have seen how to do it. thanks a lot ;)

PD. just one more thing is there a way to pass from a “Create” poly tool stride 2d plus - to a simple a "Create "poly tool node ?

2- on your Draft explanation camera vl file, i just add ( ) 3dmatrix value to correct the pesprective between the 3d viewer and the 2d viewer, it goes under the camera matrices () and on the new matirces mutiplier chahge the 2nd column 2nd row value to ( -1) and then we see the same perspective in both screens.

Ok here is the finalised tutorial patch.
The ‘mystery’ was about aspect ratio correction.
Thanks @motzi for helping me sort it out.

Explanation 22 Camera Transform to Screen Space coords.vl (80.9 KB)

In regards to the question about type conversion perhaps this is helpful?

3 Likes

oki doki got it. thanks a lot