1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 22:45:06 +00:00

SoundPlayer: Scale y coordinate to prevent drawing outside clip rect

Previously if sample.left amplitude was more than 0.5 we would draw
outside the painters clip rect.
This commit is contained in:
Max Thrun 2019-09-11 00:02:10 -07:00 committed by Andreas Kling
parent b9be6b7bb4
commit ae060d7450

View file

@ -31,7 +31,7 @@ void SampleWidget::paint_event(GPaintEvent& event)
for (int x = 0; x < samples_to_draw; ++x) {
// FIXME: This might look nicer if drawn as lines.
auto& sample = m_buffer->samples()[x];
Point p = { x, frame_inner_rect().center().y() + (int)(sample.left * frame_inner_rect().height()) };
Point p = { x, frame_inner_rect().center().y() + (int)(sample.left * frame_inner_rect().height() / 2) };
painter.set_pixel(p, Color::Green);
}
}