for PyPI v1.3 update

pull/12/merge 1.3
Andy 2017-02-28 23:11:46 -08:00
parent 8815ddcd52
commit 465e96f8c8
11 changed files with 48 additions and 13 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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')]

Binary file not shown.

BIN
dist/svgpathtools-1.3.tar.gz vendored Normal file

Binary file not shown.

View File

@ -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
============

View File

@ -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