+
+ -- draw grid on top
+ function x_at_freq (f)
+ if logscale then
+ return f_l + f_b * math.log (f)
+ else
+ return 2 * w * f / rate;
+ end
+ end
+
+ function grid_freq (f)
+ -- draw vertical grid line
+ local x = .5 + math.floor (x_at_freq (f))
+ ctx:move_to (x, 0)
+ ctx:line_to (x, h)
+ ctx:stroke ()
+ end
+
+ -- draw grid on top
+ local dash3 = C.DoubleVector ()
+ dash3:add ({1, 3})
+ ctx:set_line_width (1.0)
+ ctx:set_dash (dash3, 2) -- dotted line
+ ctx:set_source_rgba (.5, .5, .5, .8)
+ grid_freq (100)
+ grid_freq (1000)
+ grid_freq (10000)
+ ctx:unset_dash ()
+