From 394658142dcb87cf6502daf18434c1b24f143193 Mon Sep 17 00:00:00 2001 From: qiudejia Date: Tue, 4 Nov 2025 16:26:46 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E8=A7=92=E5=BA=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit acfe44fd2e0c7d0c026fbef7166895b84aec3fe5. --- src/qelmt/arc.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/qelmt/arc.rs b/src/qelmt/arc.rs index d3daec3..db42e46 100644 --- a/src/qelmt/arc.rs +++ b/src/qelmt/arc.rs @@ -4,18 +4,6 @@ use dxf::entities::LwPolyline; use hex_color::HexColor; use simple_xml_builder::XMLElement; -fn normalize_angle(angle: f64) -> f64 { - let mut norm = angle % 360.0; - if norm < 0.0 { - norm += 360.0; - } - norm -} - -fn qet_start_angle(angle: f64) -> f64 { - normalize_angle(270.0 - angle) -} - #[derive(Debug)] pub struct Arc { //need to brush up on my Rust scoping rules, isn't there a way to make this pub to just the module? @@ -86,7 +74,7 @@ impl Arc { y: -arc.center.y - arc.radius, height: arc.radius * 2.0, width: arc.radius * 2.0, - start: qet_start_angle(normalize_angle(start_angle)), + start: if start_angle < 0.0 { -start_angle } else { start_angle }, angle: if angle_span < 0.0 { -angle_span } else { angle_span }, //in the original code antialias is always set to false...I'm guessing for performance @@ -287,8 +275,18 @@ impl Arc { (start_y_qet - center_y_qet).atan2(start.0 - center_x).to_degrees(); let mut end_angle = (end_y_qet - center_y_qet).atan2(end.0 - center_x).to_degrees(); - start_angle = normalize_angle(start_angle); - end_angle = normalize_angle(end_angle); + let normalize = |mut angle: f64| { + while angle < 0.0 { + angle += 360.0; + } + while angle >= 360.0 { + angle -= 360.0; + } + angle + }; + + start_angle = normalize(start_angle); + end_angle = normalize(end_angle); let ccw_sweep = (end_angle - start_angle).rem_euclid(360.0); let cw_sweep = (start_angle - end_angle).rem_euclid(360.0); @@ -307,8 +305,6 @@ impl Arc { return Err("Arc sweep too small".into()); } - let start_angle = qet_start_angle(start_angle); - Ok(Arc { x: center_x - radius, y: center_y_qet - radius,