diff --git a/pax-engine/src/lib.rs b/pax-engine/src/lib.rs index 1154f64ec..666ece346 100644 --- a/pax-engine/src/lib.rs +++ b/pax-engine/src/lib.rs @@ -2,6 +2,7 @@ pub extern crate pax_macro; pub use pax_macro::*; pub use pax_runtime::api; +pub use pax_runtime::rendering; pub use pax_runtime::api::log; pub use pax_runtime::api::serde; diff --git a/pax-runtime/src/rendering.rs b/pax-runtime/src/rendering.rs index 8c28a87d5..7560df227 100644 --- a/pax-runtime/src/rendering.rs +++ b/pax-runtime/src/rendering.rs @@ -2,7 +2,7 @@ use std::any::Any; use std::cell::RefCell; use std::iter; -use std::ops::Mul; +use std::ops::{Add, Div, Mul, Sub}; use std::rc::Rc; use crate::api::{CommonProperties, RenderContext}; @@ -32,10 +32,41 @@ pub struct InstantiationArgs { pub template_node_id: usize, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Default)] pub struct Point2D { - x: f64, - y: f64, + pub x: f64, + pub y: f64, +} + +impl Add for Point2D { + type Output = Point2D; + + fn add(self, rhs: Point2D) -> Self::Output { + Self::Output { + x: self.x + rhs.x, + y: self.y + rhs.y, + } + } +} + +impl Sub for Point2D { + type Output = Point2D; + fn sub(self, rhs: Point2D) -> Self::Output { + Self::Output { + x: self.x - rhs.x, + y: self.y - rhs.y, + } + } +} + +impl Div for Point2D { + type Output = Point2D; + fn div(self, rhs: f64) -> Self::Output { + Self::Output { + x: self.x / rhs, + y: self.y / rhs, + } + } } impl Point2D {