diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-11-19 21:47:33 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-11-19 22:03:16 +0000 |
| commit | 2501025108394d875a6e5f70686333799d27ffc8 (patch) | |
| tree | 0a5a7c06f94cad07731aa261622b9588f8e7e121 /examples | |
| parent | a touch of color (diff) | |
| download | watch-cad-2501025108394d875a6e5f70686333799d27ffc8.tar.gz watch-cad-2501025108394d875a6e5f70686333799d27ffc8.zip | |
more examples
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/axis_lock.moon | 17 | ||||
| -rw-r--r-- | examples/place_on_line.lua | 3 | ||||
| -rw-r--r-- | examples/place_on_line.moon | 10 |
3 files changed, 28 insertions, 2 deletions
diff --git a/examples/axis_lock.moon b/examples/axis_lock.moon new file mode 100644 index 0000000..91a85fd --- /dev/null +++ b/examples/axis_lock.moon @@ -0,0 +1,17 @@ +import vec2 from require 'cpml' + +=> + -- draw helper lines + origin = vec2 200, 600 + draw.line origin, vec2 200, 0 + draw.line origin, vec2 1000, 600 + + -- input two points + input.line @l, { x: 200 }, { y: 600 } + + -- restrict to first quadrant + if @l!.frm.y > 600 + @l!.frm.y = 600 + + if @l!.to.x < 200 + @l!.to.x = 200 diff --git a/examples/place_on_line.lua b/examples/place_on_line.lua index d58f713..f89a831 100644 --- a/examples/place_on_line.lua +++ b/examples/place_on_line.lua @@ -1,5 +1,4 @@ --- return function (state) -function place_in_rect(S) +function place_on_line(S) input.selection(S.objs, '^led-') input.line(S.dest) diff --git a/examples/place_on_line.moon b/examples/place_on_line.moon new file mode 100644 index 0000000..0d806be --- /dev/null +++ b/examples/place_on_line.moon @@ -0,0 +1,10 @@ +=> + input.selection @objs + input.line @dest + + dest = @dest! + step = (dest.to - dest.frm) / #@objs! + + for i, obj in ipairs @objs! + pos = dest.frm + step * (i - .5) + op.move obj, pos |
