diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-11-01 00:00:40 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-11-01 10:46:05 +0000 |
| commit | b6ed3708f15b9ae534a5d51104616c1c8f7f70e0 (patch) | |
| tree | 100e8cbc35eb3bf6e94d046b0155a429693217bb /examples | |
| parent | initial commit (diff) | |
| download | watch-cad-b6ed3708f15b9ae534a5d51104616c1c8f7f70e0.tar.gz watch-cad-b6ed3708f15b9ae534a5d51104616c1c8f7f70e0.zip | |
API redesign
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demo.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/demo.lua b/examples/demo.lua new file mode 100644 index 0000000..22076b9 --- /dev/null +++ b/examples/demo.lua @@ -0,0 +1,40 @@ +-- return function (state) +function place_in_rect(state) + selection = Select_objs(state.objs, '^led-') + rect = Select_rect(state.dest) + + sx = rect.w / (#selection + 1) + + x = sx + for i, obj in ipairs(selection) do + Move(obj, rect.x + x - obj.w/2, rect.y) + x = x + sx + end +end + +function create_star(state) + local inner = Select_circle(state.inner) + local outer = Select_circle(state.outer, inner.cx, inner.cy) + + cnt = 20 + step = 2*math.pi/cnt + lag_x, lag_y = inner.cx + inner.r, inner.cy + for i = 0, 20 do + r = (i % 2 == 0) and inner.r or outer.r + x = inner.cx + math.cos(step * i) * r + y = inner.cy + math.sin(step * i) * r + obj = Object("object_"..i, x-10, y-10, 20, 20) + Add(obj) + + love.graphics.line(lag_x, lag_y, obj:center()) + lag_x, lag_y = obj:center() + end +end + +function test(S) + rect = input.rectangle(S.rect) + + input.circle(S.circle, { center = rect.min, radius = 100 }, { center = true, radius = true }) +end + +return test |
