Remove bezier deprecation warning

This commit is contained in:
Padlex
2020-07-27 15:45:34 +02:00
parent f78be04a07
commit 75063ee9fa

View File

@@ -31,7 +31,7 @@ from inkex.paths import Path
import os import os
import math import math
import bezmisc
import re import re
import sys import sys
import time import time
@@ -57,6 +57,9 @@ if target_version < 1.0:
# Inkex.Boolean # Inkex.Boolean
inkex.Boolean = bool inkex.Boolean = bool
import bezmisc as bezier
else: else:
# simplestyle # simplestyle
@@ -80,6 +83,9 @@ else:
parsePath = CubicSuperPath parsePath = CubicSuperPath
from inkex import bezier
# Check if inkex has error messages. (0.46 version does not have one) Could be removed later. # Check if inkex has error messages. (0.46 version does not have one) Could be removed later.
if "errormsg" not in dir(inkex): if "errormsg" not in dir(inkex):
inkex.errormsg = lambda msg: sys.stderr.write((str(msg) + "\n").encode("UTF-8")) inkex.errormsg = lambda msg: sys.stderr.write((str(msg) + "\n").encode("UTF-8"))
@@ -87,7 +93,7 @@ if "errormsg" not in dir(inkex):
def bezierslopeatt(xxx_todo_changeme, t): def bezierslopeatt(xxx_todo_changeme, t):
((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3)) = xxx_todo_changeme ((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3)) = xxx_todo_changeme
ax, ay, bx, by, cx, cy, x0, y0 = bezmisc.bezierparameterize(((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3))) ax, ay, bx, by, cx, cy, x0, y0 = bezier.bezierparameterize(((bx0, by0), (bx1, by1), (bx2, by2), (bx3, by3)))
dx = 3 * ax * (t ** 2) + 2 * bx * t + cx dx = 3 * ax * (t ** 2) + 2 * bx * t + cx
dy = 3 * ay * (t ** 2) + 2 * by * t + cy dy = 3 * ay * (t ** 2) + 2 * by * t + cy
if dx == dy == 0: if dx == dy == 0:
@@ -105,7 +111,7 @@ def bezierslopeatt(xxx_todo_changeme, t):
return dx, dy return dx, dy
bezmisc.bezierslopeatt = bezierslopeatt bezier.bezierslopeatt = bezierslopeatt
################################################################################ ################################################################################
# #
@@ -249,7 +255,7 @@ def csp_split(sp1, sp2, t=.5):
def csp_curvature_at_t(sp1, sp2, t, depth=3): def csp_curvature_at_t(sp1, sp2, t, depth=3):
ax, ay, bx, by, cx, cy, dx, dy = bezmisc.bezierparameterize(csp_segment_to_bez(sp1, sp2)) ax, ay, bx, by, cx, cy, dx, dy = bezier.bezierparameterize(csp_segment_to_bez(sp1, sp2))
# curvature = (x'y''-y'x'') / (x'^2+y'^2)^1.5 # curvature = (x'y''-y'x'') / (x'^2+y'^2)^1.5
@@ -293,7 +299,7 @@ def csp_at_t(sp1, sp2, t):
def cspseglength(sp1, sp2, tolerance=0.001): def cspseglength(sp1, sp2, tolerance=0.001):
bez = (sp1[1][:], sp1[2][:], sp2[0][:], sp2[1][:]) bez = (sp1[1][:], sp1[2][:], sp2[0][:], sp2[1][:])
return bezmisc.bezierlength(bez, tolerance) return bezier.bezierlength(bez, tolerance)
# Distance calculation from point to arc # Distance calculation from point to arc