-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Custom geometry support (freeform) #872
Conversation
I've removed the changes outside /src in this PR also. |
ac9a470
to
3648935
Compare
I've fixed the conflicts with the master branch. |
I spent almost 1 week trying to figure out how to convert between svg-path and a custom geometry points array. In case someone needs it, it is necessary to convert from an endpoint parameterization to a center parameterization (as described here https://www.w3.org/TR/SVG11/implnote.html#ArcConversionEndpointToCenter ) I found this article that has this conversion implemented in javascript ( https://observablehq.com/@awhitty/svg-2-elliptical-arc-to-canvas-path2d ). A point of attention is that the function described in the article returns radians and we must work with degrees. I took the liberty of making some adjustments. The code:
How to use with svg-points? Suppose your points as follows:
Just call the function endpointToCenterParameterization with: x1, y1 ---> x, y of the last point (in this case, x1=0 and y1=-50) hope it helps someone |
@luizzappa Given your example JS code. Can you show an example of how to map a Which properties should be changed with the |
Hello,
This PR adds support for the custGeom shape. (Freehand, custom polygon, path, etc). This solves #597.
I've implemented this by using a similar spec to the one that uses svg-points.
The path or contour of the custom geometry is declared under the property
points
of theShapeProps
object.With this implementation we are supporting all the custom geometry rules: moveTo, lnTo, arcTo, cubicBezTo, quadBezTo and close.
A translation of an svg path to a custom geometry could be achieved by using the svg-points package and adding a custom translation between the arcs.
The svg arc is described by the variables
x, y, rx, ry, xAxisRotation, largeArcFlag and sweepFlag
. On the other side the pptx freeform arc is described byx, y, hR, wR, stAng, swAng
.In order to add some sort of translation between svg-path and a custom geometry points array we should create a translation between those two representations of the arc.
I took the liberty to add an example of a custom geometry inside the Shape Demos section of the demo file.
Hope you like this.
Thank you !