examples: short headers
This commit is contained in:
1 parent
2591255694
commit
e23adf2a2d
13 files changed
+16
-36
No files matched your search
@@ -1,5 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/archive.luau: build, read and edit a zip, convert it to .tar.gz and back, gzip a file (docs/guide/archive.md).
|
||||
local F = require("@rosetta")
|
||||
|
||||
-- a new zip: a directory, a text file, an incompressible file stored as is
|
||||
@@ -16,7 +15,6 @@ zip:add("game/noise.bin", noise, { method = "store" })
|
||||
local zipBytes = assert(F.save(zip, nil, { format = "zip", comment = "example" }))
|
||||
print(string.format("zip: %d bytes", buffer.len(zipBytes)))
|
||||
|
||||
-- list and read
|
||||
local loaded = assert(F.archive.load(zipBytes))
|
||||
for _, e in loaded:list() do
|
||||
print(string.format(" %-18s %6d -> %6s %s", e.name, e.size, tostring(e.compressedSize), e.method or (if e.dir then "dir" else "")))
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/audio.luau: build a sound, edit it, encode it to several formats, stream it back (docs/guide/audio.md).
|
||||
local F = require("@rosetta")
|
||||
local A = F.ops.audio
|
||||
|
||||
|
||||
+2
-4
@@ -1,6 +1,5 @@
|
||||
-- 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.
|
||||
-- examples/cad.luau: read a STEP file, walk its entity graph, add an entity, write it as AP242 (docs/guide/cad.md).
|
||||
-- Solid geometry (B-rep bodies, meshes) needs a kernel plug-in, F.plugins.brep.
|
||||
local F = require("@rosetta")
|
||||
|
||||
local STEP = [[
|
||||
@@ -54,7 +53,6 @@ local si = assert(step.part(cad.entities[20], "SI_UNIT"))
|
||||
print("length unit:", si[1].enum, si[2].enum) -- MILLI METRE
|
||||
assert(si[1].enum == "MILLI")
|
||||
|
||||
-- the product name
|
||||
local product = cad.entities[step.byType(cad, "PRODUCT")[1]]
|
||||
print("product:", product.args[1], product.args[2])
|
||||
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/data.luau: one record through JSON, YAML, TOML, MessagePack and CBOR; CSV, INI and XML (docs/guide/data.md).
|
||||
local F = require("@rosetta")
|
||||
local Types = F.Types
|
||||
|
||||
|
||||
+2
-4
@@ -1,7 +1,5 @@
|
||||
-- examples/font.luau: loads a TrueType font, prints its metrics, renders a line of text into a PNG and bakes the font
|
||||
-- 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.
|
||||
-- examples/font.luau: load a TrueType font, render text into a PNG, bake a BMFont (docs/guide/font.md).
|
||||
-- Needs a .ttf: in the repo, the docs test font (python3 -I tools/fixtures.py docs); elsewhere set TTF_BYTES below.
|
||||
local F = require("@rosetta")
|
||||
|
||||
local TTF_BYTES: buffer? = nil
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
-- 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 @rosetta points at src/).
|
||||
-- On LuaJIT / LÖVE, the same calls work with local F = require("rosetta") (docs/guide/image.md).
|
||||
-- examples/image.luau: build an image, edit it, save it in several formats, make an animated GIF (docs/guide/image.md).
|
||||
-- On LuaJIT / LÖVE: local F = require("rosetta").
|
||||
local F = require("@rosetta")
|
||||
local I = F.ops.image
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/layered.luau: build a layered document, flatten it, save PSD and Aseprite, export a GIF (docs/guide/layered.md).
|
||||
local F = require("@rosetta")
|
||||
local I, L = F.ops.image, F.Types.Layered
|
||||
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/music.luau: write a MIDI file, read it back, render it to audio (docs/guide/music.md).
|
||||
local F = require("@rosetta")
|
||||
|
||||
-- 1. a Midi: 480 ticks per quarter note, absolute ticks, a tempo, a track name and a little melody
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/playlist.luau: read an M3U, inspect an HLS master playlist, convert to PLS and XSPF (docs/guide/playlist.md).
|
||||
local F = require("@rosetta")
|
||||
|
||||
local M3U = "#EXTM3U\n#PLAYLIST:Road Trip\n#EXTINF:215,Ada - First Song\nmusic/first.mp3\n"
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/scene.luau: build a 3D scene and a voxel grid, edit it, save as GLB, OBJ and STL (docs/guide/scene.md).
|
||||
local F = require("@rosetta")
|
||||
local S = F.Types.Scene
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/tilemap.luau: read a TMX map, walk a tile layer, find an object, edit, write TMJ (docs/guide/tilemap.md).
|
||||
local F = require("@rosetta")
|
||||
|
||||
local tmx = [[<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/vector.luau: parse an SVG, rasterize it, build a Vector and write it as SVG (docs/guide/vector.md).
|
||||
local F = require("@rosetta")
|
||||
|
||||
local svg = [[<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24">
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
-- 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).
|
||||
-- examples/video.luau: write frames as an MJPEG AVI, open it, walk packets and frames, seek, make a GIF (docs/guide/video.md).
|
||||
local F = require("@rosetta")
|
||||
local I = F.ops.image
|
||||
|
||||
|
||||
Reference in new issue
Block a user