From 6e0a9ec574dcc6da863c6d8e482c5a2cb4701df4 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 20 Jan 2024 23:37:08 +0100 Subject: improve rendering on high range by lowering graph quality by log --- src/ui/graph.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/graph.rs b/src/ui/graph.rs index 13e8ac9..63e1c43 100644 --- a/src/ui/graph.rs +++ b/src/ui/graph.rs @@ -92,7 +92,7 @@ impl canvas::Program for GraphCanvas { let zcolor = Color::new(0.27, 0.52, 0.53, 1.0); let lcolor = Color::new(0.49, 0.43, 0.39, 1.0); let gcolor = Color::new(0.8, 0.14, 0.11, 1.0); - let step = 10_usize.pow((400.0 / state.scale).log10() as u32); + let step = 10_usize.pow((314.1 / state.scale).log10() as u32); let unitline_whole = Stroke { width: 1.0, @@ -189,17 +189,18 @@ impl canvas::Program for GraphCanvas { } }); + let step = (step / 10).max(1); let mut y1 = self .func .lock() .unwrap() .eval(Complex::new(rect.x as f64, 0.0), &self.ctx) .real as f32; - for x in rect.x as i64..(rect.x + rect.width) as i64 { + for x in (rect.x as i64..(rect.x + rect.width) as i64).step_by(step) { for d in 0..10 { let d = d as f32 / 10.0; - let x1 = x as f32 + d; - let x2 = x as f32 + d + 0.1; + let x1 = x as f32 + d * step as f32; + let x2 = x as f32 + (d + 0.1) * step as f32; let y2 = self .func .lock() -- cgit v1.2.3-70-g09d2