Skip to content

Commit

Permalink
Add note labels to waterfall notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Chronister committed Dec 2, 2024
1 parent f1a93c1 commit ff2185d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions neothesia-core/src/render/guidelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ impl GuidelineRenderer {
}
}

// Helper method to convert key index to note name
fn get_note_name(key_index: usize) -> &'static str {
const NOTE_NAMES: [&str; 12] = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
NOTE_NAMES[key_index % 12]
}

#[profiling::function]
fn update_vertical_guidelines(&mut self, quads: &mut QuadPipeline, layer: usize) {
for key in self.layout.white_keys().chain(self.layout.black_keys()) {
let x = self.pos.x + key.x();
let y = self.pos.y;

// Add the quad instance
quads.instances(layer).push(QuadInstance {
position: [x, y], // Position of the guideline
size: [2.0, self.layout.height()], // Thin width, full keyboard height
color: [0.2, 0.2, 0.2, 0.5], // Semi-transparent dark gray
border_radius: 0.0, // Sharp corners for guidelines
});

// Add text label
self.text_cache.push(TextInstance {
position: [x + 2.0, y + 2.0], // Slight offset from quad corner
text: Self::get_note_name(key.index()).to_string(),
color: [1.0, 1.0, 1.0, 1.0], // White text
scale: 0.8,
});
}
}

#[profiling::function]
fn update_horizontal_guidelines(
&mut self,
Expand Down

0 comments on commit ff2185d

Please sign in to comment.