A lightweight programming environment for desktop and mobile devices
slider_value = function(slider, x)
	local s = slider
	if x < s.x0 then x = s.x0 end
	if x > s.x1 then x = s.x1 end
	s.x = x
	s.value = s.lo + (s.x-s.x0)*(s.hi-s.lo)/(s.x1-s.x0)
	return s.value
end