aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-09-14 14:56:57 +0000
committers-ol <s+removethis@s-ol.nu>2025-09-14 16:19:37 +0000
commit85409870ba970650a244217b029e4a1fea04a387 (patch)
treecd1db49a28795f06e4036e30f02249421b98e8f4
parentlib/glsl-view: assemble uniform preamble in send (diff)
downloadalive-85409870ba970650a244217b029e4a1fea04a387.tar.gz
alive-85409870ba970650a244217b029e4a1fea04a387.zip
lib/love: fix text, add group
-rw-r--r--alv-lib/love.moon39
1 files changed, 26 insertions, 13 deletions
diff --git a/alv-lib/love.moon b/alv-lib/love.moon
index 0500b6c..c88986f 100644
--- a/alv-lib/love.moon
+++ b/alv-lib/love.moon
@@ -20,10 +20,6 @@ draw = Constant.meta
examples: { '(love/draw shape1 …)', '(love/draw shapes)' }
value: class extends Op
- new: (...) =>
- super ...
- @state or= DrawId!
-
pattern = any['love/shape']*0
setup: (inputs, scope) =>
if #inputs == 1
@@ -42,10 +38,28 @@ draw = Constant.meta
shapes = @unwrap_all!
num = shapes.num or #shapes
for i=1, num do shapes[i] or= ->
- COPILOT.drawlist[@state] = shapes
+
+ COPILOT.drawlist[tostring @tag] = shapes
destroy: =>
- COPILOT.drawlist[@state] = nil
+ COPILOT.drawlist[tostring @tag] = nil
+
+group = Constant.meta
+ meta:
+ name: 'group'
+ summary: "combine shapes to transform as one."
+ examples: { '(love/group shape…)' }
+
+ value: class extends PureOp
+ pattern: any['love/shape']*0
+ type: T['love/shape']
+
+ tick: =>
+ shapes = @unwrap_all!
+
+ @out\set ->
+ for shape in *shapes
+ shape!
window_mode = Constant.meta
meta:
@@ -166,13 +180,12 @@ Create a shape that draws the text `str` with font `font` (or the default font).
- `left`
- `right`"
-
value: class extends PureOp
pattern: any.str + -any.str + -any['love/font']
type: T['love/shape']
tick: =>
- { text, align, font } = @unwrap_all!
+ { str, align, fnt } = @unwrap_all!
wm = switch align or 'center'
when 'left' then 0
@@ -182,10 +195,10 @@ Create a shape that draws the text `str` with font `font` (or the default font).
error Error 'argument', "unknown text alignment '#{align}'"
@out\set ->
- font or= love.graphics.getFont!
- width = font\getWidth text
- height = font\getHeight!
- love.graphics.print text, font, width*wm, -height/2
+ fnt or= love.graphics.getFont!
+ width = fnt\getWidth str
+ height = fnt\getHeight!
+ love.graphics.print str, fnt, width*wm, -height/2
color = Constant.meta
meta:
@@ -586,7 +599,7 @@ macro [->>][]:
[love]: https://love2d.org"
value:
- :draw
+ :draw, :group
'window-mode': window_mode
'no-shape': no_shape