summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-30 16:30:43 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-30 16:30:43 -0300
commitf7f8755215f2701698e173ad753f282231655bdd (patch)
tree68879c722ea0098c0a708a6de38475cb54bb4241 /src/main.rs
parent4998f5936dc7da36aba0cd018de2a1a6127dda08 (diff)
downloadbezier-f7f8755215f2701698e173ad753f282231655bdd.tar.gz
bezier-f7f8755215f2701698e173ad753f282231655bdd.zip
Optimize lerp creation
Now it uses Rc instead of Box, reducing the space and time complexity from O(2^n) to O(n^2).
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index a61478f..25a3ec1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -118,13 +118,13 @@ fn compile_bezier_shader(c: &Bezier) -> GLuint {
FragColor = vec4(r, c, 0.0, 1.0);
}}
",
- s = c.degree,
- vx = c.show_x(),
- vy = c.show_y(),
- px = &c.px,
- py = &c.py,
- sx = c.px.degree() + 1,
- sy = c.py.degree() + 1,
+ s = c.degree,
+ vx = c.show_x(),
+ vy = c.show_y(),
+ px = &c.px,
+ py = &c.py,
+ sx = c.px.degree() + 1,
+ sy = c.py.degree() + 1,
dpx = &c.dpx,
dpy = &c.dpy,
dsx = c.dpx.degree() + 1,
@@ -182,7 +182,10 @@ 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;
@@ -225,7 +228,7 @@ fn main() {
} => {
curve.push(x, window_h as i32 - y);
compile_bezier_shader(&curve);
- },
+ }
_ => {}
}
}