mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix draw_multiline_colors
usage
This commit is contained in:
parent
fb10f45efe
commit
cc44d75cd8
6 changed files with 65 additions and 78 deletions
|
@ -74,14 +74,18 @@ void AudioStreamEditor::_notification(int p_what) {
|
|||
}
|
||||
|
||||
void AudioStreamEditor::_draw_preview() {
|
||||
Rect2 rect = _preview->get_rect();
|
||||
Size2 size = get_size();
|
||||
if ((int)size.width <= 0) {
|
||||
return; // No points to draw.
|
||||
}
|
||||
|
||||
Rect2 rect = _preview->get_rect();
|
||||
|
||||
Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
|
||||
float preview_len = preview->get_length();
|
||||
|
||||
Vector<Vector2> lines;
|
||||
lines.resize(size.width * 2);
|
||||
Vector<Vector2> points;
|
||||
points.resize((int)size.width * 2);
|
||||
|
||||
for (int i = 0; i < size.width; i++) {
|
||||
float ofs = i * preview_len / size.width;
|
||||
|
@ -90,11 +94,13 @@ void AudioStreamEditor::_draw_preview() {
|
|||
float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5;
|
||||
|
||||
int idx = i;
|
||||
lines.write[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y);
|
||||
lines.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y);
|
||||
points.write[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y);
|
||||
points.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y);
|
||||
}
|
||||
|
||||
RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, { get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")) });
|
||||
Vector<Color> colors = { get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")) };
|
||||
|
||||
RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), points, colors);
|
||||
}
|
||||
|
||||
void AudioStreamEditor::_preview_changed(ObjectID p_which) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue