docs: rosetta naming in README, docs, guide, licenses
This commit is contained in:
1 parent
22ddcd78fa
commit
753ae98d4a
20 files changed
+123
-123
No files matched your search
@@ -1,8 +1,8 @@
|
||||
# formats-luau
|
||||
# rosetta
|
||||
|
||||
Read, write and convert file formats in pure Luau, from one source tree that runs on **Roblox** (Luau, native code
|
||||
generation) and on **LuaJIT / LÖVE** (through `tools/build.py`). Every format of a category maps onto one standard type
|
||||
(`src/Formats/Types.luau`): a PNG and a WebP both load as an `Image`, every audio format opens as the same streaming
|
||||
(`src/Rosetta/Types.luau`): a PNG and a WebP both load as an `Image`, every audio format opens as the same streaming
|
||||
`Decoder`, every model format loads as a `Scene`.
|
||||
|
||||
174 formats: images (25), audio (21), video (11), 3D models (32), CAD (1), fonts (11), archives (31), data (11),
|
||||
@@ -12,7 +12,7 @@ vector graphics and tile maps (2), layered images (3), subtitles (3), music (20)
|
||||
walkthroughs. `tools/lint.sh` checks these counts against the registry.
|
||||
|
||||
```luau
|
||||
local F = require(Formats) -- LuaJIT: require("formats"); luau CLI: require("@formats")
|
||||
local F = require(Rosetta) -- LuaJIT: require("rosetta"); luau CLI: require("@rosetta")
|
||||
local img, err = F.load(src) -- src: buffer | string | path (hosts with files)
|
||||
if not img then print(tostring(err)) end -- errors are values: "png: CORRUPT at 0x21: bad filter type 7"
|
||||
local buf = F.save(img, nil, { format = "webp" }) -- a buffer; F.save(img, "out.webp") writes a file
|
||||
@@ -24,20 +24,20 @@ Nothing throws on bad data or bad arguments: every call returns `nil, err` (`err
|
||||
|
||||
## Install
|
||||
|
||||
**Roblox (Rojo).** `python3 -I tools/build.py roblox` writes `build/roblox/Formats` (requires turned into instance
|
||||
paths); `default.project.json` mounts it, so `rojo build -o Formats.rbxm` (or `rojo serve`) gives a `Formats`
|
||||
ModuleScript to put in ReplicatedStorage: `local F = require(game.ReplicatedStorage.Formats)`. There is no file system:
|
||||
**Roblox (Rojo).** `python3 -I tools/build.py roblox` writes `build/roblox/Rosetta` (requires turned into instance
|
||||
paths); `default.project.json` mounts it, so `rojo build -o Rosetta.rbxm` (or `rojo serve`) gives a `Rosetta`
|
||||
ModuleScript to put in ReplicatedStorage: `local F = require(game.ReplicatedStorage.Rosetta)`. There is no file system:
|
||||
pass buffers or strings. `F.host.toEditableImage(img)` makes an EditableImage, `F.host.toEditableMesh(prim, page)` an
|
||||
EditableMesh (a merged triangle primitive split by `F.host.meshPages`).
|
||||
|
||||
**LuaJIT / LÖVE.** `python3 -I tools/build.py luajit` writes `build/luajit/formats/` (Lua 5.1 + LuaJIT FFI; the Luau
|
||||
standard library pieces come from `formats/_compat.lua`). Copy the `formats` folder into the game (or put
|
||||
`build/luajit/?.lua;build/luajit/?/init.lua` on `package.path`) and `local F = require("formats")`. Files load by path
|
||||
**LuaJIT / LÖVE.** `python3 -I tools/build.py luajit` writes `build/luajit/rosetta/` (Lua 5.1 + LuaJIT FFI; the Luau
|
||||
standard library pieces come from `rosetta/_compat.lua`). Copy the `rosetta` folder into the game (or put
|
||||
`build/luajit/?.lua;build/luajit/?/init.lua` on `package.path`) and `local F = require("rosetta")`. Files load by path
|
||||
(`love.filesystem` under LÖVE, else `io.open`); `F.host.toImageData(img)`, `F.host.fromImageData(imageData)` and
|
||||
`F.host.toSoundData(audioOrDecoder)` bridge to LÖVE. `examples/love` is a runnable example and smoke test
|
||||
(`love examples/love` from the repo root after building).
|
||||
|
||||
**luau CLI.** `luau` with the `.luaurc` alias `@formats` runs `src/` directly (no file system).
|
||||
**luau CLI.** `luau` with the `.luaurc` alias `@rosetta` runs `src/` directly (no file system).
|
||||
|
||||
## Quick start
|
||||
|
||||
@@ -98,13 +98,13 @@ hands to formats (decodeImage / encodeImage / openAudio / plugins): [docs/API.md
|
||||
(OBJ `.mtl`, glTF `.bin` and textures) are found through `opts.resolve`, which the api fills in for paths.
|
||||
- **LuaJIT trace tuning.** On load the host raises LuaJIT's trace limits (`jit.opt.start("maxtrace=8000",
|
||||
"maxmcode=65536")`): the big decoders (Opus CELT, VP8, H.264, MPEG-1) outgrow the defaults and fall back to the
|
||||
interpreter (2x or more slower). Set `_G.FORMATS_NO_JIT_TUNE = true` before requiring the library to leave the
|
||||
interpreter (2x or more slower). Set `_G.ROSETTA_NO_JIT_TUNE = true` before requiring the library to leave the
|
||||
JIT settings alone.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
src/Formats/
|
||||
src/Rosetta/
|
||||
init.luau Registry.luau (generated) api: F.*
|
||||
ops/ editing on the standard types (ImageOps, MeshOps, LayerOps, AudioOps, ...)
|
||||
<category>/<fmt>/ formats: only what is specific to the format (parsing, mapping, writing)
|
||||
@@ -139,7 +139,7 @@ bash tools/test.sh png # one test (both runtimes), no lint
|
||||
bash tools/lint.sh # globals, types, headers, requires, native-throw, layers, deps, contract, DUP, docs
|
||||
bash tools/bench.sh # throughput on both runtimes (pin it: taskset -c 2 bash tools/bench.sh)
|
||||
python3 -I tools/build.py # build/roblox + build/luajit
|
||||
python3 -I tools/gen_registry.py # src/Formats/Registry.luau + docs/FORMATS.md from the format folders
|
||||
python3 -I tools/gen_registry.py # src/Rosetta/Registry.luau + docs/FORMATS.md from the format folders
|
||||
python3 -I tools/fixtures.py # tests/gen/*.luau from tools/fixtures/*.py (reference tools through nix)
|
||||
python3 -I tools/move.py codecs/image/Foo=codecs/video/Foo # move a module, rewriting every reference
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user