Crate transformator

Crate transformator 

Source
Expand description

§transformator

A library for CSS-style 3D transform composition and inheritance.

This crate provides a Transform struct that allows you to compose hierarchical transforms with support for perspective, rotations, translations, scaling, and transform origins - just like CSS transforms work in browsers.

§Quick Start

use transformator::Transform;

// Create a root transform (identity)
let root = Transform::new();

// Create a parent with position, perspective, origin, and rotation
let parent = Transform::new()
    .with_position_relative_to_parent(350.0, 250.0)
    .with_parent_container_perspective(500.0, 400.0, 300.0)
    .with_origin(50.0, 50.0)
    .then_rotate_x_deg(45.0)
    .compose_2(&root);

// Create a child that inherits parent's transform
let child = Transform::new()
    .with_position_relative_to_parent(10.0, 10.0)
    .compose_2(&parent);

// Transform local points to world coordinates
let world_pos = parent.transform_local_point2d_to_world(0.0, 0.0);

§Features

  • Hierarchical inheritance: Child transforms compose with parent transforms
  • CSS-like API: Familiar translate, rotate, scale methods
  • Perspective support: Apply perspective with customizable origin
  • Hit testing: Project screen coordinates back to local space
  • Serialization: Optional serde support via the serialization feature

Structs§

Transform