How do I get a coordinates list from an svgpathtools bezier curve?

P.V.

I have python code to create a bezier curve, from which I create a bezier path.

Here are my imports:

import from svgpathtools import Path, Line, CubicBezier

Here is my code:

    bezier_curve = CubicBezier(start_coordinate, control_point_1, control_point_2, end_coordinate)
    bezier_path = Path(bezier_curve)

I would like to create a list of coordinates that make up this curve, but none of the documentation I am reading gives a straightforward way to do that. bezier_curve and bezier_path only have parameters for the start point, end point, and control point.

Heath Raftery

Seems like a pretty reasonable question. Surprised there's no answer. I had to do this myself recently, and the secret is point().

Here's how I got it done, using your boilerplate as a starting point:

from svgpathtools import Path, Line, CubicBezier

bezier_curve = CubicBezier(start=(300+100j), control1=(100+100j), control2=(200+200j), end=(200+300j))
bezier_path = Path(bezier_curve)

NUM_SAMPLES = 10

myPath = []
for i in range(NUM_SAMPLES):
    myPath.append(bezier_path.point(i/(NUM_SAMPLES-1)))

print(myPath)

Output:

[(300+100j), (243.8957475994513+103.56652949245542j), (206.72153635116598+113.71742112482853j), (185.1851851851852+129.62962962962962j), (175.99451303155004+150.480109739369j), (175.85733882030178+175.44581618655695j), (181.4814814814815+203.7037037037037j), (189.57475994513032+234.43072702331963j), (196.84499314128942+266.8038408779149j), (200+300j)]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I get the coordinates from CAShapeLayer

How do I push coordinates from a pandas dataframe to into a List?

How can I get 'edge' points (furthest edge coordinates) from a list of coordinates

How do I get a curve point on a line?

Can I animate the X- and Y- coordinates of a WPF Bezier curve control point separately?

How can I simulate a Bezier curve out of an image?

How could I add these annotation to this quadratic Bezier curve?

How can I draw only a subsection of a Bezier curve in WPF?

How can i add bezier curve to Path in konva?

how do i get the coordinates of a click in jquery?

How to get path of Bezier curves with coordinates of decimal value

How do I convert from mouse coordinates to pixel coordinates of a TransformedBitmap?

How to add a gradient in a Bezier curve?

How to draw Bezier Curve in Android

How to apply a SKPhysicsBody to a bezier curve?

How to Draw a Bezier Curve in UIView

How to draw a curve in Bezier Path?

How to convert quadratic bezier curve code into cubic bezier curve?

How do I get list of only duplicate objects from a list

How do I get the color value from the List<Feature> list?

How do I get a value list from a tuple list?

How do I trigger click event to get the coordinates from the map in uiversal app

How do I get color value from a color wheel based on X & Y coordinates?

Get normal of bezier curve in 2D

How do I add the curve from GauPro in ggplot?

How do I remove a curve from a plt plot?

How do I fit this curve?

Perpendicular line from bezier curve to point

I have a list of user-inputted coordinates, how do i calculate the point that is as close as possible to all the coordinates?