aboutsummaryrefslogtreecommitdiffstats
path: root/api.moon
diff options
context:
space:
mode:
Diffstat (limited to 'api.moon')
-rw-r--r--api.moon28
1 files changed, 25 insertions, 3 deletions
diff --git a/api.moon b/api.moon
index 3435cb7..6234dd0 100644
--- a/api.moon
+++ b/api.moon
@@ -50,8 +50,30 @@ draw =
half_handle = vec2 15, 15
input =
+ slider: (min=0, max=1) =>
+ @init min
+
+ origin = vec2 50, 50
+ length = 200
+ final = origin + vec2 length, 0
+ draw.line origin, final
+
+ if input.point @value, y: origin.y, x: Once min
+ val = math.max origin.x, math.min final.x, @value!.x
+ @value!.x = val
+ @set min + (val - origin.x) / length * max
+ return true
+
point: (fixed={}) =>
- last = @init random.point!
+ init = if val = is_once fixed
+ val
+ else
+ with random.point!
+ if x = is_once fixed.x
+ .x = x
+ if y = is_once fixed.y
+ .y = y
+ last = @init init
pos = last\clone!
live_x, live_y = (is_live fixed.x), is_live fixed.y
@@ -68,8 +90,8 @@ input =
-- handle size (square or rect)
hh = half_handle\clone!
- hh.x /= 2 if live_x
- hh.y /= 2 if live_y
+ hh.y /= 2 if live_x
+ hh.x /= 2 if live_y
if 'down' == draw.rect pos - hh, pos + hh
@drag\set true