Skip to content

Commit 1a0510f

Browse files
committed
adjust guitar string width based on guitar view width
1 parent 12e4d3d commit 1a0510f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

crates/notation_bevy/src/guitar/guitar_string.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ impl GuitarStringData {
5050
}
5151
fn width(&self, theme: &NotationTheme) -> f32 {
5252
let width = theme.guitar.get_string_width(self.string);
53-
if !self.upper && self.state.is_current() {
53+
let width_with_extra = if !self.upper && self.state.is_current() {
5454
width + theme.guitar.current_extra_width
5555
} else {
5656
width
57-
}
57+
};
58+
width_with_extra * self.guitar_size.width / theme.guitar.guitar_width
5859
}
5960
fn outline(&self, theme: &NotationTheme) -> f32 {
6061
if !self.upper && self.hit {
61-
theme.guitar.hit_outline
62+
theme.guitar.hit_outline * self.guitar_size.width / theme.guitar.guitar_width
6263
} else {
6364
0.0
6465
}

crates/notation_bevy/src/theme/guitar_theme.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct GuitarTheme {
1818
pub fret_y_factors: [f32; 23],
1919
pub capo_width_factor: f32,
2020
pub capo_height_factor: f32,
21+
pub guitar_width: f32,
2122
}
2223

2324
impl Default for GuitarTheme {
@@ -39,6 +40,7 @@ impl Default for GuitarTheme {
3940
],
4041
capo_width_factor: 0.78,
4142
capo_height_factor: 0.02,
43+
guitar_width: 128.0,
4244
}
4345
}
4446
}

0 commit comments

Comments
 (0)