rename: src/Formats -> src/Rosetta, @formats -> @rosetta requires, build/luajit/rosetta + rosetta._compat, build/roblox/Rosetta, ROSETTA_* env/globals, writer vendor strings
This commit is contained in:
1 parent
2956576d7f
commit
22ddcd78fa
941 files changed
+3364
-3364
No files matched your search
@@ -1,11 +1,11 @@
|
||||
-- examples/archive.luau: builds a zip, lists and reads it, edits it, converts it to a .tar.gz and back, and gzips a
|
||||
-- single file. Run from the repository root: luau examples/archive.luau (docs/guide/archive.md explains the API).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
-- a new zip: a directory, a text file, an incompressible file stored as is
|
||||
local zip = F.format("zip").create()
|
||||
zip:add("game/", nil)
|
||||
zip:add("game/readme.txt", string.rep("formats-luau reads and writes archives. ", 20), { level = 9 })
|
||||
zip:add("game/readme.txt", string.rep("rosetta reads and writes archives. ", 20), { level = 9 })
|
||||
local noise = buffer.create(2048)
|
||||
local seed = 7
|
||||
for i = 0, 2047 do
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- Audio example (formats-luau): build a sound, edit it with F.ops.audio, encode it to several formats, then stream it
|
||||
-- Audio example (rosetta): build a sound, edit it with F.ops.audio, encode it to several formats, then stream it
|
||||
-- back with a Decoder. Run from the repository root: luau examples/audio.luau (docs/guide/audio.md explains the API).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
local A = F.ops.audio
|
||||
|
||||
-- 1. one second of a stereo chord: interleaved f32 samples, frame i / channel c at byte (i * channels + c) * 4
|
||||
@@ -11,7 +11,7 @@ for i = 0, tone.frames - 1 do
|
||||
buffer.writef32(tone.samples, (i * 2) * 4, 0.3 * math.sin(2 * math.pi * 261.63 * t)) -- left: C4
|
||||
buffer.writef32(tone.samples, (i * 2 + 1) * 4, 0.3 * math.sin(2 * math.pi * 329.63 * t)) -- right: E4
|
||||
end
|
||||
tone.tags = { title = "Example chord", artist = "formats-luau" }
|
||||
tone.tags = { title = "Example chord", artist = "rosetta" }
|
||||
|
||||
-- 2. edit: fade, normalize, a mono copy at 16 kHz, then the two one after the other
|
||||
local shaped = assert(A.normalize(assert(A.fade(tone, 0.05, 0.2)), 0.8))
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
-- examples/cad.luau: reads a small STEP file, walks its entity graph (references, complex instances), adds an entity
|
||||
-- and writes it back under another schema. Run from the repository root: luau examples/cad.luau
|
||||
-- Solid geometry (B-rep bodies, meshes) needs a kernel plug-in, F.plugins.brep: see docs/guide/cad.md.
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
local STEP = [[
|
||||
ISO-10303-21;
|
||||
HEADER;
|
||||
FILE_DESCRIPTION(('example'),'2;1');
|
||||
FILE_NAME('bracket.step','2026-10-31T12:00:00',('me'),(''),'formats-luau','','');
|
||||
FILE_NAME('bracket.step','2026-10-31T12:00:00',('me'),(''),'rosetta','','');
|
||||
FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
|
||||
ENDSEC;
|
||||
DATA;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
-- examples/data.luau: one record through JSON, YAML, TOML, MessagePack and CBOR, plus CSV rows, an INI file and an
|
||||
-- XML document. Run from the repository root: luau examples/data.luau (docs/guide/data.md explains the values).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
local Types = F.Types
|
||||
|
||||
-- an ordered record with a null, an empty object and a date
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
-- into a BMFont (descriptor + page images). Run from the repository root: luau examples/font.luau
|
||||
-- It needs a .ttf: from the repo it uses the docs test font (generate it first with python3 -I tools/fixtures.py docs),
|
||||
-- elsewhere set TTF_BYTES below to the bytes of any font (the luau CLI cannot read files). docs/guide/font.md explains.
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
local TTF_BYTES: buffer? = nil
|
||||
if not TTF_BYTES then
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
-- examples/image.luau: build an image, edit it with F.ops.image, save it in several formats, make an animated GIF and
|
||||
-- read it back. Run from the repository root: luau examples/image.luau (the .luaurc alias @formats points at src/).
|
||||
-- On LuaJIT / LÖVE, the same calls work with local F = require("formats") (docs/guide/image.md).
|
||||
local F = require("@formats")
|
||||
-- read it back. Run from the repository root: luau examples/image.luau (the .luaurc alias @rosetta points at src/).
|
||||
-- On LuaJIT / LÖVE, the same calls work with local F = require("rosetta") (docs/guide/image.md).
|
||||
local F = require("@rosetta")
|
||||
local I = F.ops.image
|
||||
|
||||
-- a 64 x 48 rgba8 gradient: 4 bytes per pixel, rows top to bottom, pixel (x, y) at byte (y * width + x) * 4
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- examples/layered.luau: build a layered document (a group, a clipping layer, a blend mode), flatten it, save it as
|
||||
-- PSD and Aseprite, and make a small Aseprite animation exported as a GIF. Run from the repository root:
|
||||
-- luau examples/layered.luau (docs/guide/layered.md explains the type).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
local I, L = F.ops.image, F.Types.Layered
|
||||
|
||||
local function solid(w, h, r, g, b, a)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function love.conf(t)
|
||||
t.identity = "formats-luau-smoke"
|
||||
t.identity = "rosetta-smoke"
|
||||
t.window.width, t.window.height = 800, 600
|
||||
end
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
-- LÖVE smoke test / example for the LuaJIT build (tools/build.py luajit), run from the repo root:
|
||||
-- love examples/love (a window: images, a voxel model, a tone)
|
||||
-- FORMATS_SMOKE=1 xvfb-run love examples/love (headless: checks, a screenshot, then quits; exit code 1 on
|
||||
-- ROSETTA_SMOKE=1 xvfb-run love examples/love (headless: checks, a screenshot, then quits; exit code 1 on
|
||||
-- failure)
|
||||
-- It decodes repo fixtures (PNG suite, a MagicaVoxel model, a glTF box), round-trips an image through PNG / JPEG /
|
||||
-- WebP / GIF / QOI / BMP and a tone through FLAC / WAV / Vorbis / MP3, rasterizes an SVG, plays an animated GIF as a
|
||||
@@ -8,13 +8,13 @@
|
||||
-- the host's toImageData / toSoundData. docs/guide/README.md explains the API.
|
||||
local root = (love.filesystem.getSource():gsub("/examples/love/?$", ""))
|
||||
package.path = root .. "/build/luajit/?.lua;" .. root .. "/build/luajit/?/init.lua;" .. package.path
|
||||
local F = require("formats")
|
||||
require("formats._compat").install() -- buffer / bit32 globals for this file (the library itself does not need them)
|
||||
local F = require("rosetta")
|
||||
require("rosetta._compat").install() -- buffer / bit32 globals for this file (the library itself does not need them)
|
||||
|
||||
local SMOKE = os.getenv("FORMATS_SMOKE") == "1"
|
||||
local SMOKE = os.getenv("ROSETTA_SMOKE") == "1"
|
||||
if SMOKE then -- headless: print the error and exit instead of showing LÖVE's error screen
|
||||
function love.errorhandler(msg)
|
||||
print("formats-luau love smoke: ERROR " .. tostring(msg) .. "\n" .. debug.traceback())
|
||||
print("rosetta love smoke: ERROR " .. tostring(msg) .. "\n" .. debug.traceback())
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
@@ -38,7 +38,7 @@ local function tile(name, img)
|
||||
end
|
||||
|
||||
function love.load()
|
||||
love.window.setTitle("formats-luau on LÖVE " .. table.concat({ love.getVersion() }, ".", 1, 3))
|
||||
love.window.setTitle("rosetta on LÖVE " .. table.concat({ love.getVersion() }, ".", 1, 3))
|
||||
check(F.host.name == "love", "host detected", F.host.name)
|
||||
|
||||
-- a decoded fixture
|
||||
@@ -46,7 +46,7 @@ function love.load()
|
||||
if check(png ~= nil and png.width == 32, "png fixture", errstr(e)) then tile("basn6a08.png", png) end
|
||||
|
||||
-- a generated image, saved and reloaded through every image writer
|
||||
local Types = require("formats.Types")
|
||||
local Types = require("rosetta.Types")
|
||||
local img = Types.Image.new(96, 64, "rgba8")
|
||||
for y = 0, 63 do
|
||||
for x = 0, 95 do
|
||||
@@ -164,9 +164,9 @@ function love.draw()
|
||||
if SMOKE and frames == 3 then
|
||||
check(videoFrames > 0, "video frames shown", videoFrames)
|
||||
love.graphics.captureScreenshot(function(data)
|
||||
data:encode("png", "formats_smoke.png")
|
||||
print("screenshot: " .. love.filesystem.getSaveDirectory() .. "/formats_smoke.png")
|
||||
print(failed == 0 and "formats-luau love smoke: all passed" or ("formats-luau love smoke: " .. failed .. " FAILED"))
|
||||
data:encode("png", "rosetta_smoke.png")
|
||||
print("screenshot: " .. love.filesystem.getSaveDirectory() .. "/rosetta_smoke.png")
|
||||
print(failed == 0 and "rosetta love smoke: all passed" or ("rosetta love smoke: " .. failed .. " FAILED"))
|
||||
love.event.quit(failed == 0 and 0 or 1)
|
||||
end)
|
||||
end
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
-- Music example (formats-luau): write a MIDI file from scratch, read it back, and render it to audio with the built-in
|
||||
-- Music example (rosetta): write a MIDI file from scratch, read it back, and render it to audio with the built-in
|
||||
-- waveforms (pass a SoundFont as { soundfont = sf2Bytes } for real instruments). Run from the repository root:
|
||||
-- luau examples/music.luau (docs/guide/music.md explains the API).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
-- 1. a Midi: 480 ticks per quarter note, absolute ticks, a tempo, a track name and a little melody
|
||||
local midi = F.Types.Midi.new(480)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- examples/playlist.luau: reads an M3U with a base URL, inspects an HLS master playlist, and converts a playlist to
|
||||
-- PLS and XSPF. Run from the repository root: luau examples/playlist.luau (docs/guide/playlist.md explains the type).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
local M3U = "#EXTM3U\n#PLAYLIST:Road Trip\n#EXTINF:215,Ada - First Song\nmusic/first.mp3\n"
|
||||
.. "#EXTINF:187,Bob - Second Song\nhttps://cdn.example/second.ogg\n#EXTINF:-1,Live\nhttp://radio.example/live\n"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
-- examples/scene.luau: builds a 3D scene from scratch (a cube with a material, plus a voxel grid), edits it with
|
||||
-- F.ops.mesh and saves it as GLB, OBJ + MTL and STL. Run from the repository root: luau examples/scene.luau
|
||||
-- (docs/guide/scene.md explains the Scene type).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
local S = F.Types.Scene
|
||||
|
||||
-- a unit cube: 8 corners, 12 triangles (indices are 0-based vertex numbers, as in glTF)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- examples/tilemap.luau: read a Tiled map (TMX), walk its tile layer with the flip flags, find an object, edit the map
|
||||
-- and convert it to TMJ. Run from the repository root: luau examples/tilemap.luau (docs/guide/tilemap.md).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
local tmx = [[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" orientation="orthogonal" renderorder="right-down" width="5" height="3" tilewidth="16"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- examples/vector.luau: parse an SVG, inspect its paths, rasterize it at two sizes, build a Vector from scratch and
|
||||
-- write it as SVG. Run from the repository root: luau examples/vector.luau (docs/guide/vector.md explains the type).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
|
||||
local svg = [[<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24">
|
||||
<rect x="1" y="1" width="22" height="22" rx="4" fill="#2d6cdf"/>
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
-- Video example (formats-luau): make frames with F.ops.image, write them as an AVI (Motion-JPEG), then open the
|
||||
-- Video example (rosetta): make frames with F.ops.image, write them as an AVI (Motion-JPEG), then open the
|
||||
-- video, walk its packets and frames, seek, and turn it into an animated GIF. Run from the repository root:
|
||||
-- luau examples/video.luau (docs/guide/video.md explains the API).
|
||||
local F = require("@formats")
|
||||
local F = require("@rosetta")
|
||||
local I = F.ops.image
|
||||
|
||||
-- 1. twelve 64 x 48 frames: a square moving across a dark background
|
||||
|
||||
Reference in new issue
Block a user