Skip to main content

Crate cliffy_core

Crate cliffy_core 

Source
Expand description

§Cliffy Core

Reactive UI framework with geometric algebra state management.

Cliffy uses Clifford/Geometric Algebra as its mathematical foundation, providing FRP-style reactive primitives where all state transformations are geometric operations under the hood.

§Quick Start

use cliffy_core::{Behavior, behavior};

// Create a reactive behavior (internally a GA3 multivector)
let count = behavior(0i32);

// Sample the current value
assert_eq!(count.sample(), 0);

// Update via transformation
count.update(|n| n + 1);
assert_eq!(count.sample(), 1);

// Map to derived behavior
let doubled = count.map(|n| n * 2);
assert_eq!(doubled.sample(), 2);

§Explicit Geometric Control

For applications that need explicit geometric transformations:

use cliffy_core::{GeometricState, Rotor, Translation};
use std::f64::consts::PI;

// Create state representing a 3D position
let pos = GeometricState::from_vector(1.0, 0.0, 0.0);

// Apply explicit geometric transformations
let rotated = pos.apply_rotor(&Rotor::xy(PI / 2.0));  // 90° rotation
let translated = rotated.apply_translation(&Translation::new(1.0, 0.0, 0.0));

// Get the result as a vector
let (x, y, z) = translated.as_vector();
assert!((x - 1.0).abs() < 1e-10);  // ~1.0
assert!((y - 1.0).abs() < 1e-10);  // ~1.0

§Architecture

  • Behavior: Time-varying values backed by geometric algebra
  • Event: Discrete occurrences with geometric transformations
  • GeometricState: Explicit geometric operations (rotations, translations)
  • Projection: Extract user types from geometric state
  • Combinators: when, combine for composition

The geometric algebra foundation can be hidden from users (they work with familiar types like i32, String, Vec<T>) or exposed explicitly via GeometricState for advanced use cases.

Re-exports§

pub use behavior::behavior;
pub use behavior::Behavior;
pub use behavior::Subscription;
pub use combinators::combine;
pub use combinators::when;
pub use event::event;
pub use event::Event;
pub use geometric::FromGeometric;
pub use geometric::IntoGeometric;
pub use geometric::GA3;
pub use projection::BivectorProjection;
pub use projection::BoolProjection;
pub use projection::ColorAlphaProjection;
pub use projection::ColorProjection;
pub use projection::CustomProjection;
pub use projection::IntProjection;
pub use projection::MagnitudeProjection;
pub use projection::MappedProjection;
pub use projection::Position2DProjection;
pub use projection::Position3DProjection;
pub use projection::Projection;
pub use projection::RotorAngleProjection;
pub use projection::ScalarProjection;
pub use projection::TypedBivectorProjection;
pub use projection::TypedVectorProjection;
pub use projection::VectorProjection;
pub use state::GeometricState;
pub use state::GeometricSubscription;
pub use transforms::Rotor;
pub use transforms::Transform;
pub use transforms::Translation;
pub use transforms::Versor;
pub use component::component;
pub use component::compose;
pub use component::Component;
pub use component::ComposedComponent;
pub use component::Element;
pub use component::ElementKind;
pub use component::FnComponent;
pub use component::PropValue;
pub use component::Props;
pub use component::StateSplit;
pub use dataflow::CombinerType;
pub use dataflow::DataflowGraph;
pub use dataflow::GraphBuilder;
pub use dataflow::Node;
pub use dataflow::NodeId;
pub use dataflow::NodeKind;
pub use dataflow::ProjectionSpec;
pub use dataflow::RotationPlane;
pub use dataflow::SinkSpec;
pub use dataflow::TransformType;

Modules§

behavior
Behavior - Time-varying values backed by geometric algebra
combinators
Combinators for composing behaviors
component
Component model for Algebraic TSX
dataflow
Dataflow graph intermediate representation for Algebraic TSX
event
Event - Discrete occurrences with geometric transformations
geometric
Geometric algebra helpers
projection
Projections from geometric space to user types
state
Geometric state with explicit transformations
transforms
Geometric transformations for state manipulation

Structs§

Multivector
A multivector in a Clifford algebra Cl(P,Q,R)