login

<     >

2021-08-28 10:53:01 (UTC-03:00)

Marcel Rodrigues <marcelgmr@gmail.com>

surf: add Surf:compose()

diff --git a/surf.lua b/surf.lua
index a6a3951..a175e6b 100644
--- a/surf.lua
+++ b/surf.lua
@@ -166,6 +166,19 @@ function Surf:blit(x, y, surf, sx, sy, w, h)
     end
 end
 
+function Surf:compose(layers)
+    for y = 0, self.h-1 do
+        for x = 0, self.w-1 do
+            for _, layer in ipairs(layers) do
+                local p = layer.map[layer.surf:pget(x, y)+1]
+                if p >= 0 then
+                    self:pset(x, y, p)
+                end
+            end
+        end
+    end
+end
+
 local BitMap = {}
 
 function BitMap:fill(v)