diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-11-03 16:23:43 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-11-03 16:23:43 +0000 |
| commit | 157f6c0fdb37e8490c293a44d9ed08cd3dc63291 (patch) | |
| tree | 4cfbb2899e615c90f033a31aa4019513047d805e /examples/create_star.lua | |
| parent | add profiling support (diff) | |
| download | watch-cad-157f6c0fdb37e8490c293a44d9ed08cd3dc63291.tar.gz watch-cad-157f6c0fdb37e8490c293a44d9ed08cd3dc63291.zip | |
update examples, fixes
Diffstat (limited to 'examples/create_star.lua')
| -rw-r--r-- | examples/create_star.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/create_star.lua b/examples/create_star.lua new file mode 100644 index 0000000..520cf07 --- /dev/null +++ b/examples/create_star.lua @@ -0,0 +1,26 @@ +local vec2 = (require 'cpml').vec2 + +function draw_star(S) + input.circle(S.inner) + input.circle(S.outer, { center = S.inner().center }) + + local inner, outer = S.inner(), S.outer() + + local cnt = 20 + local step = 2*math.pi/cnt + local lag = inner.center + vec2(inner.radius, 0) + for i = 0, 20 do + local r = (i % 2 == 0) and inner.radius or outer.radius + local pos = inner.center + vec2.from_cartesian(r, step * i) + + draw.cross(pos) + draw.line(pos, lag) + + -- obj = Object("object_"..i, pos, vec2(20, 20)) + -- op.add(obj) + + lag = pos + end +end + +return draw_star |
