Utility classes for drawing routines.
Class |
|
Class representing a bounding box (a rectangular area) that encloses some objects. |
Class |
|
Fake module that raises an exception for everything |
Class |
|
Class representing a point on the 2D plane. |
Class |
|
Class representing a rectangle. |
Function | autocurve |
Calculates curvature values for each of the edges in the graph to make sure that multiple edges are shown properly on a graph plot. |
Function | calculate |
Given a list of points and a desired corner radius, returns a list containing proposed corner radii for each of the points such that it is ensured that the corner radius at a point is never larger than half of the minimum distance between the point and its neighbors. |
Function | euclidean |
Computes the Euclidean distance between points (x1,y1) and (x2,y2). |
Function | evaluate |
Evaluates the Bezier curve from point (x0,y0) to (x3,y3) via control points (x1,y1) and (x2,y2) at t. t is typically in the range [0; 1] such that 0 returns (x0, y0) and 1 returns (x3, y3). |
Function | get |
Helper function that calculates the Bezier control points for a curved edge that goes from (x1, y1) to (x2, y2). |
Function | intersect |
Binary search solver for finding the intersection of a Bezier curve and a circle centered at the curve's end point. |
Function | str |
Tries to interpret a string as an orientation value. |
Calculates curvature values for each of the edges in the graph to make sure that multiple edges are shown properly on a graph plot.
This function checks the multiplicity of each edge in the graph and assigns curvature values (numbers between -1 and 1, corresponding to CCW (-1), straight (0) and CW (1) curved edges) to them. The assigned values are either stored in an edge attribute or returned as a list, depending on the value of the attribute argument.
Parameters | |
graph | the graph on which the calculation will be run |
attribute | the name of the edge attribute to save the curvature values to. The default value is curved, which is the name of the edge attribute the default graph plotter checks to decide whether an edge should be curved on the plot or not. If attribute is None, the result will not be stored. |
default | the default curvature for single edges. Zero means that single edges will be straight. If you want single edges to be curved as well, try passing 0.5 or -0.5 here. |
Returns | |
the list of curvature values if attribute is None, otherwise None. |
Given a list of points and a desired corner radius, returns a list containing proposed corner radii for each of the points such that it is ensured that the corner radius at a point is never larger than half of the minimum distance between the point and its neighbors.
Evaluates the Bezier curve from point (x0,y0) to (x3,y3) via control points (x1,y1) and (x2,y2) at t. t is typically in the range [0; 1] such that 0 returns (x0, y0) and 1 returns (x3, y3).
Helper function that calculates the Bezier control points for a curved edge that goes from (x1, y1) to (x2, y2).
Binary search solver for finding the intersection of a Bezier curve and a circle centered at the curve's end point.
Returns the x, y coordinates of the intersection point.
Tries to interpret a string as an orientation value.
The following basic values are understood: ``left-right``, ``bottom-top``, ``right-left``, ``top-bottom``. Possible aliases are:
- ``horizontal``, ``horiz``, ``h`` and ``lr`` for ``left-right``
- ``vertical``, ``vert``, ``v`` and ``tb`` for top-bottom.
- ``lr`` for ``left-right``.
- ``rl`` for ``right-left``.
``reversed_horizontal`` reverses the meaning of ``horizontal``, ``horiz`` and ``h`` to ``rl`` (instead of ``lr``); similarly, ``reversed_vertical`` reverses the meaning of ``vertical``, ``vert`` and ``v`` to ``bt`` (instead of ``tb``).
Returns one of ``lr``, ``rl``, ``tb`` or ``bt``, or throws ``ValueError`` if the string cannot be interpreted as an orientation.