love: add circle, ellipse primitives, support array args
s-ol
1 year, 14 days ago
34 | 34 | destroy: => |
35 | 35 | COPILOT.drawlist[@state] = nil |
36 | 36 | |
37 | no_shape = Constant.meta | |
38 | meta: | |
39 | name: 'no-shape' | |
40 | summary: "invisible null shape." | |
41 | ||
42 | value: T['love/shape']\mk_const -> | |
43 | ||
44 | circle = Constant.meta | |
45 | meta: | |
46 | name: 'circle' | |
47 | summary: "create a circle shape." | |
48 | examples: { '(love/circle mode radius [segments])' } | |
49 | ||
50 | value: class extends PureOp | |
51 | pattern: any.str + any.num + -any.num | |
52 | type: T['love/shape'] | |
53 | ||
54 | tick: => | |
55 | { mode, radius, segments } = @unwrap_all! | |
56 | ||
57 | @out\set -> | |
58 | love.graphics.circle mode, 0, 0, radius, segments | |
59 | ||
60 | ellipse = Constant.meta | |
61 | meta: | |
62 | name: 'ellipse' | |
63 | summary: "create a ellipse shape." | |
64 | examples: { '(love/ellipse mode size [segments])', '(love/ellipse mode rx ry [segments])' } | |
65 | ||
66 | value: class extends PureOp | |
67 | pattern: any.str + (any(vec2) / (any.num + any.num)) + -any.num | |
68 | type: T['love/shape'] | |
69 | ||
70 | tick: => | |
71 | { mode, size, segments } = @unwrap_all! | |
72 | { rx, ry } = size | |
73 | ||
74 | @out\set -> | |
75 | love.graphics.ellipse mode, 0, 0, rx, ry, segments | |
76 | ||
37 | 77 | rectangle = Constant.meta |
38 | 78 | meta: |
39 | 79 | name: 'rectangle' |
56 | 96 | meta: |
57 | 97 | name: 'color' |
58 | 98 | summary: "set color of a shape." |
59 | examples: { '(love/color r g b [a] shape)' } | |
60 | ||
61 | value: class extends PureOp | |
62 | pattern: any.num\rep(3, 4) + any['love/shape'] | |
99 | examples: { '(love/color color shape)', '(love/color r g b [a] shape)' } | |
100 | ||
101 | value: class extends PureOp | |
102 | pattern: (any(vec3) / any(vec4) / any.num\rep(3, 4)) + any['love/shape'] | |
63 | 103 | type: T['love/shape'] |
64 | 104 | |
65 | 105 | tick: => |
211 | 251 | value: |
212 | 252 | :draw |
213 | 253 | |
214 | :rectangle | |
254 | 'no-shape': no_shape | |
255 | :circle, :ellipse, :line, :rectangle | |
215 | 256 | |
216 | 257 | :translate, :rotate, :scale, :shear |
217 | 258 | :color |