Sign in

    Lampese/mathplotlib/transforms does not have a README file

    BezierError

    pub(all) suberror BezierError {
    InvalidControlPoints(message~ : String)
    InvalidParameter(message~ : String)
    }

    Errors raised by Bezier segment construction and sampling.

    PathError

    pub(all) suberror PathError {
    InvalidCodes(message~ : String)
    InvalidVertex(message~ : String)
    }

    Errors raised while constructing a geometric path.

    TransformError

    pub(all) suberror TransformError {
    Singular
    }

    Errors raised by transform operations.

    Affine2D

    pub struct Affine2D {
    a : Double
    b : Double
    c : Double
    d : Double
    e : Double
    f : Double
    }

    A two-dimensional affine transform represented as x' = ax + cy + e and y' = bx + dy + f.

    Affine2D::apply

    Apply a transform to one point.

    Affine2D::apply_all

    Apply a transform to an array without mutating the input.

    Affine2D::apply_delta

    Apply only the linear part of a transform to a displacement vector.

    Affine2D::compose

    fn Affine2D::compose(self : Affine2D, other : Affine2D) -> Affine2D

    Compose two transforms using the same order as then.

    Affine2D::determinant

    fn Affine2D::determinant(self : Affine2D) -> Double

    Return the linear-part determinant.

    Affine2D::inverse

    fn Affine2D::inverse(self : Affine2D) -> Affine2D raise TransformError

    Compute the inverse transform.

    Affine2D::is_separable

    fn Affine2D::is_separable(self : Affine2D) -> Bool

    Whether x and y are transformed independently.

    Affine2D::matrix

    fn Affine2D::matrix(self : Affine2D) -> Array[Array[Double]]

    Return the affine matrix as three row-major rows.

    Affine2D::rotated

    fn Affine2D::rotated(self : Affine2D, radians : Double) -> Affine2D

    Return a transform with an additional rotation applied after self.

    Affine2D::scaled

    fn Affine2D::scaled(self : Affine2D, x : Double, y : Double) -> Affine2D

    Return a transform with an additional scale applied after self.

    Affine2D::skewed

    fn Affine2D::skewed(self : Affine2D, x_radians : Double, y_radians : Double) -> Affine2D

    Return a transform with an additional shear applied after self.

    Affine2D::then

    fn Affine2D::then(self : Affine2D, other : Affine2D) -> Affine2D

    Compose transforms so the returned transform applies other first.

    Affine2D::to_values

    fn Affine2D::to_values(self : Affine2D) -> (Double, Double, Double, Double, Double, Double)

    Return the six affine matrix values in (a, b, c, d, e, f) order.

    Affine2D::translated

    fn Affine2D::translated(self : Affine2D, x : Double, y : Double) -> Affine2D

    Return a transform with an additional translation applied after self.

    BBox

    pub struct BBox {
    x0 : Double
    y0 : Double
    x1 : Double
    y1 : Double
    }

    An axis-aligned rectangle in data or display coordinates.

    BBox::bounds

    fn BBox::bounds(self : BBox) -> (Double, Double, Double, Double)

    Return (x0, y0, width, height) using the box's original orientation.

    BBox::contains

    fn BBox::contains(self : BBox, x : Double, y : Double) -> Bool

    BBox::contains_point

    fn BBox::contains_point(self : BBox, point :
    Point
    ) -> Bool

    BBox::contains_x

    fn BBox::contains_x(self : BBox, x : Double) -> Bool

    Return whether x lies in the closed interval, including reversed bounds.

    BBox::contains_y

    fn BBox::contains_y(self : BBox, y : Double) -> Bool

    Return whether y lies in the closed interval, including reversed bounds.

    BBox::corners

    BBox::expanded

    fn BBox::expanded(self : BBox, x_scale : Double, y_scale : Double) -> BBox

    BBox::fully_contains

    fn BBox::fully_contains(self : BBox, x : Double, y : Double) -> Bool

    Return whether a point lies strictly inside the box.

    BBox::fully_contains_x

    fn BBox::fully_contains_x(self : BBox, x : Double) -> Bool

    Return whether x lies strictly inside the interval.

    BBox::fully_contains_y

    fn BBox::fully_contains_y(self : BBox, y : Double) -> Bool

    Return whether y lies strictly inside the interval.

    BBox::fully_overlaps

    fn BBox::fully_overlaps(self : BBox, other : BBox) -> Bool

    Return whether the interiors of two boxes overlap.

    BBox::height

    fn BBox::height(self : BBox) -> Double

    BBox::intersection

    fn BBox::intersection(self : BBox, other : BBox) -> BBox?

    BBox::interval_x

    fn BBox::interval_x(self : BBox) -> (Double, Double)

    Return the original x interval, preserving its orientation.

    BBox::interval_y

    fn BBox::interval_y(self : BBox) -> (Double, Double)

    Return the original y interval, preserving its orientation.

    BBox::is_finite

    fn BBox::is_finite(self : BBox) -> Bool

    BBox::max_point

    Return the upper-right coordinate after normalizing each axis.

    BBox::min_point

    Return the lower-left coordinate after normalizing each axis.

    BBox::overlaps

    fn BBox::overlaps(self : BBox, other : BBox) -> Bool

    BBox::padded

    fn BBox::padded(self : BBox, x : Double, y : Double) -> BBox

    BBox::rotated

    fn BBox::rotated(self : BBox, radians : Double) -> BBox

    Return an axis-aligned box containing this box after rotation around the origin.

    BBox::shrunk

    fn BBox::shrunk(self : BBox, x_scale : Double, y_scale : Double) -> BBox

    Shrink or expand from the lower-left corner by axis factors.

    BBox::shrunk_to_aspect

    fn BBox::shrunk_to_aspect(self : BBox, box_aspect : Double, container? : BBox, fig_aspect? : Double) -> BBox

    Shrink the box to the largest rectangle with the requested physical aspect ratio. The result keeps the original lower-left corner.

    BBox::size

    fn BBox::size(self : BBox) -> (Double, Double)

    Return the signed (width, height) pair.

    BBox::split_x

    fn BBox::split_x(self : BBox, fractions : Array[Double]) -> Array[BBox]

    Split the box at fractional x positions in [0, 1].

    BBox::split_y

    fn BBox::split_y(self : BBox, fractions : Array[Double]) -> Array[BBox]

    Split the box at fractional y positions in [0, 1].

    BBox::transformed

    fn BBox::transformed(self : BBox, transform : Affine2D) -> BBox

    Transform all four corners and return the enclosing axis-aligned box.

    BBox::translated

    fn BBox::translated(self : BBox, x : Double, y : Double) -> BBox

    BBox::union

    fn BBox::union(self : BBox, other : BBox) -> BBox

    BBox::width

    fn BBox::width(self : BBox) -> Double

    BBox::x0

    fn BBox::x0(self : BBox) -> Double

    BBox::x1

    fn BBox::x1(self : BBox) -> Double

    BBox::xmax

    fn BBox::xmax(self : BBox) -> Double

    BBox::xmin

    fn BBox::xmin(self : BBox) -> Double

    BBox::y0

    fn BBox::y0(self : BBox) -> Double

    BBox::y1

    fn BBox::y1(self : BBox) -> Double

    BBox::ymax

    fn BBox::ymax(self : BBox) -> Double

    BBox::ymin

    fn BBox::ymin(self : BBox) -> Double

    BezierSegment

    pub struct BezierSegment {
    control_points : Array[
    Point
    ]
    }

    A quadratic or cubic Bezier segment.

    BezierSegment::control_points

    BezierSegment::degree

    fn BezierSegment::degree(self : BezierSegment) -> Int

    BezierSegment::evaluate

    Evaluate the segment at parameter t using de Casteljau interpolation.

    BezierSegment::length

    fn BezierSegment::length(self : BezierSegment, steps? : Int) -> Double raise BezierError

    Approximate arc length by summing a sampled polyline.

    BezierSegment::sample

    Sample a polyline approximation with steps equal intervals.

    BezierSegment::split

    fn BezierSegment::split(self : BezierSegment, t : Double) -> (BezierSegment, BezierSegment) raise BezierError

    Split the segment into two segments at parameter t.

    Path

    pub struct Path {
    vertices : Array[
    Point
    ]
    codes : Array[PathCode]
    }

    A backend-independent sequence of line and curve vertices.

    Path::clip_to_bbox

    fn Path::clip_to_bbox(self : Path, clip_box : BBox, inside? : Bool) -> Path raise PathError

    Clip closed path components to an axis-aligned rectangle.

    Curves are flattened with the same deterministic sampling used by contains_point; the result is therefore a valid line-only path. With inside=false, the rectangle complement is emitted as four disjoint half-plane pieces so points in the rectangle are removed without relying on a backend-specific fill rule.

    Path::codes

    fn Path::codes(self : Path) -> Array[PathCode]

    Path::contains_point

    fn Path::contains_point(self : Path, point :
    Point
    ) -> Bool

    Test whether a point lies inside the path using the even-odd rule.

    Path::extents

    fn Path::extents(self : Path) -> BBox?

    Return the axis-aligned bounds of the geometry represented by the path.

    For quadratic and cubic segments this includes the interior extrema of the Bezier polynomial, rather than merely the control points. This is the behavior required by Matplotlib's Path.get_extents and is important for clipping and layout calculations.

    Path::length

    fn Path::length(self : Path) -> Int

    Path::transformed

    fn Path::transformed(self : Path, transform : Affine2D) -> Path raise PathError

    Apply an affine transform without mutating the path.

    Path::vertices

    PathCode

    pub(all) enum PathCode {
    Stop
    MoveTo
    LineTo
    Curve3
    Curve4
    ClosePoly
    } derive(Eq,
    Debug
    )

    Commands attached to vertices in a path.

    PathCode::equal

    fn PathCode::equal(PathCode, PathCode) -> Bool

    PathCode::not_equal

    fn PathCode::not_equal(x : PathCode, y : PathCode) -> Bool

    PathCode::to_repr

    Transform2D

    pub(all) enum Transform2D {
    Affine(Affine2D)
    Composite(Transform2D, Transform2D)
    BboxMap(BBox, BBox)
    BboxTo(BBox)
    BboxFrom(BBox)
    Blended(Transform2D, Transform2D)
    ScaledTranslation(Double, Double, Affine2D)
    }

    A composable two-dimensional transform tree.

    Every constructor in this first tree is affine in the plane, but keeping composition explicit mirrors Matplotlib's transform graph and lets layout code carry one value through point, path, and BBox operations.

    Transform2D::affine

    fn Transform2D::affine(self : Transform2D) -> Affine2D

    Materialize the current tree as one affine transform.

    Transform2D::apply

    Apply the transform to one point.

    Transform2D::apply_all

    Apply the transform to an array without mutating the input.

    Transform2D::apply_delta

    Apply the transform to a displacement vector.

    Transform2D::inverse

    fn Transform2D::inverse(self : Transform2D) -> Transform2D raise TransformError

    Invert the transform tree.

    Transform2D::is_separable

    fn Transform2D::is_separable(self : Transform2D) -> Bool

    Return whether the materialized transform has no x/y cross terms.

    Transform2D::then

    fn Transform2D::then(self : Transform2D, other : Transform2D) -> Transform2D

    Compose a tree transform using the same order as Affine2D::then.

    Transform2D::transform_bbox

    fn Transform2D::transform_bbox(self : Transform2D, value : BBox) -> BBox

    Transform all four corners and return the enclosing axis-aligned box.

    Transform2D::transform_path

    fn Transform2D::transform_path(self : Transform2D, value : Path) -> Path raise PathError

    Transform every vertex and code in a path.

    affine_from_values

    fn affine_from_values(a : Double, b : Double, c : Double, d : Double, e : Double, f : Double) -> Affine2D

    Construct an affine transform directly from the six non-trivial matrix values. The matrix is [[a, c, e], [b, d, f], [0, 0, 1]].

    affine_transform

    fn affine_transform(value : Affine2D) -> Transform2D

    Wrap an affine transform in the transform tree.

    bbox

    fn bbox(x0 : Double, y0 : Double, x1 : Double, y1 : Double) -> BBox

    Construct a bounding box from its two corners.

    bbox_from_bounds

    fn bbox_from_bounds(x : Double, y : Double, width : Double, height : Double) -> BBox

    Construct a box from an origin and its width and height.

    bbox_transform

    fn bbox_transform(input : BBox, output : BBox) -> Transform2D

    Map coordinates linearly from one bounding box to another.

    bbox_transform_from

    fn bbox_transform_from(input : BBox) -> Transform2D

    Map input to the unit box.

    bbox_transform_to

    fn bbox_transform_to(output : BBox) -> Transform2D

    Map the unit box to output.

    blended_transform

    fn blended_transform(x_transform : Transform2D, y_transform : Transform2D) -> Transform2D

    Use one transform for the x coordinate and another for y.

    composite_transform

    fn composite_transform(first : Transform2D, second : Transform2D) -> Transform2D

    Compose transforms so that second is applied first, matching Affine2D::then.

    cubic_bezier

    Construct a cubic Bezier segment.

    identity

    fn identity() -> Affine2D

    Construct the identity transform.

    identity_transform

    fn identity_transform() -> Transform2D

    Return the identity transform as a tree node.

    line_path

    fn line_path(vertices : Array[
    Point
    ]) -> Path raise PathError

    Construct a polyline path.

    null_bbox

    fn null_bbox() -> BBox

    Construct an empty box whose extents can be expanded by union operations.

    path

    fn path(vertices : Array[
    Point
    ], codes? : Array[PathCode]) -> Path raise PathError

    Construct a path. Empty codes default to one move followed by line segments.

    polygon_path

    fn polygon_path(vertices : Array[
    Point
    ]) -> Path raise PathError

    Construct a closed polygon path.

    quadratic_bezier

    Construct a quadratic Bezier segment.

    rectangle_path

    fn rectangle_path(box : BBox) -> Path raise PathError

    Construct a rectangular closed path.

    rotation

    fn rotation(radians : Double) -> Affine2D

    Construct a counter-clockwise rotation in radians around the origin.

    rotation_degrees

    fn rotation_degrees(degrees : Double) -> Affine2D

    Construct a rotation in degrees around the origin.

    scaled_translation

    fn scaled_translation(x : Double, y : Double, scale_transform : Affine2D) -> Transform2D

    Translate by (x, y) after expressing that offset in scale_transform's coordinate system. This is the transform-tree equivalent of Matplotlib's ScaledTranslation.

    scaling

    fn scaling(x : Double, y : Double) -> Affine2D

    Construct a scaling transform.

    skew

    fn skew(x_radians : Double, y_radians : Double) -> Affine2D

    Construct an x/y shear transform. The arguments are shear angles in radians, matching Matplotlib's Affine2D.skew convention.

    skew_degrees

    fn skew_degrees(x_degrees : Double, y_degrees : Double) -> Affine2D

    Construct an x/y shear transform from degree angles.

    translation

    fn translation(x : Double, y : Double) -> Affine2D

    Construct a translation transform.

    unit_bbox

    fn unit_bbox() -> BBox

    Construct the unit box from (0, 0) to (1, 1).