README

bobzhang/vg/geometry does not have a README file

#
Box

pub struct Box {
min_x : Double
min_y : Double
max_x : Double
max_y : Double
} derive(Eq,
Debug
)

Bounding box

#
Path

pub(all) struct Path(Array[PathSegment]) derive(Eq,
Debug
)

A path is a sequence of segments. pub(all) so downstream packages can build a segment array in one pass instead of through the copying builders.

#
Path::bounds

fn Path::bounds(self : Path) -> Box?

Get the bounding box of a path (approximate)

#
Path::circle

fn Path::circle(center : Point, radius : Double) -> Path

Create a circle path (approximated with bezier curves)

#
Path::close_path

fn Path::close_path(self : Path) -> Path

Close the path

#
Path::curve_to

fn Path::curve_to(self : Path, cp1 : Point, cp2 : Point, end : Point) -> Path

Cubic bezier curve to a point

#
Path::earc_to

fn Path::earc_to(self : Path, rx : Double, ry : Double, rotation : Double, large_arc : Bool, sweep : Bool, end : Point) -> Path

Elliptical arc to a point

#
Path::ellipse

fn Path::ellipse(center : Point, rx : Double, ry : Double) -> Path

Create an ellipse path

#
Path::empty

fn Path::empty() -> Path

Create an empty path

#
Path::line_to

fn Path::line_to(self : Path, p : Point) -> Path

Line to a point

#
Path::move_to

fn Path::move_to(self : Path, p : Point) -> Path

Move to a point

#
Path::qcurve_to

fn Path::qcurve_to(self : Path, cp : Point, end : Point) -> Path

Quadratic bezier curve to a point

#
Path::rect

fn Path::rect(x : Double, y : Double, width : Double, height : Double) -> Path

Create a rectangle path

#
Path::smooth_ccurve_to

fn Path::smooth_ccurve_to(self : Path, cp2 : Point, end : Point) -> Path

Create a smooth cubic curve that connects smoothly to the previous segment

#
Path::smooth_qcurve_to

fn Path::smooth_qcurve_to(self : Path, end : Point) -> Path

Create a smooth quadratic curve that connects smoothly to the previous segment

#
Path::transform

fn Path::transform(self : Path, t : Transform) -> Path

Transform a path using a transformation matrix

#
PathSegment

pub(all) enum PathSegment {
MoveTo(Point)
LineTo(Point)
CurveTo(Point, Point, Point)
QCurveTo(Point, Point)
EArcTo(Double, Double, Double, Bool, Bool, Point)
Close
} derive(Eq,
Debug
)

Path segment types

#
Point

pub struct Point {
x : Double
y : Double
} derive(Eq,
Debug
)
fn Point::Point(x : Double, y : Double) -> Point

A 2D point in the cartesian plane

#
Point::add

fn Point::add(self : Point, other : Point) -> Point

Add two points

#
Point::distance

fn Point::distance(self : Point, other : Point) -> Double

Distance between two points

#
Point::dot

fn Point::dot(self : Point, other : Point) -> Double

Dot product of two points (treated as vectors)

#
Point::length

fn Point::length(self : Point) -> Double

Length of a point (treated as vector from origin)

#
Point::lerp

fn Point::lerp(self : Point, other : Point, t : Double) -> Point

Linear interpolation between two points

#
Point::normalize

fn Point::normalize(self : Point) -> Point

Normalize a point (make it unit length)

#
Point::origin

fn Point::origin() -> Point

Origin point (0, 0)

#
Point::rotate

fn Point::rotate(self : Point, angle : Double) -> Point

Rotate a point around the origin by angle (in radians)

#
Point::scale

fn Point::scale(self : Point, factor : Double) -> Point

Scale a point by a scalar

#
Point::sub

fn Point::sub(self : Point, other : Point) -> Point

Subtract two points

#
Transform

pub struct Transform {
m11 : Double
m12 : Double
m21 : Double
m22 : Double
m31 : Double
m32 : Double
} derive(Eq,
Debug
)

2D transformation matrix

#
apply

fn apply(t : Transform, p : Point) -> Point

Apply transformation to a point

#
compose_transforms

fn compose_transforms(t1 : Transform, t2 : Transform) -> Transform

Compose two transformations (multiply matrices)

#
determinant

fn determinant(t : Transform) -> Double

Get the determinant of the transformation

#
identity

fn identity() -> Transform

Identity transformation

#
invert

fn invert(t : Transform) -> Transform?

Invert a transformation matrix

#
make_rotate

fn make_rotate(angle : Double) -> Transform

Rotation transformation (angle in radians)

#
make_scale

fn make_scale(sx : Double, sy : Double) -> Transform

Scale transformation

#
make_translate

fn make_translate(dx : Double, dy : Double) -> Transform

Translation transformation

#
preserves_orientation

fn preserves_orientation(t : Transform) -> Bool

Check if transformation preserves orientation

#
scale_uniform

fn scale_uniform(s : Double) -> Transform

Uniform scale transformation

#
skew_x

fn skew_x(angle : Double) -> Transform

Skew X transformation

#
skew_y

fn skew_y(angle : Double) -> Transform

Skew Y transformation

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io