Skip to content

Commit

Permalink
Remove bezier deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
PadLex committed Jul 27, 2020
1 parent f78be04 commit 75063ee
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import os
import math
import bezmisc

import re
import sys
import time
Expand All @@ -57,6 +57,9 @@
# Inkex.Boolean
inkex.Boolean = bool

import bezmisc as bezier


else:
# simplestyle

Expand All @@ -80,14 +83,17 @@ def parseStyle(s): # noqa
parsePath = CubicSuperPath


from inkex import bezier


# Check if inkex has error messages. (0.46 version does not have one) Could be removed later.
if "errormsg" not in dir(inkex):
inkex.errormsg = lambda msg: sys.stderr.write((str(msg) + "\n").encode("UTF-8"))


def bezierslopeatt(xxx_todo_changeme, t):
((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
dy = 3 * ay * (t ** 2) + 2 * by * t + cy
if dx == dy == 0:
Expand All @@ -105,7 +111,7 @@ def bezierslopeatt(xxx_todo_changeme, t):
return dx, dy


bezmisc.bezierslopeatt = bezierslopeatt
bezier.bezierslopeatt = bezierslopeatt

################################################################################
#
Expand Down Expand Up @@ -249,7 +255,7 @@ def csp_split(sp1, sp2, t=.5):


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

Expand Down Expand Up @@ -293,7 +299,7 @@ def csp_at_t(sp1, sp2, t):

def cspseglength(sp1, sp2, tolerance=0.001):
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
Expand Down

0 comments on commit 75063ee

Please sign in to comment.