Look and feel drawing help
-
I am trying to make a vertical slider show a circle where the value is. I have the following code:
const laf = Engine.createGlobalScriptLookAndFeel(); laf.registerFunction("drawLinearSlider", function(g, obj) { obj.drawOutside = true; var a = obj.area; var norm = obj.valueNormalized; var cx = a[0] + (a[2] / 2); var cy = a[1] + a[3] * (1.0 - norm); var radius = 15; g.setColour(obj.itemColour1); g.fillEllipse([cx - radius, cy - radius, radius * 2, radius * 2]); });This is working great, however the circle clips when it reaches the top
(The red is the circle).Is there a way to stop the clipping? I think it's something to do with the bounds of the slider, but I'm not sure...
-
@eokeefee The full displacement is then the slider height minus the circle height:
laf.registerFunction("drawLinearSlider", function(g, obj) { obj.drawOutside = true; var a = obj.area; var norm = obj.valueNormalized; var radius = 15; var cx = a[0] + (a[2] / 2); var start = a[1] + radius; var usefulDisplacement = a[3] - 2*radius; var cy = start + usefulDisplacement * (1.0 - norm); g.setColour(obj.itemColour1); g.fillEllipse([cx - radius, cy - radius, radius * 2, radius * 2]); });