BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
962 stars 159 forks source link

Creating polylines directly from numpy arrays of 2d points? #66

Closed tristanryerparke closed 1 year ago

tristanryerparke commented 1 year ago

In the single_curve.py and painterly_rendering.py examples I see that paths can be created from numpy arrays, with the points in the array representing end points and control points of a chain of quadratic bezier curves. In the single_path.py example a cubic bezier is specified from an svg string. However I don't see anywhere in the examples where a polyline is passed to the 'pydiffvg.Path()' constructor. I'd like to avoid converting my numpy array of points to an svg string and then using 'pydiffvg.from_svg_path' on each epoch. Is this possible? Thanks

WinKawaks commented 9 months ago

@tristanryerparke Do you solve this problem? I have some similar ideas based on the polylines rendering.

tristanryerparke commented 9 months ago

@WinKawaks I tried a bunch of different things, but never got it working. However, I found that one can use the from_svg_path method upon initialization, and then edit or optimize the path.points tensor directly, this allowed for differentiable adjustment of the polyline.