sokoban.love/0082-draw_slider

9 lines
452 B
Plaintext

-- draw a slider widget starting at x,y, extending right w pixels
-- position 'value' on the slider
-- the leftmost point on the slider will have value 'lo', and the rightmost will have 'hi'. In between the value will be linearly interpolated.
draw_slider = function(s)
App.color(s.fg)
love.graphics.line(s.x0, s.y0, s.x1, s.y0)
s.x = s.x0 + (s.x1-s.x0)*(s.value-s.lo)/(s.hi-s.lo)
love.graphics.rectangle('fill', s.x-s.h/2, s.y0-s.h/2, s.w,s.h)
end