I'm currently having a problem with this libary where CubicBezier curves when turned into poly1d sometimes end up being linear or end in other garbage.
This is the wanted path:
And this is what I get:
As you can see, for some reason it converts all curves into diagonals or some weird mix.
I'd appreciate any help or pointers in the right direction.
This is my Code:
import turtle
import numpy as np
from svgpathtools import svg2paths, Line, CubicBezier
from pprint import pprint
from PIL import Image, ImageDraw
s = turtle.getscreen()
t = turtle.Turtle()
t.speed(0)
paths, attributes = svg2paths("Logo - Kopie.svg") # type: ignore
scale_factor = -0.25
t.penup()
for path in paths:
for curve in path:
pprint(curve)
if isinstance(curve, Line):
t.goto(-curve.start.real * scale_factor, curve.start.imag * scale_factor)
t.pendown()
t.goto(-curve.end.real * scale_factor, curve.end.imag * scale_factor)
t.penup()
elif isinstance(curve, CubicBezier):
#! Something is wrong here
poly_curve = curve.poly()
poly_curve = np.poly1d(poly_curve)
print(poly_curve)
x_values = np.linspace(curve.start.real, curve.end.real, 250)
y_values = np.linspace(curve.start.imag, curve.end.imag, 250)
t.goto(-curve.start.real * scale_factor, curve.start.imag * scale_factor)
t.pendown()
for x, y in zip(x_values, y_values):
t.goto(-x * scale_factor, y * scale_factor)
t.penup()
input("Press Enter to continue...")
print("Done")
Hey everyone!
I'm currently having a problem with this libary where CubicBezier curves when turned into poly1d sometimes end up being linear or end in other garbage.
This is the wanted path:
And this is what I get:
As you can see, for some reason it converts all curves into diagonals or some weird mix. I'd appreciate any help or pointers in the right direction. This is my Code:
Best regards, Fischchen