Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose rendering module + impl Point2D arithmetic #109

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pax-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 35 additions & 4 deletions pax-runtime/src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<Point2D> 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<Point2D> 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<f64> for Point2D {
type Output = Point2D;
fn div(self, rhs: f64) -> Self::Output {
Self::Output {
x: self.x / rhs,
y: self.y / rhs,
}
}
}

impl Point2D {
Expand Down
Loading