svg_path/point
Small helper library for the svg_path.Point type.
Values
pub fn add(
a: svg_path.Point,
b: svg_path.Point,
) -> svg_path.Point
Add two points as vectors.
pub fn cross(a: svg_path.Point, b: svg_path.Point) -> Float
Return the 2D cross product of two points as vectors.
pub fn direction(degrees degrees: Float) -> svg_path.Point
Return the unit vector pointing at an SVG angle in degrees.
0 points right, 90 points down, 180 points left, and 270 points up.
pub fn distance(a: svg_path.Point, b: svg_path.Point) -> Float
Return the distance between two points.
pub fn distance_squared(
a: svg_path.Point,
b: svg_path.Point,
) -> Float
Return the squared distance between two points.
pub fn dot(a: svg_path.Point, b: svg_path.Point) -> Float
Return the dot product of two points as vectors.
pub fn lerp(
a: svg_path.Point,
b: svg_path.Point,
t t: Float,
) -> svg_path.Point
Linearly interpolate from a to b.
t: 0.0 returns a, t: 1.0 returns b, and values outside that range
extrapolate.
pub fn midpoint(
a: svg_path.Point,
b: svg_path.Point,
) -> svg_path.Point
Return the midpoint between two points.
pub fn near(
a: svg_path.Point,
b: svg_path.Point,
tolerance tolerance: Float,
) -> Bool
Return whether two points are within a Euclidean distance tolerance.
pub fn norm(point: svg_path.Point) -> Float
Return the Euclidean norm of a point as a vector.
pub fn norm_squared(point: svg_path.Point) -> Float
Return the squared Euclidean norm of a point as a vector.
pub fn normalize(
point: svg_path.Point,
) -> Result(svg_path.Point, Nil)
Return a unit vector with the same direction as point.
pub fn project(
point point: svg_path.Point,
onto onto: svg_path.Point,
) -> Result(svg_path.Point, Nil)
Project point onto onto.
pub fn rotate_clockwise(point: svg_path.Point) -> svg_path.Point
Rotate a point as a vector by 90 degrees clockwise.
pub fn rotate_counterclockwise(
point: svg_path.Point,
) -> svg_path.Point
Rotate a point as a vector by 90 degrees counterclockwise.
pub fn scalar_projection(
point point: svg_path.Point,
onto onto: svg_path.Point,
) -> Result(Float, Nil)
Return the scalar projection of point onto onto.
pub fn scale(
point: svg_path.Point,
by factor: Float,
) -> svg_path.Point
Scale a point as a vector.
pub fn subtract(
a: svg_path.Point,
b: svg_path.Point,
) -> svg_path.Point
Subtract b from a as vectors.