Skip to content

Commit

Permalink
draw notes
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Oct 19, 2024
1 parent 1425846 commit 6d894ad
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl View for DelayGraph {
&vg::Paint::color(selection_color.into()).with_line_width(line_width),
);
};
// draw delay taps
// draw delay tap velocities
canvas.stroke_path(
&{
let mut path = vg::Path::new();
Expand All @@ -266,6 +266,31 @@ impl View for DelayGraph {
&vg::Paint::color(outline_color.into()).with_line_width(line_width),
);

// Draw delay tap notes as diamonds
canvas.stroke_path(
&{
let mut path = vg::Path::new();
for i in 0..delay_data.current_tap {
let x_offset = delay_data.delay_times[i] as f32 * x_factor + border_width * 0.5;
let y_offset = (h - border_width * 0.5)
- ((delay_data.notes[i] as f32 / 127.0) * (h - border_width * 0.5));

let center_x = x + x_offset;
let center_y = y + y_offset;
let half_size = line_width; // You can adjust this to change the size of the diamond

// Draw diamond shape
path.move_to(center_x + half_size, center_y); // Top-Right
path.line_to(center_x, center_y + half_size); // Bottom-Right
path.line_to(center_x - half_size, center_y); // Bottom-Left
path.line_to(center_x, center_y - half_size); // Top-Left
path.close();
}
path
},
&vg::Paint::color(selection_color.into()).with_line_width(line_width),
);

// add outline
canvas.stroke_path(
&{
Expand Down

0 comments on commit 6d894ad

Please sign in to comment.