summaryrefslogtreecommitdiff
path: root/src/lerp.rs
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-17 17:51:07 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-17 17:51:07 -0300
commit727b1c2ee98d395429ec1e667279fc3f5fec3a5c (patch)
tree4c14382356d905622983b042aeeaf9fe16f8e71b /src/lerp.rs
parent5698a5ac7303b128f13e9b656e8446d24a2c1f24 (diff)
downloadbezier-727b1c2ee98d395429ec1e667279fc3f5fec3a5c.tar.gz
bezier-727b1c2ee98d395429ec1e667279fc3f5fec3a5c.zip
Fix fragment shader bug on empty curves
Diffstat (limited to 'src/lerp.rs')
-rw-r--r--src/lerp.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lerp.rs b/src/lerp.rs
index 222671f..1501d0f 100644
--- a/src/lerp.rs
+++ b/src/lerp.rs
@@ -4,6 +4,7 @@ use crate::poly::Poly;
pub enum Lerp {
Node(Box<Lerp>, Box<Lerp>),
Leaf(Number, Number),
+ Just(Number)
}
impl Lerp {
@@ -13,8 +14,8 @@ impl Lerp {
fn new_s(v: &[Number]) -> Box<Lerp> {
match v.len() {
- 0 => Box::new(Lerp::Leaf(0.0, 0.0)),
- 1 => Box::new(Lerp::Leaf(v[0], v[0])),
+ 0 => Box::new(Lerp::Just(0.0)),
+ 1 => Box::new(Lerp::Just(v[0])),
2 => Box::new(Lerp::Leaf(v[0], v[1])),
_ => Box::new(Lerp::Node(
Lerp::new_s(&v[0..v.len() - 1]),
@@ -26,6 +27,7 @@ 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);