summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lerp.rs20
-rw-r--r--src/main.rs9
2 files changed, 13 insertions, 16 deletions
diff --git a/src/lerp.rs b/src/lerp.rs
index b098f23..818c686 100644
--- a/src/lerp.rs
+++ b/src/lerp.rs
@@ -22,17 +22,17 @@ impl Lerp {
)),
}
}
-}
-pub fn lp(l: Box<Lerp>) -> Poly {
- match *l {
- Lerp::Just(a) => Poly::new(vec![a]),
- Lerp::Leaf(a, b) => Poly::new(vec![a, b - a]),
- Lerp::Node(a, b) => {
- let a = lp(a);
- let b = lp(b);
- let c = &b - &a;
- &a + &(&c * &Poly::new(vec![0.0, 1.0]))
+ pub fn to_poly(self) -> Poly {
+ match self {
+ Lerp::Just(a) => Poly::new(vec![a]),
+ Lerp::Leaf(a, b) => Poly::new(vec![a, b - a]),
+ Lerp::Node(a, b) => {
+ let a = a.to_poly();
+ let b = b.to_poly();
+ let c = &b - &a;
+ &a + &(&c * &Poly::new(vec![0.0, 1.0]))
+ }
}
}
}
diff --git a/src/main.rs b/src/main.rs
index a9bfcf9..ee508e1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -112,8 +112,8 @@ fn compile_bezier_shader(a: Poly, b: Poly) -> GLuint {
}
fn main() {
- let a = lerp::lp(Lerp::new(vec![200.0, 500.0, 500.0]));
- let b = lerp::lp(Lerp::new(vec![200.0, 500.0, 200.0]));
+ let a = Lerp::new(vec![200.0, 500.0, 500.0]).to_poly();
+ let b = Lerp::new(vec![200.0, 500.0, 200.0]).to_poly();
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
@@ -141,10 +141,7 @@ fn main() {
gl::Viewport(0, 0, window_w as i32, window_h as i32);
}
- let vertices: [f32; 18] = [
- 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, -1.0, 0.0, -1.0, 1.0,
- 0.0,
- ];
+ let vertices: [f32; 18] = [1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, -1.0, 0.0, -1.0, 1.0, 0.0];
let mut vbo: GLuint = 0;
let mut vao: GLuint = 0;