From 945f0aac9b5ae381ee9262539b527d6decb7d84b Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Thu, 13 Jan 2022 08:24:26 -0500 Subject: [PATCH] Fix `QuadToCubic` trait, changed recently for #20 --- src/outline/quad_to_cubic.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/outline/quad_to_cubic.rs b/src/outline/quad_to_cubic.rs index 704b54b3..ef2c2d6d 100644 --- a/src/outline/quad_to_cubic.rs +++ b/src/outline/quad_to_cubic.rs @@ -4,16 +4,16 @@ pub trait QuadToCubic { fn quad_to_cubic(self) -> [QCO; N]; } +// This method of Quad->Cubic conversion is used all over the place in FontForge. impl QuadToCubic for [QCO; 3] { fn quad_to_cubic(self) -> [QCO; 4] { #[allow(unused_assignments)] - let [p0, mut p1, mut p2, p3] = [self[0].to_kurbo(), self[1].to_kurbo(), self[2].to_kurbo(), self[2].to_kurbo()]; - p1.x = p0.x + (2./3.) * (p1.x-p0.x); - p1.y = p0.y + (2./3.) * (p1.y-p0.y); - p2.x = p2.x + (2./3.) * (p1.x-p2.x); - p2.y = p2.y + (2./3.) * (p1.y-p2.y); + let [p0_o, p1_o, p2_o, p3_o] = [self[0].to_kurbo(), self[1].to_kurbo(), self[2].to_kurbo(), self[2].to_kurbo()]; + let [p0, mut p1, mut p2, p3] = [p0_o, p1_o, p2_o, p3_o]; + p1.x = p0_o.x + (2./3.) * (p1_o.x-p0_o.x); + p1.y = p0_o.y + (2./3.) * (p1_o.y-p0_o.y); + p2.x = p2_o.x + (2./3.) * (p1_o.x-p2_o.x); + p2.y = p2_o.y + (2./3.) * (p1_o.y-p2_o.y); [QCO::from_kurbo(&p0), QCO::from_kurbo(&p1), QCO::from_kurbo(&p2), QCO::from_kurbo(&p3)] } } - -// This method of Quad->Cubic conversion is used all over the place in FontForge.