ws-tex: docs/guide sections (textures / HDR, OpenRaster); DDS / KTX pixelFormat option; XBM / XPM names from F.save

F.save sets opts.format to the file format, so the DDS / KTX layout option is pixelFormat; XBM / XPM make a C
identifier of opts.name (F.save passes the file name).
This commit is contained in:
4DBug committed 2026-10-31 15:18:40 -05:00
1 parent d618795ce7
commit 918c8310af
10 files changed
+90 -30

No files matched your search

+25 -3
View File
@@ -1,8 +1,8 @@
# Layered images (PSD, Aseprite)
# Layered images (PSD, Aseprite, OpenRaster)
Photoshop documents and Aseprite sprites load as a `Layered`: a canvas size and a tree of layers, each with its own
Photoshop documents, Aseprite sprites and OpenRaster files load as a `Layered`: a canvas size and a tree of layers, each with its own
rgba8 [Image](image.md), position, opacity, blend mode and visibility. `F.ops.layers.flatten` composites the tree
into one Image; `F.save` writes PSD or Aseprite, layers included. Aseprite animations also carry every frame's tree.
into one Image; `F.save` writes PSD, Aseprite or OpenRaster, layers included. Aseprite animations also carry every frame's tree.
```luau
local doc = assert(F.layered.load(psdBytes))
@@ -230,6 +230,28 @@ assert(#back.frames == 4 and back.frames[3].layers[1].x == 3)
|---|---|---|---|
| PSD / PSB | 1 / 8 / 16 / 32-bit, every colour mode, layers, groups, masks, clipping | 8-bit RGB | adjustment, type and smart-object layers keep only their pixels; no layer effects |
| Aseprite | RGBA, grayscale, indexed; frames, linked cels, tags, palette, user data | yes | tilemap layers are skipped (`meta.skipped`); slices not kept |
| OpenRaster (ORA) | the stack tree (nested stacks = groups), offsets, opacity, visibility, svg composite-ops | yes | layers are PNGs through the api hooks; `meta.composite` = mergedimage.png |
### OpenRaster
An `.ora` file is a zip of PNG layers and a `stack.xml` tree (the format GIMP, Krita and MyPaint exchange). It loads
like the others; nested `<stack>`s become groups (`isolation="auto"` is the `"passThrough"` blend). Saving writes every
layer, the flattened `mergedimage.png` and a thumbnail.
```luau
local doc = F.Types.Layered.new(32, 24)
local base = assert(F.ops.image.new(32, 24))
assert(F.ops.image.fill(base, 30, 60, 200, 255))
local dot = assert(F.ops.image.new(8, 8))
assert(F.ops.image.fill(dot, 255, 255, 0, 255))
local top = F.Types.Layered.layer("dot", dot, 12, 8)
top.blend, top.opacity = "screen", 0.5
doc.layers = { F.Types.Layered.layer("base", base), top }
local ora = assert(F.save(doc, nil, { format = "ora" }))
local back = assert(F.layered.load(ora))
assert(#back.layers == 2 and back.layers[2].blend == "screen" and back.layers[2].x == 12)
assert(back.meta.composite.width == 32) -- mergedimage.png
```
See [FORMATS.md](../FORMATS.md) for the capability matrix.