iced::widget::canvas::path::lyon_path::geom

Crate euclid

Available on crate feature canvas only.
Expand description

A collection of strongly typed math tools for computer graphics with an inclination towards 2d graphics and layout.

All types are generic over the scalar type of their component (f32, i32, etc.), and tagged with a generic Unit parameter which is useful to prevent mixing values from different spaces. For example it should not be legal to translate a screen-space position by a world-space vector and this can be expressed using the generic Unit parameter.

This unit system is not mandatory and all structures have an alias with the default unit: UnknownUnit. for example default::Point2D<T> is equivalent to Point2D<T, UnknownUnit>. Client code typically creates a set of aliases for each type and doesn’t need to deal with the specifics of typed units further. For example:

use euclid::*;
pub struct ScreenSpace;
pub type ScreenPoint = Point2D<f32, ScreenSpace>;
pub type ScreenSize = Size2D<f32, ScreenSpace>;
pub struct WorldSpace;
pub type WorldPoint = Point3D<f32, WorldSpace>;
pub type ProjectionMatrix = Transform3D<f32, WorldSpace, ScreenSpace>;
// etc...

All euclid types are marked #[repr(C)] in order to facilitate exposing them to foreign function interfaces (provided the underlying scalar type is also repr(C)).

Modules§

  • Utilities for testing approximate ordering - especially true for floating point types, where NaN’s cannot be ordered.
  • A set of aliases for all types, tagged with the default unknown unit.
  • A one-dimensional length, tagged with its units.

Structs§

  • An angle in radians
  • A 2d vector of booleans, useful for component-wise logic operations.
  • A 3d vector of booleans, useful for component-wise logic operations.
  • A 2d axis aligned rectangle represented by its minimum and maximum coordinates.
  • An axis aligned 3D box represented by its minimum and maximum coordinates.
  • Homogeneous vector in 3D space.
  • A one-dimensional distance, with value represented by T and unit of measurement Unit.
  • A 2d Point tagged with a unit.
  • A 3d Point tagged with a unit.
  • A 2d Rectangle optionally tagged with a unit.
  • A rigid transformation. All lengths are preserved under such a transformation.
  • A transform that can represent rotations in 2d, represented as an angle in radians.
  • A transform that can represent rotations in 3d, represented as a quaternion.
  • A scaling factor between two different units of measurement.
  • A group of 2D side offsets, which correspond to top/right/bottom/left for borders, padding, and margins in CSS, optionally tagged with a unit.
  • A 2d size tagged with a unit.
  • A 3d size tagged with a unit.
  • A 2d transform represented by a column-major 3 by 3 matrix, compressed down to 3 by 2.
  • A 3d transform stored as a column-major 4 by 4 matrix.
  • A 2d transformation from a space to another that can only express translations.
  • A 3d transformation from a space to another that can only express translations.
  • The default unit.
  • A 2d Vector tagged with a unit.
  • A 3d Vector tagged with a unit.

Traits§

  • Trait for basic trigonometry functions, so they can be used on generic numeric types

Functions§

  • Shorthand for Box3D::new(Point3D::new(x1, y1, z1), Point3D::new(x2, y2, z2)).
  • Shorthand for BoolVector2D { x, y }.
  • Shorthand for BoolVector3D { x, y, z }.
  • Shorthand for Point2D::new(x, y).
  • Shorthand for Point3D::new(x, y).
  • Shorthand for Rect::new(Point2D::new(x, y), Size2D::new(w, h)).
  • Shorthand for Size2D::new(w, h).
  • Shorthand for Size3D::new(w, h, d).
  • Convenience constructor.
  • Convenience constructor.