diff --git a/build/lib/svgpathtools/bezier.py b/build/lib/svgpathtools/bezier.py index 1919e68..db4c869 100644 --- a/build/lib/svgpathtools/bezier.py +++ b/build/lib/svgpathtools/bezier.py @@ -5,6 +5,8 @@ points given by their standard representation.""" # External dependencies: from __future__ import division, absolute_import, print_function +from builtins import range +from builtins import object from math import factorial as fac, ceil, log, sqrt from numpy import poly1d @@ -83,12 +85,13 @@ def bezier2polynomial(p, numpy_ordering=True, return_poly1d=False): coeffs = p else: # https://en.wikipedia.org/wiki/Bezier_curve#Polynomial_form - n = len(p) + 1 + n = len(p) - 1 coeffs = [fac(n)//fac(n-j) * sum( - (-1)**(i+j) * p[i] / (fac(i) * fac(j-i)) for i in xrange(j+1)) + (-1)**(i+j) * p[i] / (fac(i) * fac(j-i)) for i in range(j+1)) for j in range(n+1)] - if not numpy_ordering: coeffs.reverse() + if not numpy_ordering: + coeffs = coeffs[::-1] # can't use .reverse() as might be tuple if return_poly1d: return poly1d(coeffs) return coeffs diff --git a/build/lib/svgpathtools/directional_field.py b/build/lib/svgpathtools/directional_field.py new file mode 100644 index 0000000..b77351d --- /dev/null +++ b/build/lib/svgpathtools/directional_field.py @@ -0,0 +1,21 @@ +def directional_field(curve, tvals=np.linspace(0, 1, N), asize=1e-2, + colored=False): + + size = asize * curve.length() + arrows = [] + tvals = np.linspace(0, 1, N) + for t in tvals: + pt = curve.point(t) + ut = curve.unit_tangent(t) + un = curve.normal(t) + l1 = Line(pt, pt + size*(un - ut)/2).reversed() + l2 = Line(pt, pt + size*(-un - ut)/2) + if colored: + arrows.append(Path(l1, l2)) + else: + arrows += [l1, l2] + if colored: + colors = [(int(255*t), 0, 0) for t in tvals] + return arrows, tvals, colors + else: + return Path(arrows) \ No newline at end of file diff --git a/build/lib/svgpathtools/misctools.py b/build/lib/svgpathtools/misctools.py index 787d000..5deb0bc 100644 --- a/build/lib/svgpathtools/misctools.py +++ b/build/lib/svgpathtools/misctools.py @@ -3,6 +3,7 @@ aren't specific to SVGs or related mathematical objects.""" # External dependencies: from __future__ import division, absolute_import, print_function +from builtins import range import os import sys import webbrowser diff --git a/build/lib/svgpathtools/path.py b/build/lib/svgpathtools/path.py index 1484b5a..f14ce0a 100644 --- a/build/lib/svgpathtools/path.py +++ b/build/lib/svgpathtools/path.py @@ -4,6 +4,10 @@ Arc.""" # External dependencies from __future__ import division, absolute_import, print_function +from builtins import map +from builtins import zip +from builtins import range +from builtins import object from math import sqrt, cos, sin, acos, degrees, radians, log, pi from cmath import exp, sqrt as csqrt, phase from collections import MutableSequence @@ -355,7 +359,8 @@ def inv_arclength(curve, s, s_tol=ILENGTH_S_TOL, maxits=ILENGTH_MAXITS, if curve is a Path object, then seg is a segment in curve. error - used to compute lengths of cubics and arcs min_depth - used to compute lengths of cubics and arcs - Note: This function is not designed to be efficient.""" + Note: This function is not designed to be efficient, but if it's slower + than you need, make sure you have scipy installed.""" curve_length = curve.length(error=error, min_depth=min_depth) assert curve_length > 0 @@ -1514,7 +1519,7 @@ class Arc(object): u1poly_mag2 = real(u1poly)**2 + imag(u1poly)**2 t2s = polyroots01(u1poly_mag2 - 1) t1s = [self.phase2t(phase(u1poly(t2))) for t2 in t2s] - return zip(t1s, t2s) + return list(zip(t1s, t2s)) elif isinstance(other_seg, Arc): assert other_seg != self # This could be made explicit to increase efficiency @@ -2126,7 +2131,7 @@ class Path(MutableSequence): """returns a bounding box for the input Path object in the form (xmin, xmax, ymin, ymax).""" bbs = [seg.bbox() for seg in self._segments] - xmins, xmaxs, ymins, ymaxs = zip(*bbs) + xmins, xmaxs, ymins, ymaxs = list(zip(*bbs)) xmin = min(xmins) xmax = max(xmaxs) ymin = min(ymins) diff --git a/build/lib/svgpathtools/paths2svg.py b/build/lib/svgpathtools/paths2svg.py index d09ff57..48a4ff9 100644 --- a/build/lib/svgpathtools/paths2svg.py +++ b/build/lib/svgpathtools/paths2svg.py @@ -3,6 +3,8 @@ segments.""" # External dependencies: from __future__ import division, absolute_import, print_function +from builtins import zip +from builtins import str from math import ceil from os import getcwd, path as os_path, makedirs from xml.dom.minidom import parse as md_xml_parse @@ -74,7 +76,7 @@ def big_bounding_box(paths_n_stuff): raise TypeError( "paths_n_stuff can only contains Path, CubicBezier, " "QuadraticBezier, Line, and complex objects.") - xmins, xmaxs, ymins, ymaxs = zip(*bbs) + xmins, xmaxs, ymins, ymaxs = list(zip(*bbs)) xmin = min(xmins) xmax = max(xmaxs) ymin = min(ymins) diff --git a/build/lib/svgpathtools/smoothing.py b/build/lib/svgpathtools/smoothing.py index 424ed99..33f763e 100644 --- a/build/lib/svgpathtools/smoothing.py +++ b/build/lib/svgpathtools/smoothing.py @@ -5,6 +5,7 @@ curves.""" from __future__ import division, absolute_import, print_function # Internal Dependencies +from builtins import range from .path import Path, CubicBezier, Line from .misctools import isclose from .paths2svg import disvg @@ -23,7 +24,7 @@ def is_differentiable(path, tol=1e-8): def kinks(path, tol=1e-8): """returns indices of segments that start on a non-differentiable joint.""" kink_list = [] - for idx in xrange(len(path)): + for idx in range(len(path)): if idx == 0 and not path.isclosed(): continue try: diff --git a/build/lib/svgpathtools/svg2paths.py b/build/lib/svgpathtools/svg2paths.py index c3b66f9..1d3274c 100644 --- a/build/lib/svgpathtools/svg2paths.py +++ b/build/lib/svgpathtools/svg2paths.py @@ -3,6 +3,7 @@ The main tool being the svg2paths() function.""" # External dependencies from __future__ import division, absolute_import, print_function +from builtins import zip from xml.dom.minidom import parse from os import path as os_path, getcwd from shutil import copyfile @@ -64,9 +65,9 @@ def svg2paths(svg_file_location, def dom2dict(element): """Converts DOM elements to dictionaries of attributes.""" - keys = element.attributes.keys() - values = [val.value for val in element.attributes.values()] - return dict(zip(keys, values)) + keys = list(element.attributes.keys()) + values = [val.value for val in list(element.attributes.values())] + return dict(list(zip(keys, values))) # Use minidom to extract path strings from input SVG paths = [dom2dict(el) for el in doc.getElementsByTagName('path')] diff --git a/dist/svgpathtools-1.3-py2.py3-none-any.whl b/dist/svgpathtools-1.3-py2.py3-none-any.whl new file mode 100644 index 0000000..8dcaa86 Binary files /dev/null and b/dist/svgpathtools-1.3-py2.py3-none-any.whl differ diff --git a/dist/svgpathtools-1.3.tar.gz b/dist/svgpathtools-1.3.tar.gz new file mode 100644 index 0000000..9bc1a2a Binary files /dev/null and b/dist/svgpathtools-1.3.tar.gz differ diff --git a/svgpathtools.egg-info/PKG-INFO b/svgpathtools.egg-info/PKG-INFO index 2047ffe..bbef88f 100644 --- a/svgpathtools.egg-info/PKG-INFO +++ b/svgpathtools.egg-info/PKG-INFO @@ -1,12 +1,12 @@ Metadata-Version: 1.1 Name: svgpathtools -Version: 1.2.6 +Version: 1.3 Summary: A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves. Home-page: https://github.com/mathandy/svgpathtools Author: Andy Port Author-email: AndyAPort@gmail.com License: MIT -Download-URL: http://github.com/mathandy/svgpathtools/tarball/1.2.6 +Download-URL: http://github.com/mathandy/svgpathtools/tarball/1.3 Description: svgpathtools ============ diff --git a/svgpathtools.egg-info/SOURCES.txt b/svgpathtools.egg-info/SOURCES.txt index bd2f2f6..99a5197 100644 --- a/svgpathtools.egg-info/SOURCES.txt +++ b/svgpathtools.egg-info/SOURCES.txt @@ -15,6 +15,7 @@ test.svg vectorframes.svg svgpathtools/__init__.py svgpathtools/bezier.py +svgpathtools/directional_field.py svgpathtools/misctools.py svgpathtools/parser.py svgpathtools/path.py