git.s-ol.nu alive / 0af441c
love: add circle, ellipse primitives, support array args s-ol 4 months ago
1 changed file(s) with 46 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
3434 destroy: =>
3535 COPILOT.drawlist[@state] = nil
3636
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
3777 rectangle = Constant.meta
3878 meta:
3979 name: 'rectangle'
5696 meta:
5797 name: 'color'
5898 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']
63103 type: T['love/shape']
64104
65105 tick: =>
211251 value:
212252 :draw
213253
214 :rectangle
254 'no-shape': no_shape
255 :circle, :ellipse, :line, :rectangle
215256
216257 :translate, :rotate, :scale, :shear
217258 :color