summaryrefslogtreecommitdiff
path: root/libs/plugins
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-14 19:44:03 +0200
committerRobin Gareus <robin@gareus.org>2016-07-14 19:44:03 +0200
commit1d78150d45dbbc0b88628f5acad97d97f3c28682 (patch)
tree486ce5c9f0a112e59e6c80789ca85b25cae42d02 /libs/plugins
parentf53655d17ceebe5ae3e9668d9eef7a72f1951285 (diff)
refine a-eq inline display size + grid
Diffstat (limited to 'libs/plugins')
-rw-r--r--libs/plugins/a-eq.lv2/a-eq.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libs/plugins/a-eq.lv2/a-eq.c b/libs/plugins/a-eq.lv2/a-eq.c
index 380e1ba3e5..a539c90825 100644
--- a/libs/plugins/a-eq.lv2/a-eq.c
+++ b/libs/plugins/a-eq.lv2/a-eq.c
@@ -492,7 +492,7 @@ static LV2_Inline_Display_Image_Surface *
render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h)
{
Aeq* self = (Aeq*)instance;
- uint32_t h = MIN (w * 9 / 16, max_h);
+ uint32_t h = MIN (1 | (uint32_t)ceilf (w * 9.f / 16.f), max_h);
if (!self->display || self->w != w || self->h != h) {
if (self->display) cairo_surface_destroy(self->display);
@@ -510,19 +510,30 @@ render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h)
cairo_set_line_width(cr, 1.0);
- // draw grid 5dB steps
- const double dash2[] = {1, 3};
+ // prepare grid drawing
cairo_save (cr);
- cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+ const double dash2[] = {1, 3};
+ //cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
cairo_set_dash(cr, dash2, 2, 2);
cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
- for (uint32_t d = 1; d < 8; ++d) {
- const float y = -.5 + floorf (h * (d * 5.f / 40.f));
+ // draw x-grid 6dB steps
+ for (int32_t d = -18; d <= 18; d+=6) {
+ float y = (float)h * (d / 40.0 + 0.5);
+ y = rint (y) - .5;
cairo_move_to (cr, 0, y);
cairo_line_to (cr, w, y);
cairo_stroke (cr);
}
+ // draw y-axis grid 100, 1k, 10K
+ for (int32_t f = 100; f <= 10000; f *= 10) {
+ float x = w * log10 (f / 20.0) / log10 (1000.0);
+ x = rint (x) - .5;
+ cairo_move_to (cr, x, 0);
+ cairo_line_to (cr, x, h);
+ cairo_stroke (cr);
+ }
+
cairo_restore (cr);