Spectrum back to one jagged line, now precise: each band draws a full up-and-down stroke to its level, so every band shows above and below the centre
Browse files at this commit776d19ae3e3690ce3fda37f3db55370590fc0c86Parent: a77dbaa- style
- spectrum back to one jagged line, now precise: each band draws a full up-and-down stroke to its level, so every band shows above and below the centre
1 changed file +8 -13
crates/client/src/gui/parts.rsmodified+8 -13
| @@ -368,7 +368,7 @@ pub enum Voice { | |||
| 368 | 368 | ||
| 369 | const STILL: f32 = 0.02; | 369 | const STILL: f32 = 0.02; |
| 370 | const EDGE: f32 = 16.; | 370 | const EDGE: f32 = 16.; |
| 371 | -const PEAK_SPACING: f32 = 3.; | 371 | +const PEAK_SPACING: f32 = 5.; |
| 372 | const MIN_PEAKS: usize = 6; | 372 | const MIN_PEAKS: usize = 6; |
| 373 | 373 | ||
| 374 | pub fn voice_line(bands: Option<&VecDeque<f32>>, voice: Voice, t: Tokens) -> AnyElement { | 374 | pub fn voice_line(bands: Option<&VecDeque<f32>>, voice: Voice, t: Tokens) -> AnyElement { |
| @@ -402,21 +402,16 @@ pub fn voice_line(bands: Option<&VecDeque<f32>>, voice: Voice, t: Tokens) -> Any | |||
| 402 | if frayed { | 402 | if frayed { |
| 403 | path = path.dash_array(&[px(4.), px(3.)]); | 403 | path = path.dash_array(&[px(4.), px(3.)]); |
| 404 | } | 404 | } |
| 405 | - let crest = |index: usize, side: f32| { | ||
| 406 | - let along = (index as f32 + 0.5) / count; | ||
| 407 | - let edge = (along.min(1. - along) * EDGE).min(1.); | ||
| 408 | - let x = bounds.origin.x + bounds.size.width * along; | ||
| 409 | - point(x, middle + px(side * peaks[index] * edge * half)) | ||
| 410 | - }; | ||
| 411 | path.move_to(point(bounds.origin.x, middle)); | 405 | path.move_to(point(bounds.origin.x, middle)); |
| 412 | - for index in 0..peaks.len() { | 406 | + for (index, level) in peaks.iter().enumerate() { |
| 413 | - path.line_to(crest(index, -1.)); | 407 | + for (quarter, side) in [(0.25, -1.), (0.75, 1.)] { |
| 408 | + let along = (index as f32 + quarter) / count; | ||
| 409 | + let edge = (along.min(1. - along) * EDGE).min(1.); | ||
| 410 | + let x = bounds.origin.x + bounds.size.width * along; | ||
| 411 | + path.line_to(point(x, middle + px(side * level * edge * half))); | ||
| 412 | + } | ||
| 414 | } | 413 | } |
| 415 | path.line_to(point(bounds.origin.x + bounds.size.width, middle)); | 414 | path.line_to(point(bounds.origin.x + bounds.size.width, middle)); |
| 416 | - for index in (0..peaks.len()).rev() { | ||
| 417 | - path.line_to(crest(index, 1.)); | ||
| 418 | - } | ||
| 419 | - path.line_to(point(bounds.origin.x, middle)); | ||
| 420 | if let Ok(path) = path.build() { | 415 | if let Ok(path) = path.build() { |
| 421 | window.paint_path(path, color); | 416 | window.paint_path(path, color); |
| 422 | } | 417 | } |