aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-11-13 12:02:35 +0000
committers-ol <s-ol@users.noreply.github.com>2019-11-13 12:02:47 +0000
commitb651f4dbcbec7eccfcb90ea2b23e28d988e36026 (patch)
treeaea6d2ef5f3420bde3fc7fe5c0727d6bd85fb8b3 /examples
parentadd input.slider (diff)
downloadwatch-cad-b651f4dbcbec7eccfcb90ea2b23e28d988e36026.tar.gz
watch-cad-b651f4dbcbec7eccfcb90ea2b23e28d988e36026.zip
add line, arrow; hover events
Diffstat (limited to 'examples')
-rw-r--r--examples/capsule.moon2
-rw-r--r--examples/place_in_rect.lua17
-rw-r--r--examples/place_on_line.lua17
-rw-r--r--examples/test.moon2
4 files changed, 19 insertions, 19 deletions
diff --git a/examples/capsule.moon b/examples/capsule.moon
index 2a9033c..fe546e2 100644
--- a/examples/capsule.moon
+++ b/examples/capsule.moon
@@ -5,7 +5,7 @@ import vec2 from require 'cpml'
=>
-- let's try to construct a pill-shape
- input.rectangle @rect
+ input.rect @rect
rect = @rect!
hsize = (rect.max - rect.min) / 2
diff --git a/examples/place_in_rect.lua b/examples/place_in_rect.lua
deleted file mode 100644
index 3650257..0000000
--- a/examples/place_in_rect.lua
+++ /dev/null
@@ -1,17 +0,0 @@
--- return function (state)
-function place_in_rect(S)
- input.selection(S.objs, '^led-')
- input.rect(S.dest)
-
- local start = S.min()
- local step = S.dest():size()
- step.y = 0
-
- for i, obj in ipairs(S.objs()) do
- local pos = start + step:scale(i)
- draw.cross(pos)
- -- op.move(obj, pos)
- end
-end
-
-return place_in_rect
diff --git a/examples/place_on_line.lua b/examples/place_on_line.lua
new file mode 100644
index 0000000..d58f713
--- /dev/null
+++ b/examples/place_on_line.lua
@@ -0,0 +1,17 @@
+-- return function (state)
+function place_in_rect(S)
+ input.selection(S.objs, '^led-')
+ input.line(S.dest)
+
+ local dest = S.dest()
+ local start = dest.frm
+ local step = (dest.to - dest.frm) / #S.objs()
+ start = start - step/2
+
+ for i, obj in ipairs(S.objs()) do
+ local pos = start + step * i
+ op.move(obj, pos)
+ end
+end
+
+return place_in_rect
diff --git a/examples/test.moon b/examples/test.moon
index 352ebd2..ef25cd8 100644
--- a/examples/test.moon
+++ b/examples/test.moon
@@ -3,6 +3,6 @@ import vec2 from require 'cpml'
=>
input.point @p
- input.rectangle @re, max: @p!
+ input.rect @re, max: @p!
input.circle @circ, center: @p!