vec: layered/aseprite read + write (RGBA/gray/indexed, raw/zlib/linked cels, groups, blend, layer+cel opacity, palettes old+new, tags, user data); tests vs LibreSprite renders, LibreSprite reading our sprites, round trips; tools/fixtures/_ours.luau runs our encoders for the reference tools
This commit is contained in:
1 parent
e0629b12a3
commit
b76b2ec32d
6 files changed
+1185
No files matched your search
@@ -87,6 +87,30 @@ local function psdDoc(): Types.Layered
|
||||
return doc
|
||||
end
|
||||
|
||||
-- an animated sprite (tests/layered/aseprite.luau builds the same one)
|
||||
local function aseDoc(): Types.Layered
|
||||
local L = Types.Layered
|
||||
local doc = L.new(24, 16)
|
||||
local bgImg = image(24, 16, 1)
|
||||
local shared = image(10, 8, 2, true)
|
||||
local frames = {}
|
||||
for f = 1, 3 do
|
||||
local bg = L.layer("Background", bgImg)
|
||||
local mul = L.layer("Mul", if f == 2 then image(10, 8, 7, true) else shared, 3 + (if f == 2 then 1 else 0), 2)
|
||||
mul.blend = "multiply"
|
||||
local half = L.layer("Half", image(12, 9, 3 + f, true), f * 2, 4)
|
||||
half.fillOpacity = 128 / 255
|
||||
local g = L.group("Group", { mul, half })
|
||||
local top = L.layer("Top", image(6, 6, 9 + f, true), 16 - f, 8)
|
||||
top.opacity = 200 / 255
|
||||
frames[f] = { layers = { bg, g, top }, delay = 0.05 * f }
|
||||
end
|
||||
doc.frames = frames
|
||||
doc.layers = frames[1].layers
|
||||
doc.meta.tags = { { name = "all", from = 1, to = 3, direction = "pingpong", ["repeat"] = 0 } }
|
||||
return doc
|
||||
end
|
||||
|
||||
local which = ...
|
||||
if which == "psd" then
|
||||
local Psd = require("@formats/layered/psd")
|
||||
@@ -99,4 +123,13 @@ if which == "psd" then
|
||||
table.insert(layers, { name = lay.name, crc = Crc32.of(lay.image.pixels), left = lay.x, top = lay.y, width = lay.image.width, height = lay.image.height, blend = lay.blend, visible = lay.visible, clip = lay.clip == true, opacity = math.floor(lay.opacity * 255 + 0.5), depth = depth })
|
||||
end
|
||||
print(json({ data = hex(data), composite = Crc32.of(flat.pixels), layers = layers }))
|
||||
elseif which == "aseprite" then
|
||||
local Ase = require("@formats/layered/aseprite")
|
||||
local doc = aseDoc()
|
||||
local data = Ase.encode(doc) :: buffer
|
||||
local frames = {}
|
||||
for f = 1, 3 do
|
||||
frames[f] = hex((LayerOps.flatten(doc, { frame = f }) :: Types.Image).pixels)
|
||||
end
|
||||
print(json({ data = hex(data), nframes = 3, frames = frames }))
|
||||
end
|
||||
Reference in new issue
Block a user