svgpathtools API Reference
Tools for manipulating, analyzing, and transforming SVG path objects.
svgpathtools.Arc
Python Library Documentation: class Arc in module svgpathtools.path class Arc(builtins.object) | Arc(start, radius, rotation, large_arc, sweep, end, autoscale_radius=True) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, radius, rotation, large_arc, sweep, end, autoscale_radius=True) | This should be thought of as a part of an ellipse connecting two | points on that ellipse, start and end. | Parameters | ---------- | start : complex | The start point of the curve. Note: `start` and `end` cannot be the | same. To make a full ellipse or circle, use two `Arc` objects. | radius : complex | rx + 1j*ry, where rx and ry are the radii of the ellipse (also | known as its semi-major and semi-minor axes, or vice-versa or if | rx < ry). | Note: If rx = 0 or ry = 0 then this arc is treated as a | straight line segment joining the endpoints. | Note: If rx or ry has a negative sign, the sign is dropped; the | absolute value is used instead. | Note: If no such ellipse exists, the radius will be scaled so | that one does (unless autoscale_radius is set to False). | rotation : float | This is the CCW angle (in degrees) from the positive x-axis of the | current coordinate system to the x-axis of the ellipse. | large_arc : bool | Given two points on an ellipse, there are two elliptical arcs | connecting those points, the first going the short way around the | ellipse, and the second going the long way around the ellipse. If | `large_arc == False`, the shorter elliptical arc will be used. If | `large_arc == True`, then longer elliptical will be used. | In other words, `large_arc` should be 0 for arcs spanning less than | or equal to 180 degrees and 1 for arcs spanning greater than 180 | degrees. | sweep : bool | For any acceptable parameters `start`, `end`, `rotation`, and | `radius`, there are two ellipses with the given major and minor | axes (radii) which connect `start` and `end`. One which connects | them in a CCW fashion and one which connected them in a CW | fashion. If `sweep == True`, the CCW ellipse will be used. If | `sweep == False`, the CW ellipse will be used. See note on curve | orientation below. | end : complex | The end point of the curve. Note: `start` and `end` cannot be the | same. To make a full ellipse or circle, use two `Arc` objects. | autoscale_radius : bool | If `autoscale_radius == True`, then will also scale `self.radius` | in the case that no ellipse exists with the input parameters | (see inline comments for further explanation). | | Derived Parameters/Attributes | ----------------------------- | self.theta : float | This is the phase (in degrees) of self.u1transform(self.start). | It is $\theta_1$ in the official documentation and ranges from | -180 to 180. | self.delta : float | This is the angular distance (in degrees) between the start and | end of the arc after the arc has been sent to the unit circle | through self.u1transform(). | It is $\Delta\theta$ in the official documentation and ranges from | -360 to 360; being positive when the arc travels CCW and negative | otherwise (i.e. is positive/negative when sweep == True/False). | self.center : complex | This is the center of the arc's ellipse. | self.phi : float | The arc's rotation in radians, i.e. `radians(self.rotation)`. | self.rot_matrix : complex | Equal to `exp(1j * self.phi)` which is also equal to | `cos(self.phi) + 1j*sin(self.phi)`. | | | Note on curve orientation (CW vs CCW) | ------------------------------------- | The notions of clockwise (CW) and counter-clockwise (CCW) are reversed | in some sense when viewing SVGs (as the y coordinate starts at the top | of the image and increases towards the bottom). | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | apoints(self) -> 'tuple[complex, complex, float, bool, bool, complex]' | Analog of the Bezier path method, .bpoints(), for Arc objects. | | as_cubic_curves(self, curves=1) | Generates cubic curves to approximate this arc | | as_quad_curves(self, curves=1) | Generates quadratic curves to approximate this arc | | bbox(self) | returns a bounding box for the segment in the form | (xmin, xmax, ymin, ymax). | | centeriso(self, z) | Isometry to a centered aligned ellipse. | | This is an isometry that shifts and rotates `self`'s underlying | ellipse so that it's centered on the origin and has its axes | aligned with the xy-axes. | | Args: | z (:obj:`complex` or :obj:`numpy.ndarray[complex]`): a point | to send through the above-described isometry. | | Returns: | (:obj:`complex` or :obj:`numpy.ndarray[complex]`) The point(s) f(z), | where f is the above described isometry of the xy-plane (i.e. | the one-dimensional complex plane). | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the segment at t. | | derivative(self, t, n=1) | returns the nth derivative of the segment at t. | | icenteriso(self, zeta) | The inverse of the `centeriso()` method. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Approximates the unique `t` such that self.length(0, t) = s. | | Args: | s (float): A length between 0 and `self.length()`. | | Returns: | (float) The t, such that self.length(0, t) is approximately s. | | For more info: | See the inv_arclength() docstring. | | intersect(self, other_seg, tol=1e-12) | NOT FULLY IMPLEMENTED. Finds the intersections of two segments. | returns a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | Note: This will fail if the two segments coincide for more than a | finite collection of points. | | Note: Arc related intersections are only partially supported, i.e. are | only half-heartedly implemented and not well tested. Please feel free | to let me know if you're interested in such a feature -- or even better | please submit an implementation if you want to code one. | | iu1transform(self, zeta) | The inverse of the `u1transform()` method. | | joins_smoothly_with(self, previous, wrt_parameterization=False, error=0) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=1e-12, min_depth=5) | Computes the length of the Arc segment, `self`, from t0 to t1. | | Notes: | * The length of an elliptical large_arc segment requires numerical | integration, and in that case it's simpler to just do a geometric | approximation, as for cubic bezier curves. | | normal(self, t) | returns the (right hand rule) unit normal vector to self at t. | | phase2t(self, psi) | Converts phase to t-value. | | I.e. given phase, psi, such that -np.pi < psi <= np.pi, approximates | the unique t-value such that `self.u1transform(self.point(t))` equals | `np.exp(1j*psi)`. | | Args: | psi (float): The phase in radians. | | Returns: | (float): the corresponding t-value. | | point(self, t) | | point_to_t(self, point) | If the point lies on the Arc, returns its `t` parameter. | If the point does not lie on the Arc, returns None. | This function only works on Arcs with rotation == 0.0 | | radialrange(self, origin, return_all_global_extrema=False) | returns the tuples (d_min, t_min) and (d_max, t_max) which minimize | and maximize, respectively, the distance, | d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the Arc object with its orientation reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | returns two segments, whose union is this segment and which join | at self.point(t). | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | u1transform(self, z) | Similar to the `centeriso()` method, but maps to the unit circle. | | unit_tangent(self, t) | returns the unit tangent vector of the segment at t (centered at | the origin and expressed as a complex number). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.CONVERSIONS
Python Library Documentation: dict object
class dict(object)
| dict() -> new empty dictionary
| dict(mapping) -> new dictionary initialized from a mapping object's
| (key, value) pairs
| dict(iterable) -> new dictionary initialized as if via:
| d = {}
| for k, v in iterable:
| d[k] = v
| dict(**kwargs) -> new dictionary initialized with the name=value pairs
| in the keyword argument list. For example: dict(one=1, two=2)
|
| Built-in subclasses:
| StgDict
|
| Methods defined here:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
svgpathtools.CONVERT_ONLY_PATHS
Python Library Documentation: dict object
class dict(object)
| dict() -> new empty dictionary
| dict(mapping) -> new dictionary initialized from a mapping object's
| (key, value) pairs
| dict(iterable) -> new dictionary initialized as if via:
| d = {}
| for k, v in iterable:
| d[k] = v
| dict(**kwargs) -> new dictionary initialized with the name=value pairs
| in the keyword argument list. For example: dict(one=1, two=2)
|
| Built-in subclasses:
| StgDict
|
| Methods defined here:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
svgpathtools.CubicBezier
Python Library Documentation: class CubicBezier in module svgpathtools.path class CubicBezier(builtins.object) | CubicBezier(start, control1, control2, end) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, item) | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, control1, control2, end) | Initialize self. See help(type(self)) for accurate signature. | | __len__(self) | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | bbox(self) | returns bounding box in format (xmin, xmax, ymin, ymax). | | bpoints(self) | returns the Bezier control points of the segment. | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the segment at t. | | derivative(self, t, n=1) | returns the nth derivative of the segment at t. | Note: Bezier curves can have points where their derivative vanishes. | If you are interested in the tangent direction, use the unit_tangent() | method instead. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Returns a float, t, such that self.length(0, t) is approximately s. | See the inv_arclength() docstring for more details. | | intersect(self, other_seg, tol=1e-12) | Finds the intersections of two segments. | | Returns: | (list[tuple[float]]) a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | | Scope: | This will fail if the two segments coincide for more than a | finite collection of points. | | is_smooth_from(self, previous, warning_on=True) | [Warning: The name of this method is somewhat misleading (yet kept | for compatibility with scripts created using svg.path 2.0). This | method is meant only for d string creation and should not be used to | check for kinks. To check a segment for differentiability, use the | joins_smoothly_with() method instead.] | | joins_smoothly_with(self, previous, wrt_parameterization=False) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=1e-12, min_depth=5) | Calculate the length of the path up to a certain position | | normal(self, t) | returns the (right hand rule) unit normal vector to self at t. | | point(self, t) | Evaluate the cubic Bezier curve at t using Horner's rule. | | points(self, ts) | Faster than running Path.point many times. | | poly(self, return_coeffs=False) | Returns a the cubic as a Polynomial object. | | radialrange(self, origin, return_all_global_extrema=False) | returns the tuples (d_min, t_min) and (d_max, t_max) which minimize | and maximize, respectively, the distance d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the CubicBezier object with its orientation | reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | Splits a copy of `self` at t and returns the two subsegments. | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | unit_tangent(self, t) | returns the unit tangent vector of the segment at t (centered at | the origin and expressed as a complex number). If the tangent | vector's magnitude is zero, this method will find the limit of | self.derivative(tau)/abs(self.derivative(tau)) as tau approaches t. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.Document
Python Library Documentation: class Document in module svgpathtools.document
class Document(builtins.object)
| Document(filepath=None)
|
| Methods defined here:
|
| __init__(self, filepath=None)
| A container for a DOM-style SVG document.
|
| The `Document` class provides a simple interface to modify and analyze
| the path elements in a DOM-style document. The DOM-style document is
| parsed into an ElementTree object (stored in the `tree` attribute).
|
| This class provides functions for extracting SVG data into Path objects.
| The output Path objects will be transformed based on their parent groups.
|
| Args:
| filepath (str or file-like): The filepath of the
| DOM-style object or a file-like object containing it.
|
| __repr__(self)
| Return repr(self).
|
| add_group(self, group_attribs=None, parent=None)
| Add an empty group element to the SVG.
|
| add_path(self, path, attribs=None, group=None)
| Add a new path to the SVG.
|
| contains_group(self, group)
|
| display(self, filepath=None)
| Displays/opens the doc using the OS's default application.
|
| get_group(self, nested_names, name_attr='id')
| Get a group from the tree, or None if the requested group
| does not exist. Use get_or_add_group(~) if you want a new group
| to be created if it did not already exist.
|
| `nested_names` is a list of strings which represent group names.
| Each group name will be nested inside of the previous group name.
|
| `name_attr` is the group attribute that is being used to
| represent the group's name. Default is 'id', but some SVGs may
| contain custom name labels, like 'inkscape:label'.
|
| Returns the request group. If the requested group did not
| exist, this function will return a None value.
|
| get_or_add_group(self, nested_names, name_attr='id')
| Get a group from the tree, or add a new one with the given
| name structure.
|
| `nested_names` is a list of strings which represent group names.
| Each group name will be nested inside of the previous group name.
|
| `name_attr` is the group attribute that is being used to
| represent the group's name. Default is 'id', but some SVGs may
| contain custom name labels, like 'inkscape:label'.
|
| Returns the requested group. If the requested group did not
| exist, this function will create it, as well as all parent
| groups that it requires. All created groups will be left with
| blank attributes.
|
| paths(self, group_filter=<function Document.<lambda> at 0x000001C644CD1080>, path_filter=<function Document.<lambda> at 0x000001C644CD1120>, path_conversions={'path': <function path2pathd at 0x000001C644CD0680>, 'circle': <function ellipse2pathd at 0x000001C644CD0720>, 'ellipse': <function ellipse2pathd at 0x000001C644CD0720>, 'line': <function line2pathd at 0x000001C644CD09A0>, 'polyline': <function polyline2pathd at 0x000001C644CD07C0>, 'polygon': <function polygon2pathd at 0x000001C644CD0860>, 'rect': <function rect2pathd at 0x000001C644CD0900>})
| Returns a list of all paths in the document.
|
| Note that any transform attributes are applied before returning
| the paths.
|
| paths_from_group(self, group, recursive=True, group_filter=<function Document.<lambda> at 0x000001C644CD1260>, path_filter=<function Document.<lambda> at 0x000001C644CD1300>, path_conversions={'path': <function path2pathd at 0x000001C644CD0680>, 'circle': <function ellipse2pathd at 0x000001C644CD0720>, 'ellipse': <function ellipse2pathd at 0x000001C644CD0720>, 'line': <function line2pathd at 0x000001C644CD09A0>, 'polyline': <function polyline2pathd at 0x000001C644CD07C0>, 'polygon': <function polygon2pathd at 0x000001C644CD0860>, 'rect': <function rect2pathd at 0x000001C644CD0900>})
|
| pretty(self, **kwargs)
|
| save(self, filepath, prettify=False, **kwargs)
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_svg_string(svg_string)
| Constructor for creating a Document object from a string.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
svgpathtools.Line
Python Library Documentation: class Line in module svgpathtools.path class Line(builtins.object) | Line(start, end) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, item) | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, end) | Initialize self. See help(type(self)) for accurate signature. | | __len__(self) | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | bbox(self) | returns the bounding box for the segment in the form | (xmin, xmax, ymin, ymax). | | bpoints(self) | returns the Bezier control points of the segment. | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the line, which is always zero. | | derivative(self, t=None, n=1) | returns the nth derivative of the segment at t. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Returns a float, t, such that self.length(0, t) is approximately s. | See the inv_arclength() docstring for more details. | | intersect(self, other_seg, tol=None) | Finds the intersections of two segments. | returns a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | Note: This will fail if the two segments coincide for more than a | finite collection of points. | tol is not used. | | joins_smoothly_with(self, previous, wrt_parameterization=False) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=None, min_depth=None) | returns the length of the line segment between t0 and t1. | | normal(self, t=None) | returns the (right hand rule) unit normal vector to self at t. | | point(self, t) | returns the coordinates of the Bezier curve evaluated at t. | | point_to_t(self, point) | If the point lies on the Line, returns its `t` parameter. | If the point does not lie on the Line, returns None. | | points(self, ts) | Faster than running Path.point many times. | | poly(self, return_coeffs=False) | returns the line as a Polynomial object. | | radialrange(self, origin, **kwargs) | compute points in self that are min and max distance to origin. | | Args: | origin (complex): the point extremize distance to | | Returns: | tuples (d_min, t_min) and (d_max, t_max) which minimize and | maximize, respectively, the distance d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the Line object with its orientation reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | returns two segments, whose union is this segment and which join at | self.point(t). | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | unit_tangent(self, t=None) | returns the unit tangent of the segment at t. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.Path
Python Library Documentation: class Path in module svgpathtools.path
class Path(collections.abc.MutableSequence)
| Path(*segments, **kw)
|
| A Path is a sequence of path segments
|
| Method resolution order:
| Path
| collections.abc.MutableSequence
| collections.abc.Sequence
| collections.abc.Reversible
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| T2t(self, T)
| returns the segment index, `seg_idx`, and segment parameter, `t`,
| corresponding to the path parameter `T`. In other words, this is the
| inverse of the `Path.t2T()` method.
|
| __contains__(self, x)
|
| __delitem__(self, index)
|
| __eq__(self, other)
| Return self==value.
|
| __getitem__(self, index)
|
| __hash__(self) -> 'int'
| Return hash(self).
|
| __init__(self, *segments, **kw)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
|
| __len__(self)
|
| __ne__(self, other)
| Return self!=value.
|
| __repr__(self)
| Return repr(self).
|
| __setitem__(self, index, value)
|
| approximate_arcs_with_cubics(self, error=0.1)
| Iterates through this path and replaces any Arcs with cubic bezier curves.
|
| approximate_arcs_with_quads(self, error=0.1)
| Iterates through this path and replaces any Arcs with quadratic bezier curves.
|
| area(self, chord_length=0.0001)
| Find area enclosed by path.
|
| Approximates any Arc segments in the Path with lines
| approximately `chord_length` long, and returns the area enclosed
| by the approximated Path. Default chord length is 0.01. If Arc
| segments are included in path, to ensure accurate results, make
| sure this `chord_length` is set to a reasonable value (e.g. by
| checking curvature).
|
| Notes
| -----
| * Negative area results from clockwise (as opposed to
| counter-clockwise) parameterization of the input Path.
|
| To Contributors
| ---------------
| This is one of many parts of `svgpathtools` that could be
| improved by a noble soul implementing a piecewise-linear
| approximation scheme for paths (one with controls to guarantee a
| desired accuracy).
|
| bbox(self)
| returns bounding box in the form (xmin, xmax, ymin, ymax).
|
| continuous_subpaths(self)
| Breaks self into its continuous components, returning a list of
| continuous subpaths.
| I.e.
| (all(subpath.iscontinuous() for subpath in self.continuous_subpaths())
| and self == concatpaths(self.continuous_subpaths()))
| )
|
| cropped(self, T0, T1)
| returns a cropped copy of the path.
|
| curvature(self, T)
| returns the curvature of this Path object at T and outputs
| float('inf') if not differentiable at T.
|
| d(self, useSandT=False, use_closed_attrib=False, rel=False)
| Returns a path d-string for the path object.
| For an explanation of useSandT and use_closed_attrib, see the
| compatibility notes in the README.
|
| derivative(self, T, n=1)
| returns the tangent vector of the Path at T (centered at the origin
| and expressed as a complex number).
| Note: Bezier curves can have points where their derivative vanishes.
| If you are interested in the tangent direction, use unit_tangent()
| method instead.
|
| ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5)
| Returns a float, t, such that self.length(0, t) is approximately s.
| See the inv_arclength() docstring for more details.
|
| insert(self, index, value)
| S.insert(index, value) -- insert value before index
|
| intersect(self, other_curve, justonemode=False, tol=1e-12)
| Finds intersections of `self` with `other_curve`
|
| Args:
| other_curve: the path or path segment to check for intersections
| with `self`
| justonemode (bool): if true, returns only the first
| intersection found.
| tol (float): A tolerance used to check for redundant intersections
| (see comment above the code block where tol is used).
|
| Returns:
| (list[tuple[float, Curve, float]]): list of intersections, each
| in the format ((T1, seg1, t1), (T2, seg2, t2)), where
| self.point(T1) == seg1.point(t1) == seg2.point(t2) == other_curve.point(T2)
|
| Scope:
| If the two path objects coincide for more than a finite set of
| points, this code will iterate to max depth and/or raise an error.
|
| is_contained_by(self, other)
| Returns true if the path is fully contained in other closed path
|
| isclosed(self)
| This function determines if a connected path is closed.
|
| isclosedac(self)
|
| iscontinuous(self)
| Checks if a path is continuous with respect to its
| parameterization.
|
| joins_smoothly_with(self, previous, wrt_parameterization=False)
| Checks if this Path object joins smoothly with previous
| path/segment. By default, this only checks that this Path starts
| moving (at t=0) in the same direction (and from the same positive) as
| previous stopped moving (at t=1). To check if the tangent magnitudes
| also match, set wrt_parameterization=True.
|
| joints(self)
| returns generator of segment joints
|
| I.e. Path(s0, s1, s2, ..., sn).joints() returns generator
| (s0, s1), (s1, s2), ..., (sn, s0)
|
| credit: https://docs.python.org/3/library/itertools.html#recipes
|
| length(self, T0=0, T1=1, error=1e-12, min_depth=5)
|
| normal(self, t)
| returns the (right hand rule) unit normal vector to self at t.
|
| point(self, pos)
|
| radialrange(self, origin, return_all_global_extrema=False)
| returns the tuples (d_min, t_min, idx_min), (d_max, t_max, idx_max)
| which minimize and maximize, respectively, the distance
| d = |self[idx].point(t)-origin|.
|
| reversed(self)
| returns a copy of the Path object with its orientation reversed.
|
| rotated(self, degs, origin=None)
| Returns a copy of self rotated by `degs` degrees (CCW) around the
| point `origin` (a complex number). By default `origin` is either
| `self.point(0.5)`, or in the case that self is an Arc object,
| `origin` defaults to `self.center`.
|
| scaled(self, sx, sy=None, origin=0j)
| Scale transform. See `scale` function for further explanation.
|
| t2T(self, seg, t)
| returns the path parameter T which corresponds to the segment
| parameter t. In other words, for any Path object, path, and any
| segment in path, seg, T(t) = path.t2T(seg, t) is the unique
| reparameterization such that path.point(T(t)) == seg.point(t) for all
| 0 <= t <= 1.
| Input Note: seg can be a segment in the Path object or its
| corresponding index.
|
| translated(self, z0)
| Returns a copy of self shifted by the complex quantity `z0` such
| that self.translated(z0).point(t) = self.point(t) + z0 for any t.
|
| unit_tangent(self, T)
| returns the unit tangent vector of the Path at T (centered at the
| origin and expressed as a complex number). If the tangent vector's
| magnitude is zero, this method will find the limit of
| self.derivative(tau)/abs(self.derivative(tau)) as tau approaches T.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| closed
| The closed attribute is deprecated, please use the isclosed()
| method instead. See _closed_warning for more information.
|
| end
|
| start
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| element = None
|
| meta = None
|
| transform = None
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableSequence:
|
| __iadd__(self, values)
|
| append(self, value)
| S.append(value) -- append value to the end of the sequence
|
| clear(self)
| S.clear() -> None -- remove all items from S
|
| extend(self, values)
| S.extend(iterable) -- extend sequence by appending elements from the iterable
|
| pop(self, index=-1)
| S.pop([index]) -> item -- remove and return item at index (default last).
| Raise IndexError if list is empty or index is out of range.
|
| remove(self, value)
| S.remove(value) -- remove first occurrence of value.
| Raise ValueError if the value is not present.
|
| reverse(self)
| S.reverse() -- reverse *IN PLACE*
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Sequence:
|
| __reversed__(self)
|
| count(self, value)
| S.count(value) -> integer -- return number of occurrences of value
|
| index(self, value, start=0, stop=None)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
svgpathtools.QuadraticBezier
Python Library Documentation: class QuadraticBezier in module svgpathtools.path class QuadraticBezier(builtins.object) | QuadraticBezier(start, control, end) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, item) | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, control, end) | Initialize self. See help(type(self)) for accurate signature. | | __len__(self) | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | bbox(self) | returns the bounding box for the segment in the form | (xmin, xmax, ymin, ymax). | | bpoints(self) | returns the Bezier control points of the segment. | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the segment at t. | | derivative(self, t, n=1) | returns the nth derivative of the segment at t. | Note: Bezier curves can have points where their derivative vanishes. | If you are interested in the tangent direction, use the unit_tangent() | method instead. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Returns a float, t, such that self.length(0, t) is approximately s. | See the inv_arclength() docstring for more details. | | intersect(self, other_seg, tol=1e-12) | Finds the intersections of two segments. | returns a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | Note: This will fail if the two segments coincide for more than a | finite collection of points. | | is_smooth_from(self, previous, warning_on=True) | [Warning: The name of this method is somewhat misleading (yet kept | for compatibility with scripts created using svg.path 2.0). This | method is meant only for d string creation and should not be used to | check for kinks. To check a segment for differentiability, use the | joins_smoothly_with() method instead.] | | joins_smoothly_with(self, previous, wrt_parameterization=False, error=0) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=None, min_depth=None) | | normal(self, t) | returns the (right hand rule) unit normal vector to self at t. | | point(self, t) | returns the coordinates of the Bezier curve evaluated at t. | | points(self, ts) | Faster than running Path.point many times. | | poly(self, return_coeffs=False) | returns the quadratic as a Polynomial object. | | radialrange(self, origin, return_all_global_extrema=False) | returns the tuples (d_min, t_min) and (d_max, t_max) which minimize | and maximize, respectively, the distance d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the QuadraticBezier object with its orientation | reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | returns two segments, whose union is this segment and which join at | self.point(t). | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | unit_tangent(self, t) | returns the unit tangent vector of the segment at t (centered at | the origin and expressed as a complex number). If the tangent | vector's magnitude is zero, this method will find the limit of | self.derivative(tau)/abs(self.derivative(tau)) as tau approaches t. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.SVG_GROUP_TAG
Error rendering doc: No Python documentation found for 'svg:g'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
svgpathtools.SVG_NAMESPACE
Python Library Documentation: dict object
class dict(object)
| dict() -> new empty dictionary
| dict(mapping) -> new dictionary initialized from a mapping object's
| (key, value) pairs
| dict(iterable) -> new dictionary initialized as if via:
| d = {}
| for k, v in iterable:
| d[k] = v
| dict(**kwargs) -> new dictionary initialized with the name=value pairs
| in the keyword argument list. For example: dict(one=1, two=2)
|
| Built-in subclasses:
| StgDict
|
| Methods defined here:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
svgpathtools.SaxDocument
Python Library Documentation: class SaxDocument in module svgpathtools.svg_io_sax class SaxDocument(builtins.object) | SaxDocument(filename) | | Methods defined here: | | __init__(self, filename) | A container for a SAX SVG light tree objects document. | | This class provides functions for extracting SVG data into Path objects. | | Args: | filename (str): The filename of the SVG file | | display(self, filename=None) | Displays/opens the doc using the OS's default application. | | flatten_all_paths(self) | | generate_dom(self) | | get_pathd_and_matrix(self) | | save(self, filename) | | sax_parse(self, filename) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.bbox2path
Python Library Documentation: function bbox2path in module svgpathtools.path
bbox2path(xmin, xmax, ymin, ymax)
Converts a bounding box 4-tuple to a Path object.
svgpathtools.bezier2polynomial
Python Library Documentation: function bezier2polynomial in module svgpathtools.bezier
bezier2polynomial(p, numpy_ordering=True, return_poly1d=False)
Converts a tuple of Bezier control points to a tuple of coefficients
of the expanded polynomial.
return_poly1d : returns a numpy.poly1d object. This makes computations
of derivatives/anti-derivatives and many other operations quite quick.
numpy_ordering : By default (to accommodate numpy) the coefficients will
be output in reverse standard order.
svgpathtools.bezier_bounding_box
Python Library Documentation: function bezier_bounding_box in module svgpathtools.bezier
bezier_bounding_box(bez)
returns the bounding box for the segment in the form
(xmin, xmax, ymin, ymax).
Warning: For the non-cubic case this is not particularly efficient.
svgpathtools.bezier_by_line_intersections
Python Library Documentation: function bezier_by_line_intersections in module svgpathtools.bezier
bezier_by_line_intersections(bezier, line)
Returns tuples (t1,t2) such that bezier.point(t1) ~= line.point(t2).
svgpathtools.bezier_intersections
Python Library Documentation: function bezier_intersections in module svgpathtools.bezier
bezier_intersections(bez1, bez2, longer_length, tol=1e-08, tol_deC=1e-08)
INPUT:
bez1, bez2 = [P0,P1,P2,...PN], [Q0,Q1,Q2,...,PN] defining the two
Bezier curves to check for intersections between.
longer_length - the length (or an upper bound) on the longer of the two
Bezier curves. Determines the maximum iterations needed together with tol.
tol - is the smallest distance that two solutions can differ by and still
be considered distinct solutions.
OUTPUT: a list of tuples (t,s) in [0,1]x[0,1] such that
abs(bezier_point(bez1[0],t) - bezier_point(bez2[1],s)) < tol_deC
Note: This will return exactly one such tuple for each intersection
(assuming tol_deC is small enough).
svgpathtools.bezier_point
Python Library Documentation: function bezier_point in module svgpathtools.bezier
bezier_point(p, t)
Evaluates the Bezier curve given by it's control points, p, at t.
Note: Uses Horner's rule for cubic and lower order Bezier curves.
Warning: Be concerned about numerical stability when using this function
with high order curves.
svgpathtools.bezier_segment
Python Library Documentation: function bezier_segment in module svgpathtools.path bezier_segment(*bpoints)
svgpathtools.bpoints2bezier
Python Library Documentation: function bpoints2bezier in module svgpathtools.path
bpoints2bezier(bpoints)
Converts a list of length 2, 3, or 4 to a CubicBezier, QuadraticBezier,
or Line object, respectively.
See also: poly2bez.
svgpathtools.closest_point_in_path
Python Library Documentation: function closest_point_in_path in module svgpathtools.path
closest_point_in_path(pt, path)
returns (|path.seg.point(t)-pt|, t, seg_idx) where t and seg_idx
minimize the distance between pt and curve path[idx].point(t) for 0<=t<=1
and any seg_idx.
Warning: Multiple such global minima can exist. This will only return
one.
svgpathtools.concatpaths
Python Library Documentation: function concatpaths in module svgpathtools.path
concatpaths(list_of_paths)
Takes in a sequence of paths and returns their concatenations into a
single path (following the order of the input sequence).
svgpathtools.disvg
Python Library Documentation: function disvg in module svgpathtools.paths2svg
disvg(paths=None, colors=None, filename=None, stroke_widths=None, nodes=None, node_colors=None, node_radii=None, openinbrowser=True, timestamp=None, margin_size=0.1, mindim=600, dimensions=None, viewbox=None, text=None, text_path=None, font_size=None, attributes=None, svg_attributes=None, svgwrite_debug=False, paths2Drawing=False, baseunit='px')
Creates (and optionally displays) an SVG file.
REQUIRED INPUTS:
:param paths - a list of paths
OPTIONAL INPUT:
:param colors - specifies the path stroke color. By default all paths
will be black (#000000). This paramater can be input in a few ways
1) a list of strings that will be input into the path elements stroke
attribute (so anything that is understood by the svg viewer).
2) a string of single character colors -- e.g. setting colors='rrr' is
equivalent to setting colors=['red', 'red', 'red'] (see the
'color_dict' dictionary above for a list of possibilities).
3) a list of rgb 3-tuples -- e.g. colors = [(255, 0, 0), ...].
:param filename - the desired location/filename of the SVG file
created (by default the SVG will be named 'disvg_output.svg' or
'disvg_output_<timestamp>.svg' and stored in the temporary
directory returned by `tempfile.gettempdir()`. See `timestamp`
for information on the timestamp.
:param stroke_widths - a list of stroke_widths to use for paths
(default is 0.5% of the SVG's width or length)
:param nodes - a list of points to draw as filled-in circles
:param node_colors - a list of colors to use for the nodes (by default
nodes will be red)
:param node_radii - a list of radii to use for the nodes (by default
nodes will be radius will be 1 percent of the svg's width/length)
:param text - string or list of strings to be displayed
:param text_path - if text is a list, then this should be a list of
path (or path segments of the same length. Note: the path must be
long enough to display the text or the text will be cropped by the svg
viewer.
:param font_size - a single float of list of floats.
:param openinbrowser - Set to True to automatically open the created
SVG in the user's default web browser.
:param timestamp - if true, then the a timestamp will be
appended to the output SVG's filename. This is meant as a
workaround for issues related to rapidly opening multiple
SVGs in your browser using `disvg`. This defaults to true if
`filename is None` and false otherwise.
:param margin_size - The min margin (empty area framing the collection
of paths) size used for creating the canvas and background of the SVG.
:param mindim - The minimum dimension (height or width) of the output
SVG (default is 600).
:param dimensions - The (x,y) display dimensions of the output SVG.
I.e. this specifies the `width` and `height` SVG attributes. Note that
these also can be used to specify units other than pixels. Using this
will override the `mindim` parameter.
:param viewbox - This specifies the coordinated system used in the svg.
The SVG `viewBox` attribute works together with the the `height` and
`width` attrinutes. Using these three attributes allows for shifting
and scaling of the SVG canvas without changing the any values other
than those in `viewBox`, `height`, and `width`. `viewbox` should be
input as a 4-tuple, (min_x, min_y, width, height), or a string
"min_x min_y width height". Using this will override the `mindim`
parameter.
:param attributes - a list of dictionaries of attributes for the input
paths. Note: This will override any other conflicting settings.
:param svg_attributes - a dictionary of attributes for output svg.
:param svgwrite_debug - This parameter turns on/off `svgwrite`'s
debugging mode. By default svgwrite_debug=False. This increases
speed and also prevents `svgwrite` from raising of an error when not
all `svg_attributes` key-value pairs are understood.
:param paths2Drawing - If true, an `svgwrite.Drawing` object is
returned and no file is written. This `Drawing` can later be saved
using the `svgwrite.Drawing.save()` method.
NOTES:
* The `svg_attributes` parameter will override any other conflicting
settings.
* Any `extra` parameters that `svgwrite.Drawing()` accepts can be
controlled by passing them in through `svg_attributes`.
* The unit of length here is assumed to be pixels in all variables.
* If this function is used multiple times in quick succession to
display multiple SVGs (all using the default filename), the
svgviewer/browser will likely fail to load some of the SVGs in time.
To fix this, use the timestamp attribute, or give the files unique
names, or use a pause command (e.g. time.sleep(1)) between uses.
SEE ALSO:
* document.py
svgpathtools.farthest_point_in_path
Python Library Documentation: function farthest_point_in_path in module svgpathtools.path
farthest_point_in_path(pt, path)
returns (|path.seg.point(t)-pt|, t, seg_idx) where t and seg_idx
maximize the distance between pt and curve path[idx].point(t) for 0<=t<=1
and any seg_idx.
:rtype : object
:param pt:
:param path:
Warning: Multiple such global maxima can exist. This will only return
one.
svgpathtools.hex2rgb
Python Library Documentation: function hex2rgb in module svgpathtools.misctools
hex2rgb(value)
Converts a hexadeximal color string to an RGB 3-tuple
EXAMPLE
-------
>>> hex2rgb('#0000FF')
(0, 0, 255)
svgpathtools.imag
Python Library Documentation: function imag in module svgpathtools.polytools imag(z)
svgpathtools.is_bezier_path
Python Library Documentation: function is_bezier_path in module svgpathtools.path
is_bezier_path(path)
Checks that all segments in path are a Line, QuadraticBezier, or
CubicBezier object.
svgpathtools.is_bezier_segment
Python Library Documentation: function is_bezier_segment in module svgpathtools.path is_bezier_segment(seg)
svgpathtools.is_differentiable
Python Library Documentation: function is_differentiable in module svgpathtools.smoothing is_differentiable(path, tol=1e-08)
svgpathtools.is_path_segment
Python Library Documentation: function is_path_segment in module svgpathtools.path is_path_segment(seg)
svgpathtools.kinks
Python Library Documentation: function kinks in module svgpathtools.smoothing
kinks(path, tol=1e-08)
returns indices of segments that start on a non-differentiable joint.
svgpathtools.parse_path
Python Library Documentation: function parse_path in module svgpathtools.parser parse_path(pathdef, current_pos=0j, tree_element=None)
svgpathtools.path_encloses_pt
Python Library Documentation: function path_encloses_pt in module svgpathtools.path
path_encloses_pt(pt, opt, path)
returns true if pt is a point enclosed by path (which must be a Path
object satisfying path.isclosed==True). opt is a point you know is
NOT enclosed by path.
svgpathtools.paths2Drawing
Python Library Documentation: function paths2Drawing in module svgpathtools.paths2svg
paths2Drawing(paths=None, colors=None, filename=None, stroke_widths=None, nodes=None, node_colors=None, node_radii=None, openinbrowser=False, timestamp=False, margin_size=0.1, mindim=600, dimensions=None, viewbox=None, text=None, text_path=None, font_size=None, attributes=None, svg_attributes=None, svgwrite_debug=False, paths2Drawing=True, baseunit='px')
Create and return `svg.Drawing` object.
Note: This is identical to `disvg()` except that `paths2Drawing`
is true by default and an assertion error is raised if `filename
is None`.
See `disvg()` docstring for more info.
svgpathtools.poly2bez
Python Library Documentation: function poly2bez in module svgpathtools.path
poly2bez(poly, return_bpoints=False)
Converts a cubic or lower order Polynomial object (or a sequence of
coefficients) to a CubicBezier, QuadraticBezier, or Line object as
appropriate. If return_bpoints=True then this will instead only return
the control points of the corresponding Bezier curve.
Note: The inverse operation is available as a method of CubicBezier,
QuadraticBezier and Line objects.
svgpathtools.polygon
Python Library Documentation: function polygon in module svgpathtools.path
polygon(*points)
Converts a list of points to a Path composed of lines connecting those
points, then closes the path by connecting the last point to the first.
See also `polyline()`.
svgpathtools.polyline
Python Library Documentation: function polyline in module svgpathtools.path
polyline(*points)
Converts a list of points to a Path composed of lines connecting those
points (i.e. a linear spline or polyline). See also `polygon()`.
svgpathtools.polynomial2bezier
Python Library Documentation: function polynomial2bezier in module svgpathtools.bezier
polynomial2bezier(poly)
Converts a cubic or lower order Polynomial object (or a sequence of
coefficients) to a CubicBezier, QuadraticBezier, or Line object as
appropriate.
svgpathtools.polyroots
Python Library Documentation: function polyroots in module svgpathtools.polytools
polyroots(p, realroots=False, condition=<function <lambda> at 0x000001C63A7BA3E0>)
Returns the roots of a polynomial with coefficients given in p.
p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
INPUT:
p - Rank-1 array-like object of polynomial coefficients.
realroots - a boolean. If true, only real roots will be returned and the
condition function can be written assuming all roots are real.
condition - a boolean-valued function. Only roots satisfying this will be
returned. If realroots==True, these conditions should assume the roots
are real.
OUTPUT:
A list containing the roots of the polynomial.
NOTE: This uses np.isclose and np.roots
svgpathtools.polyroots01
Python Library Documentation: function polyroots01 in module svgpathtools.polytools
polyroots01(p)
Returns the real roots between 0 and 1 of the polynomial with
coefficients given in p,
p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
p can also be a np.poly1d object. See polyroots for more information.
svgpathtools.rational_limit
Python Library Documentation: function rational_limit in module svgpathtools.polytools
rational_limit(f, g, t0)
Computes the limit of the rational function (f/g)(t)
as t approaches t0.
svgpathtools.real
Python Library Documentation: function real in module svgpathtools.polytools real(z)
svgpathtools.rgb2hex
Python Library Documentation: function rgb2hex in module svgpathtools.misctools
rgb2hex(rgb)
Converts an RGB 3-tuple to a hexadeximal color string.
EXAMPLE
-------
>>> rgb2hex((0,0,255))
'#0000FF'
svgpathtools.smoothed_joint
Python Library Documentation: function smoothed_joint in module svgpathtools.smoothing
smoothed_joint(seg0, seg1, maxjointsize=3, tightness=1.99)
See Andy's notes on
Smoothing Bezier Paths for an explanation of the method.
Input: two segments seg0, seg1 such that seg0.end==seg1.start, and
jointsize, a positive number
Output: seg0_trimmed, elbow, seg1_trimmed, where elbow is a cubic bezier
object that smoothly connects seg0_trimmed and seg1_trimmed.
svgpathtools.smoothed_path
Python Library Documentation: function smoothed_path in module svgpathtools.smoothing
smoothed_path(path, maxjointsize=3, tightness=1.99, ignore_unfixable_kinks=False)
returns a path with no non-differentiable joints.
svgpathtools.split_bezier
Python Library Documentation: function split_bezier in module svgpathtools.bezier
split_bezier(bpoints, t)
Uses deCasteljau's recursion to split the Bezier curve at t into two
Bezier curves of the same order.
svgpathtools.svg2paths
Python Library Documentation: function svg2paths in module svgpathtools.svg_to_paths
svg2paths(svg_file_location, return_svg_attributes=False, convert_circles_to_paths=True, convert_ellipses_to_paths=True, convert_lines_to_paths=True, convert_polylines_to_paths=True, convert_polygons_to_paths=True, convert_rectangles_to_paths=True)
Converts an SVG into a list of Path objects and attribute dictionaries.
Converts an SVG file into a list of Path objects and a list of
dictionaries containing their attributes. This currently supports
SVG Path, Line, Polyline, Polygon, Circle, and Ellipse elements.
Args:
svg_file_location (string or file-like object): the location of the
svg file on disk or a file-like object containing the content of a
svg file
return_svg_attributes (bool): Set to True and a dictionary of
svg-attributes will be extracted and returned. See also the
`svg2paths2()` function.
convert_circles_to_paths: Set to False to exclude SVG-Circle
elements (converted to Paths). By default circles are included as
paths of two `Arc` objects.
convert_ellipses_to_paths (bool): Set to False to exclude SVG-Ellipse
elements (converted to Paths). By default ellipses are included as
paths of two `Arc` objects.
convert_lines_to_paths (bool): Set to False to exclude SVG-Line elements
(converted to Paths)
convert_polylines_to_paths (bool): Set to False to exclude SVG-Polyline
elements (converted to Paths)
convert_polygons_to_paths (bool): Set to False to exclude SVG-Polygon
elements (converted to Paths)
convert_rectangles_to_paths (bool): Set to False to exclude SVG-Rect
elements (converted to Paths).
Returns:
list: The list of Path objects.
list: The list of corresponding path attribute dictionaries.
dict (optional): A dictionary of svg-attributes (see `svg2paths2()`).
svgpathtools.svg2paths2
Python Library Documentation: function svg2paths2 in module svgpathtools.svg_to_paths
svg2paths2(svg_file_location, return_svg_attributes=True, convert_circles_to_paths=True, convert_ellipses_to_paths=True, convert_lines_to_paths=True, convert_polylines_to_paths=True, convert_polygons_to_paths=True, convert_rectangles_to_paths=True)
Convenience function; identical to svg2paths() except that
return_svg_attributes=True by default. See svg2paths() docstring for more
info.
svgpathtools.svgstr2paths
Python Library Documentation: function svgstr2paths in module svgpathtools.svg_to_paths
svgstr2paths(svg_string, return_svg_attributes=False, convert_circles_to_paths=True, convert_ellipses_to_paths=True, convert_lines_to_paths=True, convert_polylines_to_paths=True, convert_polygons_to_paths=True, convert_rectangles_to_paths=True)
Convenience function; identical to svg2paths() except that it takes the
svg object as string. See svg2paths() docstring for more
info.
svgpathtools.wsvg
Python Library Documentation: function wsvg in module svgpathtools.paths2svg
wsvg(paths=None, colors=None, filename=None, stroke_widths=None, nodes=None, node_colors=None, node_radii=None, openinbrowser=False, timestamp=False, margin_size=0.1, mindim=600, dimensions=None, viewbox=None, text=None, text_path=None, font_size=None, attributes=None, svg_attributes=None, svgwrite_debug=False, paths2Drawing=False, baseunit='px')
Create SVG and write to disk.
Note: This is identical to `disvg()` except that `openinbrowser`
is false by default and an assertion error is raised if `filename
is None`.
See `disvg()` docstring for more info.
svgpathtools.path.Arc
Python Library Documentation: class Arc in module svgpathtools.path class Arc(builtins.object) | Arc(start, radius, rotation, large_arc, sweep, end, autoscale_radius=True) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, radius, rotation, large_arc, sweep, end, autoscale_radius=True) | This should be thought of as a part of an ellipse connecting two | points on that ellipse, start and end. | Parameters | ---------- | start : complex | The start point of the curve. Note: `start` and `end` cannot be the | same. To make a full ellipse or circle, use two `Arc` objects. | radius : complex | rx + 1j*ry, where rx and ry are the radii of the ellipse (also | known as its semi-major and semi-minor axes, or vice-versa or if | rx < ry). | Note: If rx = 0 or ry = 0 then this arc is treated as a | straight line segment joining the endpoints. | Note: If rx or ry has a negative sign, the sign is dropped; the | absolute value is used instead. | Note: If no such ellipse exists, the radius will be scaled so | that one does (unless autoscale_radius is set to False). | rotation : float | This is the CCW angle (in degrees) from the positive x-axis of the | current coordinate system to the x-axis of the ellipse. | large_arc : bool | Given two points on an ellipse, there are two elliptical arcs | connecting those points, the first going the short way around the | ellipse, and the second going the long way around the ellipse. If | `large_arc == False`, the shorter elliptical arc will be used. If | `large_arc == True`, then longer elliptical will be used. | In other words, `large_arc` should be 0 for arcs spanning less than | or equal to 180 degrees and 1 for arcs spanning greater than 180 | degrees. | sweep : bool | For any acceptable parameters `start`, `end`, `rotation`, and | `radius`, there are two ellipses with the given major and minor | axes (radii) which connect `start` and `end`. One which connects | them in a CCW fashion and one which connected them in a CW | fashion. If `sweep == True`, the CCW ellipse will be used. If | `sweep == False`, the CW ellipse will be used. See note on curve | orientation below. | end : complex | The end point of the curve. Note: `start` and `end` cannot be the | same. To make a full ellipse or circle, use two `Arc` objects. | autoscale_radius : bool | If `autoscale_radius == True`, then will also scale `self.radius` | in the case that no ellipse exists with the input parameters | (see inline comments for further explanation). | | Derived Parameters/Attributes | ----------------------------- | self.theta : float | This is the phase (in degrees) of self.u1transform(self.start). | It is $\theta_1$ in the official documentation and ranges from | -180 to 180. | self.delta : float | This is the angular distance (in degrees) between the start and | end of the arc after the arc has been sent to the unit circle | through self.u1transform(). | It is $\Delta\theta$ in the official documentation and ranges from | -360 to 360; being positive when the arc travels CCW and negative | otherwise (i.e. is positive/negative when sweep == True/False). | self.center : complex | This is the center of the arc's ellipse. | self.phi : float | The arc's rotation in radians, i.e. `radians(self.rotation)`. | self.rot_matrix : complex | Equal to `exp(1j * self.phi)` which is also equal to | `cos(self.phi) + 1j*sin(self.phi)`. | | | Note on curve orientation (CW vs CCW) | ------------------------------------- | The notions of clockwise (CW) and counter-clockwise (CCW) are reversed | in some sense when viewing SVGs (as the y coordinate starts at the top | of the image and increases towards the bottom). | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | apoints(self) -> 'tuple[complex, complex, float, bool, bool, complex]' | Analog of the Bezier path method, .bpoints(), for Arc objects. | | as_cubic_curves(self, curves=1) | Generates cubic curves to approximate this arc | | as_quad_curves(self, curves=1) | Generates quadratic curves to approximate this arc | | bbox(self) | returns a bounding box for the segment in the form | (xmin, xmax, ymin, ymax). | | centeriso(self, z) | Isometry to a centered aligned ellipse. | | This is an isometry that shifts and rotates `self`'s underlying | ellipse so that it's centered on the origin and has its axes | aligned with the xy-axes. | | Args: | z (:obj:`complex` or :obj:`numpy.ndarray[complex]`): a point | to send through the above-described isometry. | | Returns: | (:obj:`complex` or :obj:`numpy.ndarray[complex]`) The point(s) f(z), | where f is the above described isometry of the xy-plane (i.e. | the one-dimensional complex plane). | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the segment at t. | | derivative(self, t, n=1) | returns the nth derivative of the segment at t. | | icenteriso(self, zeta) | The inverse of the `centeriso()` method. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Approximates the unique `t` such that self.length(0, t) = s. | | Args: | s (float): A length between 0 and `self.length()`. | | Returns: | (float) The t, such that self.length(0, t) is approximately s. | | For more info: | See the inv_arclength() docstring. | | intersect(self, other_seg, tol=1e-12) | NOT FULLY IMPLEMENTED. Finds the intersections of two segments. | returns a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | Note: This will fail if the two segments coincide for more than a | finite collection of points. | | Note: Arc related intersections are only partially supported, i.e. are | only half-heartedly implemented and not well tested. Please feel free | to let me know if you're interested in such a feature -- or even better | please submit an implementation if you want to code one. | | iu1transform(self, zeta) | The inverse of the `u1transform()` method. | | joins_smoothly_with(self, previous, wrt_parameterization=False, error=0) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=1e-12, min_depth=5) | Computes the length of the Arc segment, `self`, from t0 to t1. | | Notes: | * The length of an elliptical large_arc segment requires numerical | integration, and in that case it's simpler to just do a geometric | approximation, as for cubic bezier curves. | | normal(self, t) | returns the (right hand rule) unit normal vector to self at t. | | phase2t(self, psi) | Converts phase to t-value. | | I.e. given phase, psi, such that -np.pi < psi <= np.pi, approximates | the unique t-value such that `self.u1transform(self.point(t))` equals | `np.exp(1j*psi)`. | | Args: | psi (float): The phase in radians. | | Returns: | (float): the corresponding t-value. | | point(self, t) | | point_to_t(self, point) | If the point lies on the Arc, returns its `t` parameter. | If the point does not lie on the Arc, returns None. | This function only works on Arcs with rotation == 0.0 | | radialrange(self, origin, return_all_global_extrema=False) | returns the tuples (d_min, t_min) and (d_max, t_max) which minimize | and maximize, respectively, the distance, | d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the Arc object with its orientation reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | returns two segments, whose union is this segment and which join | at self.point(t). | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | u1transform(self, z) | Similar to the `centeriso()` method, but maps to the unit circle. | | unit_tangent(self, t) | returns the unit tangent vector of the segment at t (centered at | the origin and expressed as a complex number). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.path.BugException
Python Library Documentation: Exception object class Exception(BaseException) | Common base class for all non-exit exceptions. | | Method resolution order: | Exception | BaseException | object | | Built-in subclasses: | ArithmeticError | AssertionError | AttributeError | BufferError | ... and 16 other subclasses | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
svgpathtools.path.CLOSED_WARNING_ON
Python Library Documentation: bool object class bool(int) | bool(x) -> bool | | Returns True when the argument x is true, False otherwise. | The builtins True and False are the only two instances of the class bool. | The class bool is a subclass of the class int, and cannot be subclassed. | | Method resolution order: | bool | int | object | | Methods defined here: | | __and__(self, value, /) | Return self&value. | | __invert__(self, /) | ~self | | __or__(self, value, /) | Return self|value. | | __rand__(self, value, /) | Return value&self. | | __repr__(self, /) | Return repr(self). | | __ror__(self, value, /) | Return value|self. | | __rxor__(self, value, /) | Return value^self. | | __xor__(self, value, /) | Return self^value. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from int: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __bool__(self, /) | True if self else False | | __ceil__(...) | Ceiling of an Integral returns itself. | | __divmod__(self, value, /) | Return divmod(self, value). | | __eq__(self, value, /) | Return self==value. | | __float__(self, /) | float(self) | | __floor__(...) | Flooring an Integral returns itself. | | __floordiv__(self, value, /) | Return self//value. | | __format__(self, format_spec, /) | Convert to a string according to format_spec. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getnewargs__(self, /) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __index__(self, /) | Return self converted to an integer, if self is suitable for use as an index into a list. | | __int__(self, /) | int(self) | | __le__(self, value, /) | Return self<=value. | | __lshift__(self, value, /) | Return self<<value. | | __lt__(self, value, /) | Return self<value. | | __mod__(self, value, /) | Return self%value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __neg__(self, /) | -self | | __pos__(self, /) | +self | | __pow__(self, value, mod=None, /) | Return pow(self, value, mod). | | __radd__(self, value, /) | Return value+self. | | __rdivmod__(self, value, /) | Return divmod(value, self). | | __rfloordiv__(self, value, /) | Return value//self. | | __rlshift__(self, value, /) | Return value<<self. | | __rmod__(self, value, /) | Return value%self. | | __rmul__(self, value, /) | Return value*self. | | __round__(...) | Rounding an Integral returns itself. | | Rounding with an ndigits argument also returns an integer. | | __rpow__(self, value, mod=None, /) | Return pow(value, self, mod). | | __rrshift__(self, value, /) | Return value>>self. | | __rshift__(self, value, /) | Return self>>value. | | __rsub__(self, value, /) | Return value-self. | | __rtruediv__(self, value, /) | Return value/self. | | __sizeof__(self, /) | Returns size in memory, in bytes. | | __sub__(self, value, /) | Return self-value. | | __truediv__(self, value, /) | Return self/value. | | __trunc__(...) | Truncating an Integral returns itself. | | as_integer_ratio(self, /) | Return a pair of integers, whose ratio is equal to the original int. | | The ratio is in lowest terms and has a positive denominator. | | >>> (10).as_integer_ratio() | (10, 1) | >>> (-10).as_integer_ratio() | (-10, 1) | >>> (0).as_integer_ratio() | (0, 1) | | bit_count(self, /) | Number of ones in the binary representation of the absolute value of self. | | Also known as the population count. | | >>> bin(13) | '0b1101' | >>> (13).bit_count() | 3 | | bit_length(self, /) | Number of bits necessary to represent self in binary. | | >>> bin(37) | '0b100101' | >>> (37).bit_length() | 6 | | conjugate(...) | Returns self, the complex conjugate of any int. | | is_integer(self, /) | Returns True. Exists for duck type compatibility with float.is_integer. | | to_bytes(self, /, length=1, byteorder='big', *, signed=False) | Return an array of bytes representing an integer. | | length | Length of bytes object to use. An OverflowError is raised if the | integer is not representable with the given number of bytes. Default | is length 1. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Determines whether two's complement is used to represent the integer. | If signed is False and a negative integer is given, an OverflowError | is raised. | | ---------------------------------------------------------------------- | Class methods inherited from int: | | from_bytes(bytes, byteorder='big', *, signed=False) | Return the integer represented by the given array of bytes. | | bytes | Holds the array of bytes to convert. The argument must either | support the buffer protocol or be an iterable object producing bytes. | Bytes and bytearray are examples of built-in objects that support the | buffer protocol. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Indicates whether two's complement is used to represent the integer. | | ---------------------------------------------------------------------- | Data descriptors inherited from int: | | denominator | the denominator of a rational number in lowest terms | | imag | the imaginary part of a complex number | | numerator | the numerator of a rational number in lowest terms | | real | the real part of a complex number
svgpathtools.path.COMMANDS
Python Library Documentation: set object class set(object) | set() -> new empty set object | set(iterable) -> new set object | | Build an unordered collection of unique elements. | | Methods defined here: | | __and__(self, value, /) | Return self&value. | | __contains__(...) | x.__contains__(y) <==> y in x. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __gt__(self, value, /) | Return self>value. | | __iand__(self, value, /) | Return self&=value. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __ior__(self, value, /) | Return self|=value. | | __isub__(self, value, /) | Return self-=value. | | __iter__(self, /) | Implement iter(self). | | __ixor__(self, value, /) | Return self^=value. | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __ne__(self, value, /) | Return self!=value. | | __or__(self, value, /) | Return self|value. | | __rand__(self, value, /) | Return value&self. | | __reduce__(...) | Return state information for pickling. | | __repr__(self, /) | Return repr(self). | | __ror__(self, value, /) | Return value|self. | | __rsub__(self, value, /) | Return value-self. | | __rxor__(self, value, /) | Return value^self. | | __sizeof__(...) | S.__sizeof__() -> size of S in memory, in bytes | | __sub__(self, value, /) | Return self-value. | | __xor__(self, value, /) | Return self^value. | | add(...) | Add an element to a set. | | This has no effect if the element is already present. | | clear(...) | Remove all elements from this set. | | copy(...) | Return a shallow copy of a set. | | difference(...) | Return the difference of two or more sets as a new set. | | (i.e. all elements that are in this set but not the others.) | | difference_update(...) | Remove all elements of another set from this set. | | discard(...) | Remove an element from a set if it is a member. | | Unlike set.remove(), the discard() method does not raise | an exception when an element is missing from the set. | | intersection(...) | Return the intersection of two sets as a new set. | | (i.e. all elements that are in both sets.) | | intersection_update(...) | Update a set with the intersection of itself and another. | | isdisjoint(...) | Return True if two sets have a null intersection. | | issubset(self, other, /) | Test whether every element in the set is in other. | | issuperset(self, other, /) | Test whether every element in other is in the set. | | pop(...) | Remove and return an arbitrary set element. | Raises KeyError if the set is empty. | | remove(...) | Remove an element from a set; it must be a member. | | If the element is not a member, raise a KeyError. | | symmetric_difference(...) | Return the symmetric difference of two sets as a new set. | | (i.e. all elements that are in exactly one of the sets.) | | symmetric_difference_update(...) | Update a set with the symmetric difference of itself and another. | | union(...) | Return the union of sets as a new set. | | (i.e. all elements that are in either set.) | | update(...) | Update a set with the union of itself and others. | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None
svgpathtools.path.COMMAND_RE
Python Library Documentation: Pattern in module re object class Pattern(builtins.object) | Compiled regular expression object. | | Methods defined here: | | __copy__(self, /) | | __deepcopy__(self, memo, /) | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __le__(self, value, /) | Return self<=value. | | __lt__(self, value, /) | Return self<value. | | __ne__(self, value, /) | Return self!=value. | | __repr__(self, /) | Return repr(self). | | findall(self, /, string, pos=0, endpos=9223372036854775807) | Return a list of all non-overlapping matches of pattern in string. | | finditer(self, /, string, pos=0, endpos=9223372036854775807) | Return an iterator over all non-overlapping matches for the RE pattern in string. | | For each match, the iterator returns a match object. | | fullmatch(self, /, string, pos=0, endpos=9223372036854775807) | Matches against all of the string. | | match(self, /, string, pos=0, endpos=9223372036854775807) | Matches zero or more characters at the beginning of the string. | | scanner(self, /, string, pos=0, endpos=9223372036854775807) | | search(self, /, string, pos=0, endpos=9223372036854775807) | Scan through string looking for a match, and return a corresponding match object instance. | | Return None if no position in the string matches. | | split(self, /, string, maxsplit=0) | Split string by the occurrences of pattern. | | sub(self, /, repl, string, count=0) | Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. | | subn(self, /, repl, string, count=0) | Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl. | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Data descriptors defined here: | | flags | The regex matching flags. | | groupindex | A dictionary mapping group names to group numbers. | | groups | The number of capturing groups in the pattern. | | pattern | The pattern string from which the RE object was compiled.
svgpathtools.path.CubicBezier
Python Library Documentation: class CubicBezier in module svgpathtools.path class CubicBezier(builtins.object) | CubicBezier(start, control1, control2, end) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, item) | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, control1, control2, end) | Initialize self. See help(type(self)) for accurate signature. | | __len__(self) | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | bbox(self) | returns bounding box in format (xmin, xmax, ymin, ymax). | | bpoints(self) | returns the Bezier control points of the segment. | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the segment at t. | | derivative(self, t, n=1) | returns the nth derivative of the segment at t. | Note: Bezier curves can have points where their derivative vanishes. | If you are interested in the tangent direction, use the unit_tangent() | method instead. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Returns a float, t, such that self.length(0, t) is approximately s. | See the inv_arclength() docstring for more details. | | intersect(self, other_seg, tol=1e-12) | Finds the intersections of two segments. | | Returns: | (list[tuple[float]]) a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | | Scope: | This will fail if the two segments coincide for more than a | finite collection of points. | | is_smooth_from(self, previous, warning_on=True) | [Warning: The name of this method is somewhat misleading (yet kept | for compatibility with scripts created using svg.path 2.0). This | method is meant only for d string creation and should not be used to | check for kinks. To check a segment for differentiability, use the | joins_smoothly_with() method instead.] | | joins_smoothly_with(self, previous, wrt_parameterization=False) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=1e-12, min_depth=5) | Calculate the length of the path up to a certain position | | normal(self, t) | returns the (right hand rule) unit normal vector to self at t. | | point(self, t) | Evaluate the cubic Bezier curve at t using Horner's rule. | | points(self, ts) | Faster than running Path.point many times. | | poly(self, return_coeffs=False) | Returns a the cubic as a Polynomial object. | | radialrange(self, origin, return_all_global_extrema=False) | returns the tuples (d_min, t_min) and (d_max, t_max) which minimize | and maximize, respectively, the distance d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the CubicBezier object with its orientation | reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | Splits a copy of `self` at t and returns the two subsegments. | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | unit_tangent(self, t) | returns the unit tangent vector of the segment at t (centered at | the origin and expressed as a complex number). If the tangent | vector's magnitude is zero, this method will find the limit of | self.derivative(tau)/abs(self.derivative(tau)) as tau approaches t. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.path.FLOAT_RE
Python Library Documentation: Pattern in module re object class Pattern(builtins.object) | Compiled regular expression object. | | Methods defined here: | | __copy__(self, /) | | __deepcopy__(self, memo, /) | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __le__(self, value, /) | Return self<=value. | | __lt__(self, value, /) | Return self<value. | | __ne__(self, value, /) | Return self!=value. | | __repr__(self, /) | Return repr(self). | | findall(self, /, string, pos=0, endpos=9223372036854775807) | Return a list of all non-overlapping matches of pattern in string. | | finditer(self, /, string, pos=0, endpos=9223372036854775807) | Return an iterator over all non-overlapping matches for the RE pattern in string. | | For each match, the iterator returns a match object. | | fullmatch(self, /, string, pos=0, endpos=9223372036854775807) | Matches against all of the string. | | match(self, /, string, pos=0, endpos=9223372036854775807) | Matches zero or more characters at the beginning of the string. | | scanner(self, /, string, pos=0, endpos=9223372036854775807) | | search(self, /, string, pos=0, endpos=9223372036854775807) | Scan through string looking for a match, and return a corresponding match object instance. | | Return None if no position in the string matches. | | split(self, /, string, maxsplit=0) | Split string by the occurrences of pattern. | | sub(self, /, repl, string, count=0) | Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. | | subn(self, /, repl, string, count=0) | Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl. | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Data descriptors defined here: | | flags | The regex matching flags. | | groupindex | A dictionary mapping group names to group numbers. | | groups | The number of capturing groups in the pattern. | | pattern | The pattern string from which the RE object was compiled.
svgpathtools.path.ILENGTH_ERROR
Python Library Documentation: float object
class float(object)
| float(x=0, /)
|
| Convert a string or number to a floating-point number, if possible.
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(self, /)
| Return the ceiling as an Integral.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(self, /)
| Return the floor as an Integral.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Formats the float according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(self, ndigits=None, /)
| Return the Integral closest to x, rounding half toward even.
|
| When an argument is passed, work like built-in round(x, ndigits).
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(self, /)
| Return the Integral closest to x between 0 and x.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is exactly equal to the original float.
|
| The ratio is in lowest terms and has a positive denominator. Raise
| OverflowError on infinities and a ValueError on NaNs.
|
| >>> (10.0).as_integer_ratio()
| (10, 1)
| >>> (0.0).as_integer_ratio()
| (0, 1)
| >>> (-.25).as_integer_ratio()
| (-1, 4)
|
| conjugate(self, /)
| Return self, the complex conjugate of any float.
|
| hex(self, /)
| Return a hexadecimal representation of a floating-point number.
|
| >>> (-0.1).hex()
| '-0x1.999999999999ap-4'
| >>> 3.14159.hex()
| '0x1.921f9f01b866ep+1'
|
| is_integer(self, /)
| Return True if the float is an integer.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __getformat__(typestr, /)
| You probably don't want to use this function.
|
| typestr
| Must be 'double' or 'float'.
|
| It exists mainly to be used in Python's test suite.
|
| This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
| little-endian' best describes the format of floating-point numbers used by the
| C type named by typestr.
|
| fromhex(string, /)
| Create a floating-point number from a hexadecimal string.
|
| >>> float.fromhex('0x1.ffffp10')
| 2047.984375
| >>> float.fromhex('-0x1p-1074')
| -5e-324
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| imag
| the imaginary part of a complex number
|
| real
| the real part of a complex number
svgpathtools.path.ILENGTH_MAXITS
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
svgpathtools.path.ILENGTH_MIN_DEPTH
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
svgpathtools.path.ILENGTH_S_TOL
Python Library Documentation: float object
class float(object)
| float(x=0, /)
|
| Convert a string or number to a floating-point number, if possible.
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(self, /)
| Return the ceiling as an Integral.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(self, /)
| Return the floor as an Integral.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Formats the float according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(self, ndigits=None, /)
| Return the Integral closest to x, rounding half toward even.
|
| When an argument is passed, work like built-in round(x, ndigits).
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(self, /)
| Return the Integral closest to x between 0 and x.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is exactly equal to the original float.
|
| The ratio is in lowest terms and has a positive denominator. Raise
| OverflowError on infinities and a ValueError on NaNs.
|
| >>> (10.0).as_integer_ratio()
| (10, 1)
| >>> (0.0).as_integer_ratio()
| (0, 1)
| >>> (-.25).as_integer_ratio()
| (-1, 4)
|
| conjugate(self, /)
| Return self, the complex conjugate of any float.
|
| hex(self, /)
| Return a hexadecimal representation of a floating-point number.
|
| >>> (-0.1).hex()
| '-0x1.999999999999ap-4'
| >>> 3.14159.hex()
| '0x1.921f9f01b866ep+1'
|
| is_integer(self, /)
| Return True if the float is an integer.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __getformat__(typestr, /)
| You probably don't want to use this function.
|
| typestr
| Must be 'double' or 'float'.
|
| It exists mainly to be used in Python's test suite.
|
| This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
| little-endian' best describes the format of floating-point numbers used by the
| C type named by typestr.
|
| fromhex(string, /)
| Create a floating-point number from a hexadecimal string.
|
| >>> float.fromhex('0x1.ffffp10')
| 2047.984375
| >>> float.fromhex('-0x1p-1074')
| -5e-324
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| imag
| the imaginary part of a complex number
|
| real
| the real part of a complex number
svgpathtools.path.LENGTH_ERROR
Python Library Documentation: float object
class float(object)
| float(x=0, /)
|
| Convert a string or number to a floating-point number, if possible.
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(self, /)
| Return the ceiling as an Integral.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(self, /)
| Return the floor as an Integral.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Formats the float according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(self, ndigits=None, /)
| Return the Integral closest to x, rounding half toward even.
|
| When an argument is passed, work like built-in round(x, ndigits).
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(self, /)
| Return the Integral closest to x between 0 and x.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is exactly equal to the original float.
|
| The ratio is in lowest terms and has a positive denominator. Raise
| OverflowError on infinities and a ValueError on NaNs.
|
| >>> (10.0).as_integer_ratio()
| (10, 1)
| >>> (0.0).as_integer_ratio()
| (0, 1)
| >>> (-.25).as_integer_ratio()
| (-1, 4)
|
| conjugate(self, /)
| Return self, the complex conjugate of any float.
|
| hex(self, /)
| Return a hexadecimal representation of a floating-point number.
|
| >>> (-0.1).hex()
| '-0x1.999999999999ap-4'
| >>> 3.14159.hex()
| '0x1.921f9f01b866ep+1'
|
| is_integer(self, /)
| Return True if the float is an integer.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __getformat__(typestr, /)
| You probably don't want to use this function.
|
| typestr
| Must be 'double' or 'float'.
|
| It exists mainly to be used in Python's test suite.
|
| This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
| little-endian' best describes the format of floating-point numbers used by the
| C type named by typestr.
|
| fromhex(string, /)
| Create a floating-point number from a hexadecimal string.
|
| >>> float.fromhex('0x1.ffffp10')
| 2047.984375
| >>> float.fromhex('-0x1p-1074')
| -5e-324
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| imag
| the imaginary part of a complex number
|
| real
| the real part of a complex number
svgpathtools.path.LENGTH_MIN_DEPTH
Python Library Documentation: int object
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating-point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Built-in subclasses:
| bool
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __and__(self, value, /)
| Return self&value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Convert to a string according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __or__(self, value, /)
| Return self|value.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
svgpathtools.path.Line
Python Library Documentation: class Line in module svgpathtools.path class Line(builtins.object) | Line(start, end) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, item) | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, end) | Initialize self. See help(type(self)) for accurate signature. | | __len__(self) | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | bbox(self) | returns the bounding box for the segment in the form | (xmin, xmax, ymin, ymax). | | bpoints(self) | returns the Bezier control points of the segment. | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the line, which is always zero. | | derivative(self, t=None, n=1) | returns the nth derivative of the segment at t. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Returns a float, t, such that self.length(0, t) is approximately s. | See the inv_arclength() docstring for more details. | | intersect(self, other_seg, tol=None) | Finds the intersections of two segments. | returns a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | Note: This will fail if the two segments coincide for more than a | finite collection of points. | tol is not used. | | joins_smoothly_with(self, previous, wrt_parameterization=False) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=None, min_depth=None) | returns the length of the line segment between t0 and t1. | | normal(self, t=None) | returns the (right hand rule) unit normal vector to self at t. | | point(self, t) | returns the coordinates of the Bezier curve evaluated at t. | | point_to_t(self, point) | If the point lies on the Line, returns its `t` parameter. | If the point does not lie on the Line, returns None. | | points(self, ts) | Faster than running Path.point many times. | | poly(self, return_coeffs=False) | returns the line as a Polynomial object. | | radialrange(self, origin, **kwargs) | compute points in self that are min and max distance to origin. | | Args: | origin (complex): the point extremize distance to | | Returns: | tuples (d_min, t_min) and (d_max, t_max) which minimize and | maximize, respectively, the distance d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the Line object with its orientation reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | returns two segments, whose union is this segment and which join at | self.point(t). | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | unit_tangent(self, t=None) | returns the unit tangent of the segment at t. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.path.MutableSequence
Python Library Documentation: class MutableSequence in module collections.abc
class MutableSequence(Sequence)
| All the operations on a read-write sequence.
|
| Concrete subclasses must provide __new__ or __init__,
| __getitem__, __setitem__, __delitem__, __len__, and insert().
|
| Method resolution order:
| MutableSequence
| Sequence
| Reversible
| Collection
| Sized
| Iterable
| Container
| builtins.object
|
| Methods defined here:
|
| __delitem__(self, index)
|
| __iadd__(self, values)
|
| __setitem__(self, index, value)
|
| append(self, value)
| S.append(value) -- append value to the end of the sequence
|
| clear(self)
| S.clear() -> None -- remove all items from S
|
| extend(self, values)
| S.extend(iterable) -- extend sequence by appending elements from the iterable
|
| insert(self, index, value)
| S.insert(index, value) -- insert value before index
|
| pop(self, index=-1)
| S.pop([index]) -> item -- remove and return item at index (default last).
| Raise IndexError if list is empty or index is out of range.
|
| remove(self, value)
| S.remove(value) -- remove first occurrence of value.
| Raise ValueError if the value is not present.
|
| reverse(self)
| S.reverse() -- reverse *IN PLACE*
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'__delitem__', '__getitem__', '__len_...
|
| ----------------------------------------------------------------------
| Methods inherited from Sequence:
|
| __contains__(self, value)
|
| __getitem__(self, index)
|
| __iter__(self)
|
| __reversed__(self)
|
| count(self, value)
| S.count(value) -> integer -- return number of occurrences of value
|
| index(self, value, start=0, stop=None)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| ----------------------------------------------------------------------
| Class methods inherited from Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Methods inherited from Sized:
|
| __len__(self)
|
| ----------------------------------------------------------------------
| Class methods inherited from Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
svgpathtools.path.Path
Python Library Documentation: class Path in module svgpathtools.path
class Path(collections.abc.MutableSequence)
| Path(*segments, **kw)
|
| A Path is a sequence of path segments
|
| Method resolution order:
| Path
| collections.abc.MutableSequence
| collections.abc.Sequence
| collections.abc.Reversible
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| T2t(self, T)
| returns the segment index, `seg_idx`, and segment parameter, `t`,
| corresponding to the path parameter `T`. In other words, this is the
| inverse of the `Path.t2T()` method.
|
| __contains__(self, x)
|
| __delitem__(self, index)
|
| __eq__(self, other)
| Return self==value.
|
| __getitem__(self, index)
|
| __hash__(self) -> 'int'
| Return hash(self).
|
| __init__(self, *segments, **kw)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
|
| __len__(self)
|
| __ne__(self, other)
| Return self!=value.
|
| __repr__(self)
| Return repr(self).
|
| __setitem__(self, index, value)
|
| approximate_arcs_with_cubics(self, error=0.1)
| Iterates through this path and replaces any Arcs with cubic bezier curves.
|
| approximate_arcs_with_quads(self, error=0.1)
| Iterates through this path and replaces any Arcs with quadratic bezier curves.
|
| area(self, chord_length=0.0001)
| Find area enclosed by path.
|
| Approximates any Arc segments in the Path with lines
| approximately `chord_length` long, and returns the area enclosed
| by the approximated Path. Default chord length is 0.01. If Arc
| segments are included in path, to ensure accurate results, make
| sure this `chord_length` is set to a reasonable value (e.g. by
| checking curvature).
|
| Notes
| -----
| * Negative area results from clockwise (as opposed to
| counter-clockwise) parameterization of the input Path.
|
| To Contributors
| ---------------
| This is one of many parts of `svgpathtools` that could be
| improved by a noble soul implementing a piecewise-linear
| approximation scheme for paths (one with controls to guarantee a
| desired accuracy).
|
| bbox(self)
| returns bounding box in the form (xmin, xmax, ymin, ymax).
|
| continuous_subpaths(self)
| Breaks self into its continuous components, returning a list of
| continuous subpaths.
| I.e.
| (all(subpath.iscontinuous() for subpath in self.continuous_subpaths())
| and self == concatpaths(self.continuous_subpaths()))
| )
|
| cropped(self, T0, T1)
| returns a cropped copy of the path.
|
| curvature(self, T)
| returns the curvature of this Path object at T and outputs
| float('inf') if not differentiable at T.
|
| d(self, useSandT=False, use_closed_attrib=False, rel=False)
| Returns a path d-string for the path object.
| For an explanation of useSandT and use_closed_attrib, see the
| compatibility notes in the README.
|
| derivative(self, T, n=1)
| returns the tangent vector of the Path at T (centered at the origin
| and expressed as a complex number).
| Note: Bezier curves can have points where their derivative vanishes.
| If you are interested in the tangent direction, use unit_tangent()
| method instead.
|
| ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5)
| Returns a float, t, such that self.length(0, t) is approximately s.
| See the inv_arclength() docstring for more details.
|
| insert(self, index, value)
| S.insert(index, value) -- insert value before index
|
| intersect(self, other_curve, justonemode=False, tol=1e-12)
| Finds intersections of `self` with `other_curve`
|
| Args:
| other_curve: the path or path segment to check for intersections
| with `self`
| justonemode (bool): if true, returns only the first
| intersection found.
| tol (float): A tolerance used to check for redundant intersections
| (see comment above the code block where tol is used).
|
| Returns:
| (list[tuple[float, Curve, float]]): list of intersections, each
| in the format ((T1, seg1, t1), (T2, seg2, t2)), where
| self.point(T1) == seg1.point(t1) == seg2.point(t2) == other_curve.point(T2)
|
| Scope:
| If the two path objects coincide for more than a finite set of
| points, this code will iterate to max depth and/or raise an error.
|
| is_contained_by(self, other)
| Returns true if the path is fully contained in other closed path
|
| isclosed(self)
| This function determines if a connected path is closed.
|
| isclosedac(self)
|
| iscontinuous(self)
| Checks if a path is continuous with respect to its
| parameterization.
|
| joins_smoothly_with(self, previous, wrt_parameterization=False)
| Checks if this Path object joins smoothly with previous
| path/segment. By default, this only checks that this Path starts
| moving (at t=0) in the same direction (and from the same positive) as
| previous stopped moving (at t=1). To check if the tangent magnitudes
| also match, set wrt_parameterization=True.
|
| joints(self)
| returns generator of segment joints
|
| I.e. Path(s0, s1, s2, ..., sn).joints() returns generator
| (s0, s1), (s1, s2), ..., (sn, s0)
|
| credit: https://docs.python.org/3/library/itertools.html#recipes
|
| length(self, T0=0, T1=1, error=1e-12, min_depth=5)
|
| normal(self, t)
| returns the (right hand rule) unit normal vector to self at t.
|
| point(self, pos)
|
| radialrange(self, origin, return_all_global_extrema=False)
| returns the tuples (d_min, t_min, idx_min), (d_max, t_max, idx_max)
| which minimize and maximize, respectively, the distance
| d = |self[idx].point(t)-origin|.
|
| reversed(self)
| returns a copy of the Path object with its orientation reversed.
|
| rotated(self, degs, origin=None)
| Returns a copy of self rotated by `degs` degrees (CCW) around the
| point `origin` (a complex number). By default `origin` is either
| `self.point(0.5)`, or in the case that self is an Arc object,
| `origin` defaults to `self.center`.
|
| scaled(self, sx, sy=None, origin=0j)
| Scale transform. See `scale` function for further explanation.
|
| t2T(self, seg, t)
| returns the path parameter T which corresponds to the segment
| parameter t. In other words, for any Path object, path, and any
| segment in path, seg, T(t) = path.t2T(seg, t) is the unique
| reparameterization such that path.point(T(t)) == seg.point(t) for all
| 0 <= t <= 1.
| Input Note: seg can be a segment in the Path object or its
| corresponding index.
|
| translated(self, z0)
| Returns a copy of self shifted by the complex quantity `z0` such
| that self.translated(z0).point(t) = self.point(t) + z0 for any t.
|
| unit_tangent(self, T)
| returns the unit tangent vector of the Path at T (centered at the
| origin and expressed as a complex number). If the tangent vector's
| magnitude is zero, this method will find the limit of
| self.derivative(tau)/abs(self.derivative(tau)) as tau approaches T.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| closed
| The closed attribute is deprecated, please use the isclosed()
| method instead. See _closed_warning for more information.
|
| end
|
| start
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| element = None
|
| meta = None
|
| transform = None
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableSequence:
|
| __iadd__(self, values)
|
| append(self, value)
| S.append(value) -- append value to the end of the sequence
|
| clear(self)
| S.clear() -> None -- remove all items from S
|
| extend(self, values)
| S.extend(iterable) -- extend sequence by appending elements from the iterable
|
| pop(self, index=-1)
| S.pop([index]) -> item -- remove and return item at index (default last).
| Raise IndexError if list is empty or index is out of range.
|
| remove(self, value)
| S.remove(value) -- remove first occurrence of value.
| Raise ValueError if the value is not present.
|
| reverse(self)
| S.reverse() -- reverse *IN PLACE*
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Sequence:
|
| __reversed__(self)
|
| count(self, value)
| S.count(value) -> integer -- return number of occurrences of value
|
| index(self, value, start=0, stop=None)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
svgpathtools.path.QuadraticBezier
Python Library Documentation: class QuadraticBezier in module svgpathtools.path class QuadraticBezier(builtins.object) | QuadraticBezier(start, control, end) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, item) | | __hash__(self) -> 'int' | Return hash(self). | | __init__(self, start, control, end) | Initialize self. See help(type(self)) for accurate signature. | | __len__(self) | | __ne__(self, other) | Return self!=value. | | __repr__(self) | Return repr(self). | | bbox(self) | returns the bounding box for the segment in the form | (xmin, xmax, ymin, ymax). | | bpoints(self) | returns the Bezier control points of the segment. | | cropped(self, t0, t1) | returns a cropped copy of this segment which starts at | self.point(t0) and ends at self.point(t1). | | curvature(self, t) | returns the curvature of the segment at t. | | derivative(self, t, n=1) | returns the nth derivative of the segment at t. | Note: Bezier curves can have points where their derivative vanishes. | If you are interested in the tangent direction, use the unit_tangent() | method instead. | | ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5) | Returns a float, t, such that self.length(0, t) is approximately s. | See the inv_arclength() docstring for more details. | | intersect(self, other_seg, tol=1e-12) | Finds the intersections of two segments. | returns a list of tuples (t1, t2) such that | self.point(t1) == other_seg.point(t2). | Note: This will fail if the two segments coincide for more than a | finite collection of points. | | is_smooth_from(self, previous, warning_on=True) | [Warning: The name of this method is somewhat misleading (yet kept | for compatibility with scripts created using svg.path 2.0). This | method is meant only for d string creation and should not be used to | check for kinks. To check a segment for differentiability, use the | joins_smoothly_with() method instead.] | | joins_smoothly_with(self, previous, wrt_parameterization=False, error=0) | Checks if this segment joins smoothly with previous segment. By | default, this only checks that this segment starts moving (at t=0) in | the same direction (and from the same positive) as previous stopped | moving (at t=1). To check if the tangent magnitudes also match, set | wrt_parameterization=True. | | length(self, t0=0, t1=1, error=None, min_depth=None) | | normal(self, t) | returns the (right hand rule) unit normal vector to self at t. | | point(self, t) | returns the coordinates of the Bezier curve evaluated at t. | | points(self, ts) | Faster than running Path.point many times. | | poly(self, return_coeffs=False) | returns the quadratic as a Polynomial object. | | radialrange(self, origin, return_all_global_extrema=False) | returns the tuples (d_min, t_min) and (d_max, t_max) which minimize | and maximize, respectively, the distance d = |self.point(t)-origin|. | | reversed(self) | returns a copy of the QuadraticBezier object with its orientation | reversed. | | rotated(self, degs, origin=None) | Returns a copy of self rotated by `degs` degrees (CCW) around the | point `origin` (a complex number). By default `origin` is either | `self.point(0.5)`, or in the case that self is an Arc object, | `origin` defaults to `self.center`. | | scaled(self, sx, sy=None, origin=0j) | Scale transform. See `scale` function for further explanation. | | split(self, t) | returns two segments, whose union is this segment and which join at | self.point(t). | | translated(self, z0) | Returns a copy of self shifted by the complex quantity `z0` such | that self.translated(z0).point(t) = self.point(t) + z0 for any t. | | unit_tangent(self, t) | returns the unit tangent vector of the segment at t (centered at | the origin and expressed as a complex number). If the tangent | vector's magnitude is zero, this method will find the limit of | self.derivative(tau)/abs(self.derivative(tau)) as tau approaches t. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.path.UPPERCASE
Python Library Documentation: set object class set(object) | set() -> new empty set object | set(iterable) -> new set object | | Build an unordered collection of unique elements. | | Methods defined here: | | __and__(self, value, /) | Return self&value. | | __contains__(...) | x.__contains__(y) <==> y in x. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __gt__(self, value, /) | Return self>value. | | __iand__(self, value, /) | Return self&=value. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __ior__(self, value, /) | Return self|=value. | | __isub__(self, value, /) | Return self-=value. | | __iter__(self, /) | Implement iter(self). | | __ixor__(self, value, /) | Return self^=value. | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __ne__(self, value, /) | Return self!=value. | | __or__(self, value, /) | Return self|value. | | __rand__(self, value, /) | Return value&self. | | __reduce__(...) | Return state information for pickling. | | __repr__(self, /) | Return repr(self). | | __ror__(self, value, /) | Return value|self. | | __rsub__(self, value, /) | Return value-self. | | __rxor__(self, value, /) | Return value^self. | | __sizeof__(...) | S.__sizeof__() -> size of S in memory, in bytes | | __sub__(self, value, /) | Return self-value. | | __xor__(self, value, /) | Return self^value. | | add(...) | Add an element to a set. | | This has no effect if the element is already present. | | clear(...) | Remove all elements from this set. | | copy(...) | Return a shallow copy of a set. | | difference(...) | Return the difference of two or more sets as a new set. | | (i.e. all elements that are in this set but not the others.) | | difference_update(...) | Remove all elements of another set from this set. | | discard(...) | Remove an element from a set if it is a member. | | Unlike set.remove(), the discard() method does not raise | an exception when an element is missing from the set. | | intersection(...) | Return the intersection of two sets as a new set. | | (i.e. all elements that are in both sets.) | | intersection_update(...) | Update a set with the intersection of itself and another. | | isdisjoint(...) | Return True if two sets have a null intersection. | | issubset(self, other, /) | Test whether every element in the set is in other. | | issuperset(self, other, /) | Test whether every element in other is in the set. | | pop(...) | Remove and return an arbitrary set element. | Raises KeyError if the set is empty. | | remove(...) | Remove an element from a set; it must be a member. | | If the element is not a member, raise a KeyError. | | symmetric_difference(...) | Return the symmetric difference of two sets as a new set. | | (i.e. all elements that are in exactly one of the sets.) | | symmetric_difference_update(...) | Update a set with the symmetric difference of itself and another. | | union(...) | Return the union of sets as a new set. | | (i.e. all elements that are in either set.) | | update(...) | Update a set with the union of itself and others. | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None
svgpathtools.path.USE_SCIPY_QUAD
Python Library Documentation: bool object class bool(int) | bool(x) -> bool | | Returns True when the argument x is true, False otherwise. | The builtins True and False are the only two instances of the class bool. | The class bool is a subclass of the class int, and cannot be subclassed. | | Method resolution order: | bool | int | object | | Methods defined here: | | __and__(self, value, /) | Return self&value. | | __invert__(self, /) | ~self | | __or__(self, value, /) | Return self|value. | | __rand__(self, value, /) | Return value&self. | | __repr__(self, /) | Return repr(self). | | __ror__(self, value, /) | Return value|self. | | __rxor__(self, value, /) | Return value^self. | | __xor__(self, value, /) | Return self^value. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from int: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __bool__(self, /) | True if self else False | | __ceil__(...) | Ceiling of an Integral returns itself. | | __divmod__(self, value, /) | Return divmod(self, value). | | __eq__(self, value, /) | Return self==value. | | __float__(self, /) | float(self) | | __floor__(...) | Flooring an Integral returns itself. | | __floordiv__(self, value, /) | Return self//value. | | __format__(self, format_spec, /) | Convert to a string according to format_spec. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getnewargs__(self, /) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __index__(self, /) | Return self converted to an integer, if self is suitable for use as an index into a list. | | __int__(self, /) | int(self) | | __le__(self, value, /) | Return self<=value. | | __lshift__(self, value, /) | Return self<<value. | | __lt__(self, value, /) | Return self<value. | | __mod__(self, value, /) | Return self%value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __neg__(self, /) | -self | | __pos__(self, /) | +self | | __pow__(self, value, mod=None, /) | Return pow(self, value, mod). | | __radd__(self, value, /) | Return value+self. | | __rdivmod__(self, value, /) | Return divmod(value, self). | | __rfloordiv__(self, value, /) | Return value//self. | | __rlshift__(self, value, /) | Return value<<self. | | __rmod__(self, value, /) | Return value%self. | | __rmul__(self, value, /) | Return value*self. | | __round__(...) | Rounding an Integral returns itself. | | Rounding with an ndigits argument also returns an integer. | | __rpow__(self, value, mod=None, /) | Return pow(value, self, mod). | | __rrshift__(self, value, /) | Return value>>self. | | __rshift__(self, value, /) | Return self>>value. | | __rsub__(self, value, /) | Return value-self. | | __rtruediv__(self, value, /) | Return value/self. | | __sizeof__(self, /) | Returns size in memory, in bytes. | | __sub__(self, value, /) | Return self-value. | | __truediv__(self, value, /) | Return self/value. | | __trunc__(...) | Truncating an Integral returns itself. | | as_integer_ratio(self, /) | Return a pair of integers, whose ratio is equal to the original int. | | The ratio is in lowest terms and has a positive denominator. | | >>> (10).as_integer_ratio() | (10, 1) | >>> (-10).as_integer_ratio() | (-10, 1) | >>> (0).as_integer_ratio() | (0, 1) | | bit_count(self, /) | Number of ones in the binary representation of the absolute value of self. | | Also known as the population count. | | >>> bin(13) | '0b1101' | >>> (13).bit_count() | 3 | | bit_length(self, /) | Number of bits necessary to represent self in binary. | | >>> bin(37) | '0b100101' | >>> (37).bit_length() | 6 | | conjugate(...) | Returns self, the complex conjugate of any int. | | is_integer(self, /) | Returns True. Exists for duck type compatibility with float.is_integer. | | to_bytes(self, /, length=1, byteorder='big', *, signed=False) | Return an array of bytes representing an integer. | | length | Length of bytes object to use. An OverflowError is raised if the | integer is not representable with the given number of bytes. Default | is length 1. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Determines whether two's complement is used to represent the integer. | If signed is False and a negative integer is given, an OverflowError | is raised. | | ---------------------------------------------------------------------- | Class methods inherited from int: | | from_bytes(bytes, byteorder='big', *, signed=False) | Return the integer represented by the given array of bytes. | | bytes | Holds the array of bytes to convert. The argument must either | support the buffer protocol or be an iterable object producing bytes. | Bytes and bytearray are examples of built-in objects that support the | buffer protocol. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Indicates whether two's complement is used to represent the integer. | | ---------------------------------------------------------------------- | Data descriptors inherited from int: | | denominator | the denominator of a rational number in lowest terms | | imag | the imaginary part of a complex number | | numerator | the numerator of a rational number in lowest terms | | real | the real part of a complex number
svgpathtools.path.acos
Python Library Documentation: ufunc
arccos = <ufunc 'arccos'>
arccos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Trigonometric inverse cosine, element-wise.
The inverse of `cos` so that, if ``y = cos(x)``, then ``x = arccos(y)``.
Parameters
----------
x : array_like
`x`-coordinate on the unit circle.
For real arguments, the domain is [-1, 1].
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
angle : ndarray
The angle of the ray intersecting the unit circle at the given
`x`-coordinate in radians [0, pi].
This is a scalar if `x` is a scalar.
See Also
--------
cos, arctan, arcsin, emath.arccos
Notes
-----
`arccos` is a multivalued function: for each `x` there are infinitely
many numbers `z` such that ``cos(z) = x``. The convention is to return
the angle `z` whose real part lies in `[0, pi]`.
For real-valued input data types, `arccos` always returns real output.
For each value that cannot be expressed as a real number or infinity,
it yields ``nan`` and sets the `invalid` floating point error flag.
For complex-valued input, `arccos` is a complex analytic function that
has branch cuts ``[-inf, -1]`` and `[1, inf]` and is continuous from
above on the former and from below on the latter.
The inverse `cos` is also known as `acos` or cos^-1.
References
----------
M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
10th printing, 1964, pp. 79.
https://personal.math.ubc.ca/~cbm/aands/page_79.htm
Examples
--------
>>> import numpy as np
We expect the arccos of 1 to be 0, and of -1 to be pi:
>>> np.arccos([1, -1])
array([ 0. , 3.14159265])
Plot arccos:
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-1, 1, num=100)
>>> plt.plot(x, np.arccos(x))
>>> plt.axis('tight')
>>> plt.show()
svgpathtools.path.annotations
Python Library Documentation: _Feature in module __future__ object class _Feature(builtins.object) | _Feature(optionalRelease, mandatoryRelease, compiler_flag) | | Methods defined here: | | __init__(self, optionalRelease, mandatoryRelease, compiler_flag) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | getMandatoryRelease(self) | Return release in which this feature will become mandatory. | | This is a 5-tuple, of the same form as sys.version_info, or, if | the feature was dropped, or the release date is undetermined, is None. | | getOptionalRelease(self) | Return first release in which this feature was recognized. | | This is a 5-tuple, of the same form as sys.version_info. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.path.asin
Python Library Documentation: ufunc
arcsin = <ufunc 'arcsin'>
arcsin(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Inverse sine, element-wise.
Parameters
----------
x : array_like
`y`-coordinate on the unit circle.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
angle : ndarray
The inverse sine of each element in `x`, in radians and in the
closed interval ``[-pi/2, pi/2]``.
This is a scalar if `x` is a scalar.
See Also
--------
sin, cos, arccos, tan, arctan, arctan2, emath.arcsin
Notes
-----
`arcsin` is a multivalued function: for each `x` there are infinitely
many numbers `z` such that :math:`sin(z) = x`. The convention is to
return the angle `z` whose real part lies in [-pi/2, pi/2].
For real-valued input data types, *arcsin* always returns real output.
For each value that cannot be expressed as a real number or infinity,
it yields ``nan`` and sets the `invalid` floating point error flag.
For complex-valued input, `arcsin` is a complex analytic function that
has, by convention, the branch cuts [-inf, -1] and [1, inf] and is
continuous from above on the former and from below on the latter.
The inverse sine is also known as `asin` or sin^{-1}.
References
----------
Abramowitz, M. and Stegun, I. A., *Handbook of Mathematical Functions*,
10th printing, New York: Dover, 1964, pp. 79ff.
https://personal.math.ubc.ca/~cbm/aands/page_79.htm
Examples
--------
>>> import numpy as np
>>> np.arcsin(1) # pi/2
1.5707963267948966
>>> np.arcsin(-1) # -pi/2
-1.5707963267948966
>>> np.arcsin(0)
0.0
svgpathtools.path.bbox2path
Python Library Documentation: function bbox2path in module svgpathtools.path
bbox2path(xmin, xmax, ymin, ymax)
Converts a bounding box 4-tuple to a Path object.
svgpathtools.path.bez2poly
Python Library Documentation: function bez2poly in module svgpathtools.path
bez2poly(bez, numpy_ordering=True, return_poly1d=False)
Converts a Bezier object or tuple of Bezier control points to a tuple
of coefficients of the expanded polynomial.
return_poly1d : returns a numpy.poly1d object. This makes computations
of derivatives/anti-derivatives and many other operations quite quick.
numpy_ordering : By default (to accommodate numpy) the coefficients will
be output in reverse standard order.
Note: This function is redundant thanks to the .poly() method included
with all bezier segment classes.
svgpathtools.path.bezier2polynomial
Python Library Documentation: function bezier2polynomial in module svgpathtools.bezier
bezier2polynomial(p, numpy_ordering=True, return_poly1d=False)
Converts a tuple of Bezier control points to a tuple of coefficients
of the expanded polynomial.
return_poly1d : returns a numpy.poly1d object. This makes computations
of derivatives/anti-derivatives and many other operations quite quick.
numpy_ordering : By default (to accommodate numpy) the coefficients will
be output in reverse standard order.
svgpathtools.path.bezier_bounding_box
Python Library Documentation: function bezier_bounding_box in module svgpathtools.bezier
bezier_bounding_box(bez)
returns the bounding box for the segment in the form
(xmin, xmax, ymin, ymax).
Warning: For the non-cubic case this is not particularly efficient.
svgpathtools.path.bezier_by_line_intersections
Python Library Documentation: function bezier_by_line_intersections in module svgpathtools.bezier
bezier_by_line_intersections(bezier, line)
Returns tuples (t1,t2) such that bezier.point(t1) ~= line.point(t2).
svgpathtools.path.bezier_intersections
Python Library Documentation: function bezier_intersections in module svgpathtools.bezier
bezier_intersections(bez1, bez2, longer_length, tol=1e-08, tol_deC=1e-08)
INPUT:
bez1, bez2 = [P0,P1,P2,...PN], [Q0,Q1,Q2,...,PN] defining the two
Bezier curves to check for intersections between.
longer_length - the length (or an upper bound) on the longer of the two
Bezier curves. Determines the maximum iterations needed together with tol.
tol - is the smallest distance that two solutions can differ by and still
be considered distinct solutions.
OUTPUT: a list of tuples (t,s) in [0,1]x[0,1] such that
abs(bezier_point(bez1[0],t) - bezier_point(bez2[1],s)) < tol_deC
Note: This will return exactly one such tuple for each intersection
(assuming tol_deC is small enough).
svgpathtools.path.bezier_radialrange
Python Library Documentation: function bezier_radialrange in module svgpathtools.path
bezier_radialrange(seg, origin, return_all_global_extrema=False)
returns the tuples (d_min, t_min) and (d_max, t_max) which minimize and
maximize, respectively, the distance d = |self.point(t)-origin|.
return_all_global_extrema: Multiple such t_min or t_max values can exist.
By default, this will only return one. Set return_all_global_extrema=True
to return all such global extrema.
svgpathtools.path.bezier_segment
Python Library Documentation: function bezier_segment in module svgpathtools.path bezier_segment(*bpoints)
svgpathtools.path.bezier_unit_tangent
Python Library Documentation: function bezier_unit_tangent in module svgpathtools.path
bezier_unit_tangent(seg, t)
Returns the unit tangent of the segment at t.
Notes
-----
If you receive a RuntimeWarning, try the following:
>>> import numpy
>>> old_numpy_error_settings = numpy.seterr(invalid='raise')
This can be undone with:
>>> numpy.seterr(**old_numpy_error_settings)
svgpathtools.path.bpoints2bezier
Python Library Documentation: function bpoints2bezier in module svgpathtools.path
bpoints2bezier(bpoints)
Converts a list of length 2, 3, or 4 to a CubicBezier, QuadraticBezier,
or Line object, respectively.
See also: poly2bez.
svgpathtools.path.ceil
Python Library Documentation: ufunc
ceil = <ufunc 'ceil'>
ceil(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Return the ceiling of the input, element-wise.
The ceil of the scalar `x` is the smallest integer `i`, such that
``i >= x``. It is often denoted as :math:`\lceil x \rceil`.
Parameters
----------
x : array_like
Input data.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray or scalar
The ceiling of each element in `x`.
This is a scalar if `x` is a scalar.
See Also
--------
floor, trunc, rint, fix
Examples
--------
>>> import numpy as np
>>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
>>> np.ceil(a)
array([-1., -1., -0., 1., 2., 2., 2.])
svgpathtools.path.closest_point_in_path
Python Library Documentation: function closest_point_in_path in module svgpathtools.path
closest_point_in_path(pt, path)
returns (|path.seg.point(t)-pt|, t, seg_idx) where t and seg_idx
minimize the distance between pt and curve path[idx].point(t) for 0<=t<=1
and any seg_idx.
Warning: Multiple such global minima can exist. This will only return
one.
svgpathtools.path.concatpaths
Python Library Documentation: function concatpaths in module svgpathtools.path
concatpaths(list_of_paths)
Takes in a sequence of paths and returns their concatenations into a
single path (following the order of the input sequence).
svgpathtools.path.cos
Python Library Documentation: ufunc
cos = <ufunc 'cos'>
cos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Cosine element-wise.
Parameters
----------
x : array_like
Input array in radians.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray
The corresponding cosine values.
This is a scalar if `x` is a scalar.
Notes
-----
If `out` is provided, the function writes the result into it,
and returns a reference to `out`. (See Examples)
References
----------
M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions.
New York, NY: Dover, 1972.
Examples
--------
>>> import numpy as np
>>> np.cos(np.array([0, np.pi/2, np.pi]))
array([ 1.00000000e+00, 6.12303177e-17, -1.00000000e+00])
>>>
>>> # Example of providing the optional output parameter
>>> out1 = np.array([0], dtype='d')
>>> out2 = np.cos([0.1], out1)
>>> out2 is out1
True
>>>
>>> # Example of ValueError due to provision of shape mis-matched `out`
>>> np.cos(np.zeros((3,3)),np.zeros((2,2)))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: operands could not be broadcast together with shapes (3,3) (2,2)
svgpathtools.path.crop_bezier
Python Library Documentation: function crop_bezier in module svgpathtools.path
crop_bezier(seg, t0, t1)
Crop a copy of this `self` from `self.point(t0)` to `self.point(t1)`.
svgpathtools.path.csqrt
Python Library Documentation: ufunc
sqrt = <ufunc 'sqrt'>
sqrt(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Return the non-negative square-root of an array, element-wise.
Parameters
----------
x : array_like
The values whose square-roots are required.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray
An array of the same shape as `x`, containing the positive
square-root of each element in `x`. If any element in `x` is
complex, a complex array is returned (and the square-roots of
negative reals are calculated). If all of the elements in `x`
are real, so is `y`, with negative elements returning ``nan``.
If `out` was provided, `y` is a reference to it.
This is a scalar if `x` is a scalar.
See Also
--------
emath.sqrt
A version which returns complex numbers when given negative reals.
Note that 0.0 and -0.0 are handled differently for complex inputs.
Notes
-----
*sqrt* has--consistent with common convention--as its branch cut the
real "interval" [`-inf`, 0), and is continuous from above on it.
A branch cut is a curve in the complex plane across which a given
complex function fails to be continuous.
Examples
--------
>>> import numpy as np
>>> np.sqrt([1,4,9])
array([ 1., 2., 3.])
>>> np.sqrt([4, -1, -3+4J])
array([ 2.+0.j, 0.+1.j, 1.+2.j])
>>> np.sqrt([4, -1, np.inf])
array([ 2., nan, inf])
svgpathtools.path.degrees
Python Library Documentation: ufunc
degrees = <ufunc 'degrees'>
degrees(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Convert angles from radians to degrees.
Parameters
----------
x : array_like
Input array in radians.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray of floats
The corresponding degree values; if `out` was supplied this is a
reference to it.
This is a scalar if `x` is a scalar.
See Also
--------
rad2deg : equivalent function
Examples
--------
Convert a radian array to degrees
>>> import numpy as np
>>> rad = np.arange(12.)*np.pi/6
>>> np.degrees(rad)
array([ 0., 30., 60., 90., 120., 150., 180., 210., 240.,
270., 300., 330.])
>>> out = np.zeros((rad.shape))
>>> r = np.degrees(rad, out)
>>> np.all(r == out)
True
svgpathtools.path.exp
Python Library Documentation: ufunc
exp = <ufunc 'exp'>
exp(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Calculate the exponential of all elements in the input array.
Parameters
----------
x : array_like
Input values.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
out : ndarray or scalar
Output array, element-wise exponential of `x`.
This is a scalar if `x` is a scalar.
See Also
--------
expm1 : Calculate ``exp(x) - 1`` for all elements in the array.
exp2 : Calculate ``2**x`` for all elements in the array.
Notes
-----
The irrational number ``e`` is also known as Euler's number. It is
approximately 2.718281, and is the base of the natural logarithm,
``ln`` (this means that, if :math:`x = \ln y = \log_e y`,
then :math:`e^x = y`. For real input, ``exp(x)`` is always positive.
For complex arguments, ``x = a + ib``, we can write
:math:`e^x = e^a e^{ib}`. The first term, :math:`e^a`, is already
known (it is the real argument, described above). The second term,
:math:`e^{ib}`, is :math:`\cos b + i \sin b`, a function with
magnitude 1 and a periodic phase.
References
----------
.. [1] Wikipedia, "Exponential function",
https://en.wikipedia.org/wiki/Exponential_function
.. [2] M. Abramovitz and I. A. Stegun, "Handbook of Mathematical Functions
with Formulas, Graphs, and Mathematical Tables," Dover, 1964, p. 69,
https://personal.math.ubc.ca/~cbm/aands/page_69.htm
Examples
--------
Plot the magnitude and phase of ``exp(x)`` in the complex plane:
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-2*np.pi, 2*np.pi, 100)
>>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane
>>> out = np.exp(xx)
>>> plt.subplot(121)
>>> plt.imshow(np.abs(out),
... extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi], cmap='gray')
>>> plt.title('Magnitude of exp(x)')
>>> plt.subplot(122)
>>> plt.imshow(np.angle(out),
... extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi], cmap='hsv')
>>> plt.title('Phase (angle) of exp(x)')
>>> plt.show()
svgpathtools.path.farthest_point_in_path
Python Library Documentation: function farthest_point_in_path in module svgpathtools.path
farthest_point_in_path(pt, path)
returns (|path.seg.point(t)-pt|, t, seg_idx) where t and seg_idx
maximize the distance between pt and curve path[idx].point(t) for 0<=t<=1
and any seg_idx.
:rtype : object
:param pt:
:param path:
Warning: Multiple such global maxima can exist. This will only return
one.
svgpathtools.path.imag
Python Library Documentation: function imag in module svgpathtools.polytools imag(z)
svgpathtools.path.inv_arclength
Python Library Documentation: function inv_arclength in module svgpathtools.path
inv_arclength(curve, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5)
INPUT: curve should be a CubicBezier, Line, of Path of CubicBezier
and/or Line objects.
OUTPUT: Returns a float, t, such that the arc length of curve from 0 to
t is approximately s.
s_tol - exit when |s(t) - s| < s_tol where
s(t) = seg.length(0, t, error, min_depth) and seg is either curve or,
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, but if it's slower
than you need, make sure you have scipy installed.
svgpathtools.path.is_bezier_path
Python Library Documentation: function is_bezier_path in module svgpathtools.path
is_bezier_path(path)
Checks that all segments in path are a Line, QuadraticBezier, or
CubicBezier object.
svgpathtools.path.is_bezier_segment
Python Library Documentation: function is_bezier_segment in module svgpathtools.path is_bezier_segment(seg)
svgpathtools.path.is_path_segment
Python Library Documentation: function is_path_segment in module svgpathtools.path is_path_segment(seg)
svgpathtools.path.isnan
Python Library Documentation: ufunc
isnan = <ufunc 'isnan'>
isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Test element-wise for NaN and return result as a boolean array.
Parameters
----------
x : array_like
Input array.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray or bool
True where ``x`` is NaN, false otherwise.
This is a scalar if `x` is a scalar.
See Also
--------
isinf, isneginf, isposinf, isfinite, isnat
Notes
-----
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
(IEEE 754). This means that Not a Number is not equivalent to infinity.
Examples
--------
>>> import numpy as np
>>> np.isnan(np.nan)
True
>>> np.isnan(np.inf)
False
>>> np.isnan([np.log(-1.),1.,np.log(0)])
array([ True, False, False])
svgpathtools.path.itemgetter
Python Library Documentation: class itemgetter in module operator class itemgetter(builtins.object) | itemgetter(item, /, *items) | | Return a callable object that fetches the given item(s) from its operand. | After f = itemgetter(2), the call f(r) returns r[2]. | After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3]) | | Methods defined here: | | __call__(self, /, *args, **kwargs) | Call self as a function. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Return state information for pickling | | __repr__(self, /) | Return repr(self). | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __vectorcalloffset__
svgpathtools.path.log
Python Library Documentation: ufunc
log = <ufunc 'log'>
log(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Natural logarithm, element-wise.
The natural logarithm `log` is the inverse of the exponential function,
so that `log(exp(x)) = x`. The natural logarithm is logarithm in base
`e`.
Parameters
----------
x : array_like
Input value.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray
The natural logarithm of `x`, element-wise.
This is a scalar if `x` is a scalar.
See Also
--------
log10, log2, log1p, emath.log
Notes
-----
Logarithm is a multivalued function: for each `x` there is an infinite
number of `z` such that `exp(z) = x`. The convention is to return the
`z` whose imaginary part lies in `(-pi, pi]`.
For real-valued input data types, `log` always returns real output. For
each value that cannot be expressed as a real number or infinity, it
yields ``nan`` and sets the `invalid` floating point error flag.
For complex-valued input, `log` is a complex analytical function that
has a branch cut `[-inf, 0]` and is continuous from above on it. `log`
handles the floating-point negative zero as an infinitesimal negative
number, conforming to the C99 standard.
In the cases where the input has a negative real part and a very small
negative complex part (approaching 0), the result is so close to `-pi`
that it evaluates to exactly `-pi`.
References
----------
.. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
10th printing, 1964, pp. 67.
https://personal.math.ubc.ca/~cbm/aands/page_67.htm
.. [2] Wikipedia, "Logarithm". https://en.wikipedia.org/wiki/Logarithm
Examples
--------
>>> import numpy as np
>>> np.log([1, np.e, np.e**2, 0])
array([ 0., 1., 2., -inf])
svgpathtools.path.path_encloses_pt
Python Library Documentation: function path_encloses_pt in module svgpathtools.path
path_encloses_pt(pt, opt, path)
returns true if pt is a point enclosed by path (which must be a Path
object satisfying path.isclosed==True). opt is a point you know is
NOT enclosed by path.
svgpathtools.path.phase
Python Library Documentation: _ArrayFunctionDispatcher in module numpy
angle(z, deg=False)
Return the angle of the complex argument.
Parameters
----------
z : array_like
A complex number or sequence of complex numbers.
deg : bool, optional
Return angle in degrees if True, radians if False (default).
Returns
-------
angle : ndarray or scalar
The counterclockwise angle from the positive real axis on the complex
plane in the range ``(-pi, pi]``, with dtype as numpy.float64.
.. versionchanged:: 1.16.0
This function works on subclasses of ndarray like `ma.array`.
See Also
--------
arctan2
absolute
Notes
-----
This function passes the imaginary and real parts of the argument to
`arctan2` to compute the result; consequently, it follows the convention
of `arctan2` when the magnitude of the argument is zero. See example.
Examples
--------
>>> import numpy as np
>>> np.angle([1.0, 1.0j, 1+1j]) # in radians
array([ 0. , 1.57079633, 0.78539816]) # may vary
>>> np.angle(1+1j, deg=True) # in degrees
45.0
>>> np.angle([0., -0., complex(0., -0.), complex(-0., -0.)]) # convention
array([ 0. , 3.14159265, -0. , -3.14159265])
svgpathtools.path.pi
Python Library Documentation: float object
class float(object)
| float(x=0, /)
|
| Convert a string or number to a floating-point number, if possible.
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(self, /)
| Return the ceiling as an Integral.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(self, /)
| Return the floor as an Integral.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(self, format_spec, /)
| Formats the float according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(self, ndigits=None, /)
| Return the Integral closest to x, rounding half toward even.
|
| When an argument is passed, work like built-in round(x, ndigits).
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(self, /)
| Return the Integral closest to x between 0 and x.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is exactly equal to the original float.
|
| The ratio is in lowest terms and has a positive denominator. Raise
| OverflowError on infinities and a ValueError on NaNs.
|
| >>> (10.0).as_integer_ratio()
| (10, 1)
| >>> (0.0).as_integer_ratio()
| (0, 1)
| >>> (-.25).as_integer_ratio()
| (-1, 4)
|
| conjugate(self, /)
| Return self, the complex conjugate of any float.
|
| hex(self, /)
| Return a hexadecimal representation of a floating-point number.
|
| >>> (-0.1).hex()
| '-0x1.999999999999ap-4'
| >>> 3.14159.hex()
| '0x1.921f9f01b866ep+1'
|
| is_integer(self, /)
| Return True if the float is an integer.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __getformat__(typestr, /)
| You probably don't want to use this function.
|
| typestr
| Must be 'double' or 'float'.
|
| It exists mainly to be used in Python's test suite.
|
| This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
| little-endian' best describes the format of floating-point numbers used by the
| C type named by typestr.
|
| fromhex(string, /)
| Create a floating-point number from a hexadecimal string.
|
| >>> float.fromhex('0x1.ffffp10')
| 2047.984375
| >>> float.fromhex('-0x1p-1074')
| -5e-324
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| imag
| the imaginary part of a complex number
|
| real
| the real part of a complex number
svgpathtools.path.poly2bez
Python Library Documentation: function poly2bez in module svgpathtools.path
poly2bez(poly, return_bpoints=False)
Converts a cubic or lower order Polynomial object (or a sequence of
coefficients) to a CubicBezier, QuadraticBezier, or Line object as
appropriate. If return_bpoints=True then this will instead only return
the control points of the corresponding Bezier curve.
Note: The inverse operation is available as a method of CubicBezier,
QuadraticBezier and Line objects.
svgpathtools.path.polygon
Python Library Documentation: function polygon in module svgpathtools.path
polygon(*points)
Converts a list of points to a Path composed of lines connecting those
points, then closes the path by connecting the last point to the first.
See also `polyline()`.
svgpathtools.path.polyline
Python Library Documentation: function polyline in module svgpathtools.path
polyline(*points)
Converts a list of points to a Path composed of lines connecting those
points (i.e. a linear spline or polyline). See also `polygon()`.
svgpathtools.path.polynomial2bezier
Python Library Documentation: function polynomial2bezier in module svgpathtools.bezier
polynomial2bezier(poly)
Converts a cubic or lower order Polynomial object (or a sequence of
coefficients) to a CubicBezier, QuadraticBezier, or Line object as
appropriate.
svgpathtools.path.polyroots
Python Library Documentation: function polyroots in module svgpathtools.polytools
polyroots(p, realroots=False, condition=<function <lambda> at 0x000001C63A7BA3E0>)
Returns the roots of a polynomial with coefficients given in p.
p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
INPUT:
p - Rank-1 array-like object of polynomial coefficients.
realroots - a boolean. If true, only real roots will be returned and the
condition function can be written assuming all roots are real.
condition - a boolean-valued function. Only roots satisfying this will be
returned. If realroots==True, these conditions should assume the roots
are real.
OUTPUT:
A list containing the roots of the polynomial.
NOTE: This uses np.isclose and np.roots
svgpathtools.path.polyroots01
Python Library Documentation: function polyroots01 in module svgpathtools.polytools
polyroots01(p)
Returns the real roots between 0 and 1 of the polynomial with
coefficients given in p,
p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
p can also be a np.poly1d object. See polyroots for more information.
svgpathtools.path.quad
Python Library Documentation: function quad in module scipy.integrate._quadpack_py
quad(func, a, b, args=(), full_output=0, epsabs=1.49e-08, epsrel=1.49e-08, limit=50, points=None, weight=None, wvar=None, wopts=None, maxp1=50, limlst=50, complex_func=False)
Compute a definite integral.
Integrate func from `a` to `b` (possibly infinite interval) using a
technique from the Fortran library QUADPACK.
Parameters
----------
func : {function, scipy.LowLevelCallable}
A Python function or method to integrate. If `func` takes many
arguments, it is integrated along the axis corresponding to the
first argument.
If the user desires improved integration performance, then `f` may
be a `scipy.LowLevelCallable` with one of the signatures::
double func(double x)
double func(double x, void *user_data)
double func(int n, double *xx)
double func(int n, double *xx, void *user_data)
The ``user_data`` is the data contained in the `scipy.LowLevelCallable`.
In the call forms with ``xx``, ``n`` is the length of the ``xx``
array which contains ``xx[0] == x`` and the rest of the items are
numbers contained in the ``args`` argument of quad.
In addition, certain ctypes call signatures are supported for
backward compatibility, but those should not be used in new code.
a : float
Lower limit of integration (use -numpy.inf for -infinity).
b : float
Upper limit of integration (use numpy.inf for +infinity).
args : tuple, optional
Extra arguments to pass to `func`.
full_output : int, optional
Non-zero to return a dictionary of integration information.
If non-zero, warning messages are also suppressed and the
message is appended to the output tuple.
complex_func : bool, optional
Indicate if the function's (`func`) return type is real
(``complex_func=False``: default) or complex (``complex_func=True``).
In both cases, the function's argument is real.
If full_output is also non-zero, the `infodict`, `message`, and
`explain` for the real and complex components are returned in
a dictionary with keys "real output" and "imag output".
Returns
-------
y : float
The integral of func from `a` to `b`.
abserr : float
An estimate of the absolute error in the result.
infodict : dict
A dictionary containing additional information.
message
A convergence message.
explain
Appended only with 'cos' or 'sin' weighting and infinite
integration limits, it contains an explanation of the codes in
infodict['ierlst']
Other Parameters
----------------
epsabs : float or int, optional
Absolute error tolerance. Default is 1.49e-8. `quad` tries to obtain
an accuracy of ``abs(i-result) <= max(epsabs, epsrel*abs(i))``
where ``i`` = integral of `func` from `a` to `b`, and ``result`` is the
numerical approximation. See `epsrel` below.
epsrel : float or int, optional
Relative error tolerance. Default is 1.49e-8.
If ``epsabs <= 0``, `epsrel` must be greater than both 5e-29
and ``50 * (machine epsilon)``. See `epsabs` above.
limit : float or int, optional
An upper bound on the number of subintervals used in the adaptive
algorithm.
points : (sequence of floats,ints), optional
A sequence of break points in the bounded integration interval
where local difficulties of the integrand may occur (e.g.,
singularities, discontinuities). The sequence does not have
to be sorted. Note that this option cannot be used in conjunction
with ``weight``.
weight : float or int, optional
String indicating weighting function. Full explanation for this
and the remaining arguments can be found below.
wvar : optional
Variables for use with weighting functions.
wopts : optional
Optional input for reusing Chebyshev moments.
maxp1 : float or int, optional
An upper bound on the number of Chebyshev moments.
limlst : int, optional
Upper bound on the number of cycles (>=3) for use with a sinusoidal
weighting and an infinite end-point.
See Also
--------
dblquad : double integral
tplquad : triple integral
nquad : n-dimensional integrals (uses `quad` recursively)
fixed_quad : fixed-order Gaussian quadrature
simpson : integrator for sampled data
romb : integrator for sampled data
scipy.special : for coefficients and roots of orthogonal polynomials
Notes
-----
For valid results, the integral must converge; behavior for divergent
integrals is not guaranteed.
**Extra information for quad() inputs and outputs**
If full_output is non-zero, then the third output argument
(infodict) is a dictionary with entries as tabulated below. For
infinite limits, the range is transformed to (0,1) and the
optional outputs are given with respect to this transformed range.
Let M be the input argument limit and let K be infodict['last'].
The entries are:
'neval'
The number of function evaluations.
'last'
The number, K, of subintervals produced in the subdivision process.
'alist'
A rank-1 array of length M, the first K elements of which are the
left end points of the subintervals in the partition of the
integration range.
'blist'
A rank-1 array of length M, the first K elements of which are the
right end points of the subintervals.
'rlist'
A rank-1 array of length M, the first K elements of which are the
integral approximations on the subintervals.
'elist'
A rank-1 array of length M, the first K elements of which are the
moduli of the absolute error estimates on the subintervals.
'iord'
A rank-1 integer array of length M, the first L elements of
which are pointers to the error estimates over the subintervals
with ``L=K`` if ``K<=M/2+2`` or ``L=M+1-K`` otherwise. Let I be the
sequence ``infodict['iord']`` and let E be the sequence
``infodict['elist']``. Then ``E[I[1]], ..., E[I[L]]`` forms a
decreasing sequence.
If the input argument points is provided (i.e., it is not None),
the following additional outputs are placed in the output
dictionary. Assume the points sequence is of length P.
'pts'
A rank-1 array of length P+2 containing the integration limits
and the break points of the intervals in ascending order.
This is an array giving the subintervals over which integration
will occur.
'level'
A rank-1 integer array of length M (=limit), containing the
subdivision levels of the subintervals, i.e., if (aa,bb) is a
subinterval of ``(pts[1], pts[2])`` where ``pts[0]`` and ``pts[2]``
are adjacent elements of ``infodict['pts']``, then (aa,bb) has level l
if ``|bb-aa| = |pts[2]-pts[1]| * 2**(-l)``.
'ndin'
A rank-1 integer array of length P+2. After the first integration
over the intervals (pts[1], pts[2]), the error estimates over some
of the intervals may have been increased artificially in order to
put their subdivision forward. This array has ones in slots
corresponding to the subintervals for which this happens.
**Weighting the integrand**
The input variables, *weight* and *wvar*, are used to weight the
integrand by a select list of functions. Different integration
methods are used to compute the integral with these weighting
functions, and these do not support specifying break points. The
possible values of weight and the corresponding weighting functions are.
========== =================================== =====================
``weight`` Weight function used ``wvar``
========== =================================== =====================
'cos' cos(w*x) wvar = w
'sin' sin(w*x) wvar = w
'alg' g(x) = ((x-a)**alpha)*((b-x)**beta) wvar = (alpha, beta)
'alg-loga' g(x)*log(x-a) wvar = (alpha, beta)
'alg-logb' g(x)*log(b-x) wvar = (alpha, beta)
'alg-log' g(x)*log(x-a)*log(b-x) wvar = (alpha, beta)
'cauchy' 1/(x-c) wvar = c
========== =================================== =====================
wvar holds the parameter w, (alpha, beta), or c depending on the weight
selected. In these expressions, a and b are the integration limits.
For the 'cos' and 'sin' weighting, additional inputs and outputs are
available.
For finite integration limits, the integration is performed using a
Clenshaw-Curtis method which uses Chebyshev moments. For repeated
calculations, these moments are saved in the output dictionary:
'momcom'
The maximum level of Chebyshev moments that have been computed,
i.e., if ``M_c`` is ``infodict['momcom']`` then the moments have been
computed for intervals of length ``|b-a| * 2**(-l)``,
``l=0,1,...,M_c``.
'nnlog'
A rank-1 integer array of length M(=limit), containing the
subdivision levels of the subintervals, i.e., an element of this
array is equal to l if the corresponding subinterval is
``|b-a|* 2**(-l)``.
'chebmo'
A rank-2 array of shape (25, maxp1) containing the computed
Chebyshev moments. These can be passed on to an integration
over the same interval by passing this array as the second
element of the sequence wopts and passing infodict['momcom'] as
the first element.
If one of the integration limits is infinite, then a Fourier integral is
computed (assuming w neq 0). If full_output is 1 and a numerical error
is encountered, besides the error message attached to the output tuple,
a dictionary is also appended to the output tuple which translates the
error codes in the array ``info['ierlst']`` to English messages. The
output information dictionary contains the following entries instead of
'last', 'alist', 'blist', 'rlist', and 'elist':
'lst'
The number of subintervals needed for the integration (call it ``K_f``).
'rslst'
A rank-1 array of length M_f=limlst, whose first ``K_f`` elements
contain the integral contribution over the interval
``(a+(k-1)c, a+kc)`` where ``c = (2*floor(|w|) + 1) * pi / |w|``
and ``k=1,2,...,K_f``.
'erlst'
A rank-1 array of length ``M_f`` containing the error estimate
corresponding to the interval in the same position in
``infodict['rslist']``.
'ierlst'
A rank-1 integer array of length ``M_f`` containing an error flag
corresponding to the interval in the same position in
``infodict['rslist']``. See the explanation dictionary (last entry
in the output tuple) for the meaning of the codes.
**Details of QUADPACK level routines**
`quad` calls routines from the FORTRAN library QUADPACK. This section
provides details on the conditions for each routine to be called and a
short description of each routine. The routine called depends on
`weight`, `points` and the integration limits `a` and `b`.
================ ============== ========== =====================
QUADPACK routine `weight` `points` infinite bounds
================ ============== ========== =====================
qagse None No No
qagie None No Yes
qagpe None Yes No
qawoe 'sin', 'cos' No No
qawfe 'sin', 'cos' No either `a` or `b`
qawse 'alg*' No No
qawce 'cauchy' No No
================ ============== ========== =====================
The following provides a short description from [1]_ for each
routine.
qagse
is an integrator based on globally adaptive interval
subdivision in connection with extrapolation, which will
eliminate the effects of integrand singularities of
several types.
qagie
handles integration over infinite intervals. The infinite range is
mapped onto a finite interval and subsequently the same strategy as
in ``QAGS`` is applied.
qagpe
serves the same purposes as QAGS, but also allows the
user to provide explicit information about the location
and type of trouble-spots i.e. the abscissae of internal
singularities, discontinuities and other difficulties of
the integrand function.
qawoe
is an integrator for the evaluation of
:math:`\int^b_a \cos(\omega x)f(x)dx` or
:math:`\int^b_a \sin(\omega x)f(x)dx`
over a finite interval [a,b], where :math:`\omega` and :math:`f`
are specified by the user. The rule evaluation component is based
on the modified Clenshaw-Curtis technique
An adaptive subdivision scheme is used in connection
with an extrapolation procedure, which is a modification
of that in ``QAGS`` and allows the algorithm to deal with
singularities in :math:`f(x)`.
qawfe
calculates the Fourier transform
:math:`\int^\infty_a \cos(\omega x)f(x)dx` or
:math:`\int^\infty_a \sin(\omega x)f(x)dx`
for user-provided :math:`\omega` and :math:`f`. The procedure of
``QAWO`` is applied on successive finite intervals, and convergence
acceleration by means of the :math:`\varepsilon`-algorithm is applied
to the series of integral approximations.
qawse
approximate :math:`\int^b_a w(x)f(x)dx`, with :math:`a < b` where
:math:`w(x) = (x-a)^{\alpha}(b-x)^{\beta}v(x)` with
:math:`\alpha,\beta > -1`, where :math:`v(x)` may be one of the
following functions: :math:`1`, :math:`\log(x-a)`, :math:`\log(b-x)`,
:math:`\log(x-a)\log(b-x)`.
The user specifies :math:`\alpha`, :math:`\beta` and the type of the
function :math:`v`. A globally adaptive subdivision strategy is
applied, with modified Clenshaw-Curtis integration on those
subintervals which contain `a` or `b`.
qawce
compute :math:`\int^b_a f(x) / (x-c)dx` where the integral must be
interpreted as a Cauchy principal value integral, for user specified
:math:`c` and :math:`f`. The strategy is globally adaptive. Modified
Clenshaw-Curtis integration is used on those intervals containing the
point :math:`x = c`.
**Integration of Complex Function of a Real Variable**
A complex valued function, :math:`f`, of a real variable can be written as
:math:`f = g + ih`. Similarly, the integral of :math:`f` can be
written as
.. math::
\int_a^b f(x) dx = \int_a^b g(x) dx + i\int_a^b h(x) dx
assuming that the integrals of :math:`g` and :math:`h` exist
over the interval :math:`[a,b]` [2]_. Therefore, ``quad`` integrates
complex-valued functions by integrating the real and imaginary components
separately.
References
----------
.. [1] Piessens, Robert; de Doncker-Kapenga, Elise;
Überhuber, Christoph W.; Kahaner, David (1983).
QUADPACK: A subroutine package for automatic integration.
Springer-Verlag.
ISBN 978-3-540-12553-2.
.. [2] McCullough, Thomas; Phillips, Keith (1973).
Foundations of Analysis in the Complex Plane.
Holt Rinehart Winston.
ISBN 0-03-086370-8
Examples
--------
Calculate :math:`\int^4_0 x^2 dx` and compare with an analytic result
>>> from scipy import integrate
>>> import numpy as np
>>> x2 = lambda x: x**2
>>> integrate.quad(x2, 0, 4)
(21.333333333333332, 2.3684757858670003e-13)
>>> print(4**3 / 3.) # analytical result
21.3333333333
Calculate :math:`\int^\infty_0 e^{-x} dx`
>>> invexp = lambda x: np.exp(-x)
>>> integrate.quad(invexp, 0, np.inf)
(1.0, 5.842605999138044e-11)
Calculate :math:`\int^1_0 a x \,dx` for :math:`a = 1, 3`
>>> f = lambda x, a: a*x
>>> y, err = integrate.quad(f, 0, 1, args=(1,))
>>> y
0.5
>>> y, err = integrate.quad(f, 0, 1, args=(3,))
>>> y
1.5
Calculate :math:`\int^1_0 x^2 + y^2 dx` with ctypes, holding
y parameter as 1::
testlib.c =>
double func(int n, double args[n]){
return args[0]*args[0] + args[1]*args[1];}
compile to library testlib.*
::
from scipy import integrate
import ctypes
lib = ctypes.CDLL('/home/.../testlib.*') #use absolute path
lib.func.restype = ctypes.c_double
lib.func.argtypes = (ctypes.c_int,ctypes.c_double)
integrate.quad(lib.func,0,1,(1))
#(1.3333333333333333, 1.4802973661668752e-14)
print((1.0**3/3.0 + 1.0) - (0.0**3/3.0 + 0.0)) #Analytic result
# 1.3333333333333333
Be aware that pulse shapes and other sharp features as compared to the
size of the integration interval may not be integrated correctly using
this method. A simplified example of this limitation is integrating a
y-axis reflected step function with many zero values within the integrals
bounds.
>>> y = lambda x: 1 if x<=0 else 0
>>> integrate.quad(y, -1, 1)
(1.0, 1.1102230246251565e-14)
>>> integrate.quad(y, -1, 100)
(1.0000000002199108, 1.0189464580163188e-08)
>>> integrate.quad(y, -1, 10000)
(0.0, 0.0)
svgpathtools.path.radians
Python Library Documentation: ufunc
radians = <ufunc 'radians'>
radians(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Convert angles from degrees to radians.
Parameters
----------
x : array_like
Input array in degrees.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray
The corresponding radian values.
This is a scalar if `x` is a scalar.
See Also
--------
deg2rad : equivalent function
Examples
--------
>>> import numpy as np
Convert a degree array to radians
>>> deg = np.arange(12.) * 30.
>>> np.radians(deg)
array([ 0. , 0.52359878, 1.04719755, 1.57079633, 2.0943951 ,
2.61799388, 3.14159265, 3.66519143, 4.1887902 , 4.71238898,
5.23598776, 5.75958653])
>>> out = np.zeros((deg.shape))
>>> ret = np.radians(deg, out)
>>> ret is out
True
svgpathtools.path.rational_limit
Python Library Documentation: function rational_limit in module svgpathtools.polytools
rational_limit(f, g, t0)
Computes the limit of the rational function (f/g)(t)
as t approaches t0.
svgpathtools.path.real
Python Library Documentation: function real in module svgpathtools.polytools real(z)
svgpathtools.path.reduce
Python Library Documentation: built-in function reduce in module _functools
reduce(...)
reduce(function, iterable[, initial]) -> value
Apply a function of two arguments cumulatively to the items of a sequence
or iterable, from left to right, so as to reduce the iterable to a single
value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
((((1+2)+3)+4)+5). If initial is present, it is placed before the items
of the iterable in the calculation, and serves as a default when the
iterable is empty.
svgpathtools.path.rotate
Python Library Documentation: function rotate in module svgpathtools.path
rotate(curve, degs, origin=None)
Returns curve rotated by `degs` degrees (CCW) around the point `origin`
(a complex number). By default origin is either `curve.point(0.5)`, or in
the case that curve is an Arc object, `origin` defaults to `curve.center`.
svgpathtools.path.scale
Python Library Documentation: function scale in module svgpathtools.path
scale(curve, sx, sy=None, origin=0j)
Scales `curve`, about `origin`, by diagonal matrix `[[sx,0],[0,sy]]`.
Notes:
------
* If `sy` is not specified, it is assumed to be equal to `sx` and
a scalar transformation of `curve` about `origin` will be returned.
I.e.
scale(curve, sx, origin).point(t) ==
((curve.point(t) - origin) * sx) + origin
svgpathtools.path.segment_curvature
Python Library Documentation: function segment_curvature in module svgpathtools.path
segment_curvature(self, t, use_inf=False)
returns the curvature of the segment at t.
Notes
-----
If you receive a RuntimeWarning, run command
>>> old = np.seterr(invalid='raise')
This can be undone with
>>> np.seterr(**old)
svgpathtools.path.segment_length
Python Library Documentation: function segment_length in module svgpathtools.path
segment_length(curve, start, end, start_point, end_point, error=1e-12, min_depth=5, depth=0)
Recursively approximates the length by straight lines
svgpathtools.path.sin
Python Library Documentation: ufunc
sin = <ufunc 'sin'>
sin(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Trigonometric sine, element-wise.
Parameters
----------
x : array_like
Angle, in radians (:math:`2 \pi` rad equals 360 degrees).
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : array_like
The sine of each element of x.
This is a scalar if `x` is a scalar.
See Also
--------
arcsin, sinh, cos
Notes
-----
The sine is one of the fundamental functions of trigonometry (the
mathematical study of triangles). Consider a circle of radius 1
centered on the origin. A ray comes in from the :math:`+x` axis, makes
an angle at the origin (measured counter-clockwise from that axis), and
departs from the origin. The :math:`y` coordinate of the outgoing
ray's intersection with the unit circle is the sine of that angle. It
ranges from -1 for :math:`x=3\pi / 2` to +1 for :math:`\pi / 2.` The
function has zeroes where the angle is a multiple of :math:`\pi`.
Sines of angles between :math:`\pi` and :math:`2\pi` are negative.
The numerous properties of the sine and related functions are included
in any standard trigonometry text.
Examples
--------
>>> import numpy as np
Print sine of one angle:
>>> np.sin(np.pi/2.)
1.0
Print sines of an array of angles given in degrees:
>>> np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180. )
array([ 0. , 0.5 , 0.70710678, 0.8660254 , 1. ])
Plot the sine function:
>>> import matplotlib.pylab as plt
>>> x = np.linspace(-np.pi, np.pi, 201)
>>> plt.plot(x, np.sin(x))
>>> plt.xlabel('Angle [rad]')
>>> plt.ylabel('sin(x)')
>>> plt.axis('tight')
>>> plt.show()
svgpathtools.path.split_bezier
Python Library Documentation: function split_bezier in module svgpathtools.bezier
split_bezier(bpoints, t)
Uses deCasteljau's recursion to split the Bezier curve at t into two
Bezier curves of the same order.
svgpathtools.path.sqrt
Python Library Documentation: ufunc
sqrt = <ufunc 'sqrt'>
sqrt(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Return the non-negative square-root of an array, element-wise.
Parameters
----------
x : array_like
The values whose square-roots are required.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray
An array of the same shape as `x`, containing the positive
square-root of each element in `x`. If any element in `x` is
complex, a complex array is returned (and the square-roots of
negative reals are calculated). If all of the elements in `x`
are real, so is `y`, with negative elements returning ``nan``.
If `out` was provided, `y` is a reference to it.
This is a scalar if `x` is a scalar.
See Also
--------
emath.sqrt
A version which returns complex numbers when given negative reals.
Note that 0.0 and -0.0 are handled differently for complex inputs.
Notes
-----
*sqrt* has--consistent with common convention--as its branch cut the
real "interval" [`-inf`, 0), and is continuous from above on it.
A branch cut is a curve in the complex plane across which a given
complex function fails to be continuous.
Examples
--------
>>> import numpy as np
>>> np.sqrt([1,4,9])
array([ 1., 2., 3.])
>>> np.sqrt([4, -1, -3+4J])
array([ 2.+0.j, 0.+1.j, 1.+2.j])
>>> np.sqrt([4, -1, np.inf])
array([ 2., nan, inf])
svgpathtools.path.tan
Python Library Documentation: ufunc
tan = <ufunc 'tan'>
tan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
Compute tangent element-wise.
Equivalent to ``np.sin(x)/np.cos(x)`` element-wise.
Parameters
----------
x : array_like
Input array.
out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
This condition is broadcast over the input. At locations where the
condition is True, the `out` array will be set to the ufunc result.
Elsewhere, the `out` array will retain its original value.
Note that if an uninitialized `out` array is created via the default
``out=None``, locations within it where the condition is False will
remain uninitialized.
**kwargs
For other keyword-only arguments, see the
:ref:`ufunc docs <ufuncs.kwargs>`.
Returns
-------
y : ndarray
The corresponding tangent values.
This is a scalar if `x` is a scalar.
Notes
-----
If `out` is provided, the function writes the result into it,
and returns a reference to `out`. (See Examples)
References
----------
M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions.
New York, NY: Dover, 1972.
Examples
--------
>>> import numpy as np
>>> from math import pi
>>> np.tan(np.array([-pi,pi/2,pi]))
array([ 1.22460635e-16, 1.63317787e+16, -1.22460635e-16])
>>>
>>> # Example of providing the optional output parameter illustrating
>>> # that what is returned is a reference to said parameter
>>> out1 = np.array([0], dtype='d')
>>> out2 = np.cos([0.1], out1)
>>> out2 is out1
True
>>>
>>> # Example of ValueError due to provision of shape mis-matched `out`
>>> np.cos(np.zeros((3,3)),np.zeros((2,2)))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: operands could not be broadcast together with shapes (3,3) (2,2)
svgpathtools.path.tee
Python Library Documentation: built-in function tee in module itertools
tee(iterable, n=2, /)
Returns a tuple of n independent iterators.
svgpathtools.path.transform
Python Library Documentation: function transform in module svgpathtools.path
transform(curve, tf)
Transforms the curve by the homogeneous transformation matrix tf
svgpathtools.path.transform_segments_together
Python Library Documentation: function transform_segments_together in module svgpathtools.path
transform_segments_together(path, transformation)
Makes sure that, if joints were continuous, they're kept that way.
svgpathtools.path.translate
Python Library Documentation: function translate in module svgpathtools.path
translate(curve, z0)
Shifts the curve by the complex quantity z such that
translate(curve, z0).point(t) = curve.point(t) + z0
svgpathtools.path.warn
Python Library Documentation: built-in function warn in module _warnings
warn(...)
Issue a warning, or maybe ignore it or raise an exception.
message
Text of the warning message.
category
The Warning category subclass. Defaults to UserWarning.
stacklevel
How far up the call stack to make this warning appear. A value of 2 for
example attributes the warning to the caller of the code calling warn().
source
If supplied, the destroyed object which emitted a ResourceWarning
skip_file_prefixes
An optional tuple of module filename prefixes indicating frames to skip
during stacklevel computations for stack frame attribution.
svgpathtools.parser.Path
Python Library Documentation: class Path in module svgpathtools.path
class Path(collections.abc.MutableSequence)
| Path(*segments, **kw)
|
| A Path is a sequence of path segments
|
| Method resolution order:
| Path
| collections.abc.MutableSequence
| collections.abc.Sequence
| collections.abc.Reversible
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| T2t(self, T)
| returns the segment index, `seg_idx`, and segment parameter, `t`,
| corresponding to the path parameter `T`. In other words, this is the
| inverse of the `Path.t2T()` method.
|
| __contains__(self, x)
|
| __delitem__(self, index)
|
| __eq__(self, other)
| Return self==value.
|
| __getitem__(self, index)
|
| __hash__(self) -> 'int'
| Return hash(self).
|
| __init__(self, *segments, **kw)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
|
| __len__(self)
|
| __ne__(self, other)
| Return self!=value.
|
| __repr__(self)
| Return repr(self).
|
| __setitem__(self, index, value)
|
| approximate_arcs_with_cubics(self, error=0.1)
| Iterates through this path and replaces any Arcs with cubic bezier curves.
|
| approximate_arcs_with_quads(self, error=0.1)
| Iterates through this path and replaces any Arcs with quadratic bezier curves.
|
| area(self, chord_length=0.0001)
| Find area enclosed by path.
|
| Approximates any Arc segments in the Path with lines
| approximately `chord_length` long, and returns the area enclosed
| by the approximated Path. Default chord length is 0.01. If Arc
| segments are included in path, to ensure accurate results, make
| sure this `chord_length` is set to a reasonable value (e.g. by
| checking curvature).
|
| Notes
| -----
| * Negative area results from clockwise (as opposed to
| counter-clockwise) parameterization of the input Path.
|
| To Contributors
| ---------------
| This is one of many parts of `svgpathtools` that could be
| improved by a noble soul implementing a piecewise-linear
| approximation scheme for paths (one with controls to guarantee a
| desired accuracy).
|
| bbox(self)
| returns bounding box in the form (xmin, xmax, ymin, ymax).
|
| continuous_subpaths(self)
| Breaks self into its continuous components, returning a list of
| continuous subpaths.
| I.e.
| (all(subpath.iscontinuous() for subpath in self.continuous_subpaths())
| and self == concatpaths(self.continuous_subpaths()))
| )
|
| cropped(self, T0, T1)
| returns a cropped copy of the path.
|
| curvature(self, T)
| returns the curvature of this Path object at T and outputs
| float('inf') if not differentiable at T.
|
| d(self, useSandT=False, use_closed_attrib=False, rel=False)
| Returns a path d-string for the path object.
| For an explanation of useSandT and use_closed_attrib, see the
| compatibility notes in the README.
|
| derivative(self, T, n=1)
| returns the tangent vector of the Path at T (centered at the origin
| and expressed as a complex number).
| Note: Bezier curves can have points where their derivative vanishes.
| If you are interested in the tangent direction, use unit_tangent()
| method instead.
|
| ilength(self, s, s_tol=1e-12, maxits=10000, error=1e-12, min_depth=5)
| Returns a float, t, such that self.length(0, t) is approximately s.
| See the inv_arclength() docstring for more details.
|
| insert(self, index, value)
| S.insert(index, value) -- insert value before index
|
| intersect(self, other_curve, justonemode=False, tol=1e-12)
| Finds intersections of `self` with `other_curve`
|
| Args:
| other_curve: the path or path segment to check for intersections
| with `self`
| justonemode (bool): if true, returns only the first
| intersection found.
| tol (float): A tolerance used to check for redundant intersections
| (see comment above the code block where tol is used).
|
| Returns:
| (list[tuple[float, Curve, float]]): list of intersections, each
| in the format ((T1, seg1, t1), (T2, seg2, t2)), where
| self.point(T1) == seg1.point(t1) == seg2.point(t2) == other_curve.point(T2)
|
| Scope:
| If the two path objects coincide for more than a finite set of
| points, this code will iterate to max depth and/or raise an error.
|
| is_contained_by(self, other)
| Returns true if the path is fully contained in other closed path
|
| isclosed(self)
| This function determines if a connected path is closed.
|
| isclosedac(self)
|
| iscontinuous(self)
| Checks if a path is continuous with respect to its
| parameterization.
|
| joins_smoothly_with(self, previous, wrt_parameterization=False)
| Checks if this Path object joins smoothly with previous
| path/segment. By default, this only checks that this Path starts
| moving (at t=0) in the same direction (and from the same positive) as
| previous stopped moving (at t=1). To check if the tangent magnitudes
| also match, set wrt_parameterization=True.
|
| joints(self)
| returns generator of segment joints
|
| I.e. Path(s0, s1, s2, ..., sn).joints() returns generator
| (s0, s1), (s1, s2), ..., (sn, s0)
|
| credit: https://docs.python.org/3/library/itertools.html#recipes
|
| length(self, T0=0, T1=1, error=1e-12, min_depth=5)
|
| normal(self, t)
| returns the (right hand rule) unit normal vector to self at t.
|
| point(self, pos)
|
| radialrange(self, origin, return_all_global_extrema=False)
| returns the tuples (d_min, t_min, idx_min), (d_max, t_max, idx_max)
| which minimize and maximize, respectively, the distance
| d = |self[idx].point(t)-origin|.
|
| reversed(self)
| returns a copy of the Path object with its orientation reversed.
|
| rotated(self, degs, origin=None)
| Returns a copy of self rotated by `degs` degrees (CCW) around the
| point `origin` (a complex number). By default `origin` is either
| `self.point(0.5)`, or in the case that self is an Arc object,
| `origin` defaults to `self.center`.
|
| scaled(self, sx, sy=None, origin=0j)
| Scale transform. See `scale` function for further explanation.
|
| t2T(self, seg, t)
| returns the path parameter T which corresponds to the segment
| parameter t. In other words, for any Path object, path, and any
| segment in path, seg, T(t) = path.t2T(seg, t) is the unique
| reparameterization such that path.point(T(t)) == seg.point(t) for all
| 0 <= t <= 1.
| Input Note: seg can be a segment in the Path object or its
| corresponding index.
|
| translated(self, z0)
| Returns a copy of self shifted by the complex quantity `z0` such
| that self.translated(z0).point(t) = self.point(t) + z0 for any t.
|
| unit_tangent(self, T)
| returns the unit tangent vector of the Path at T (centered at the
| origin and expressed as a complex number). If the tangent vector's
| magnitude is zero, this method will find the limit of
| self.derivative(tau)/abs(self.derivative(tau)) as tau approaches T.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| closed
| The closed attribute is deprecated, please use the isclosed()
| method instead. See _closed_warning for more information.
|
| end
|
| start
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| element = None
|
| meta = None
|
| transform = None
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableSequence:
|
| __iadd__(self, values)
|
| append(self, value)
| S.append(value) -- append value to the end of the sequence
|
| clear(self)
| S.clear() -> None -- remove all items from S
|
| extend(self, values)
| S.extend(iterable) -- extend sequence by appending elements from the iterable
|
| pop(self, index=-1)
| S.pop([index]) -> item -- remove and return item at index (default last).
| Raise IndexError if list is empty or index is out of range.
|
| remove(self, value)
| S.remove(value) -- remove first occurrence of value.
| Raise ValueError if the value is not present.
|
| reverse(self)
| S.reverse() -- reverse *IN PLACE*
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Sequence:
|
| __reversed__(self)
|
| count(self, value)
| S.count(value) -> integer -- return number of occurrences of value
|
| index(self, value, start=0, stop=None)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
svgpathtools.parser.absolute_import
Python Library Documentation: _Feature in module __future__ object class _Feature(builtins.object) | _Feature(optionalRelease, mandatoryRelease, compiler_flag) | | Methods defined here: | | __init__(self, optionalRelease, mandatoryRelease, compiler_flag) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | getMandatoryRelease(self) | Return release in which this feature will become mandatory. | | This is a 5-tuple, of the same form as sys.version_info, or, if | the feature was dropped, or the release date is undetermined, is None. | | getOptionalRelease(self) | Return first release in which this feature was recognized. | | This is a 5-tuple, of the same form as sys.version_info. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.parser.division
Python Library Documentation: _Feature in module __future__ object class _Feature(builtins.object) | _Feature(optionalRelease, mandatoryRelease, compiler_flag) | | Methods defined here: | | __init__(self, optionalRelease, mandatoryRelease, compiler_flag) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | getMandatoryRelease(self) | Return release in which this feature will become mandatory. | | This is a 5-tuple, of the same form as sys.version_info, or, if | the feature was dropped, or the release date is undetermined, is None. | | getOptionalRelease(self) | Return first release in which this feature was recognized. | | This is a 5-tuple, of the same form as sys.version_info. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgpathtools.parser.parse_path
Python Library Documentation: function parse_path in module svgpathtools.parser parse_path(pathdef, current_pos=0j, tree_element=None)
svgpathtools.parser.parse_transform
Python Library Documentation: function parse_transform in module svgpathtools.parser
parse_transform(transform_str)
Converts a valid SVG transformation string into a 3x3 matrix.
If the string is empty or null, this returns a 3x3 identity matrix
svgpathtools.parser.print_function
Python Library Documentation: _Feature in module __future__ object class _Feature(builtins.object) | _Feature(optionalRelease, mandatoryRelease, compiler_flag) | | Methods defined here: | | __init__(self, optionalRelease, mandatoryRelease, compiler_flag) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | getMandatoryRelease(self) | Return release in which this feature will become mandatory. | | This is a 5-tuple, of the same form as sys.version_info, or, if | the feature was dropped, or the release date is undetermined, is None. | | getOptionalRelease(self) | Return first release in which this feature was recognized. | | This is a 5-tuple, of the same form as sys.version_info. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object