aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-01-20 23:37:08 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2024-01-20 23:37:08 +0100
commit6e0a9ec574dcc6da863c6d8e482c5a2cb4701df4 (patch)
tree24f669647d0ae31e5f086eed4c86b3edddc4444b
parentb8e501b7d4d3991669233109a6f8213a2d624c14 (diff)
improve rendering on high range by lowering graph quality by log
-rw-r--r--src/ui/graph.rs9
1 files changed, 5 insertions, 4 deletions
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<Message, Renderer> 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<Message, Renderer> 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()