diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-04-25 12:00:40 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-04-25 12:00:40 +0200 |
commit | c2c991815b73817d2a89e93f399bd95f1385eb37 (patch) | |
tree | 1c7472c7773e2f2dc70aa14459edb68a151aab3b | |
parent | e834521b276eda5cff3e422b0372bb1a66e0b98a (diff) |
WIP: Draw line segments instead of points.
-rw-r--r-- | plugingui/powerwidget.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/plugingui/powerwidget.cc b/plugingui/powerwidget.cc index e459503..a1af333 100644 --- a/plugingui/powerwidget.cc +++ b/plugingui/powerwidget.cc @@ -177,18 +177,15 @@ void PowerWidget::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent) GUI::Painter p(*this); p.clear(); -// GUI::Colour c(1.0f, 1.0f, 0.0f, 0.2f); -// p.setColour(c); -// p.drawFilledRectangle(0, 0, width(), height()); // draw the fixed nodes of the spline p.setColour(GUI::Colour{0.f, 0.7f, .5f, 1.f}); - p.drawFilledCircle( - power_map.getFixed0().in*width(), height() - power_map.getFixed0().out*height(), 3); - p.drawFilledCircle( - power_map.getFixed1().in*width(), height() - power_map.getFixed1().out*height(), 3); - p.drawFilledCircle( - power_map.getFixed2().in*width(), height() - power_map.getFixed2().out*height(), 3); + p.drawFilledCircle(power_map.getFixed0().in*width(), + height() - power_map.getFixed0().out*height(), 3); + p.drawFilledCircle(power_map.getFixed1().in*width(), + height() - power_map.getFixed1().out*height(), 3); + p.drawFilledCircle(power_map.getFixed2().in*width(), + height() - power_map.getFixed2().out*height(), 3); if(enabled) { @@ -201,11 +198,22 @@ void PowerWidget::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent) p.setColour(GUI::Colour(0.5f, 0.5f, 0.5f, 1.0f)); } - for(std::size_t x = 0; x < width(); ++x) + // draw 64 line segments across the region + std::pair<int, int> old{}; + for(std::size_t x = 0; x < width(); x += width() / 64) { int y = power_map.map((float)x / width()) * height(); - p.drawPoint(x, height() - y); + if(x > 0) + { + p.drawLine(old.first, old.second, x, height() - y); + } + old = { x, height() - y }; } + + int x = width(); + int y = power_map.map((float)x / width()) * height(); + p.drawLine(old.first, old.second, x, height() - y); + old = { x, height() - y }; } void PowerWidget::Canvas::parameterChangedFloat(float) |