Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
#32: an HTML page renders to PNGs, a folder (-o DIR, one frame-NNNNN.png a frame) or one still (-o OUT.png: frame 0, or the one --at names), and --alpha gives them a transparent canvas, as a TSX composition's do. The direct path wrote only video or hashes, so -o frames wrote an MP4 named frames, failed with "Is a directory" when the folder was there, and --alpha couldn't apply.
shinyobjectz3e1efbab77ba
diff --git a/apps/media/src/command.rs b/apps/media/src/command.rsindex 026be2e5..ca0009b9 100644--- a/apps/media/src/command.rs+++ b/apps/media/src/command.rs@@ -3,7 +3,7 @@//!//! media probe|still|sheet|audio|loudness|motion|cuts|freezes|proxy|trim|concat FILE ... media work, native (media help)//! ffmpeg ARGS | ffprobe ARGS ffmpeg and ffprobe command lines read as the media verbs (no ffmpeg involved)-//! render PAGE.html -o OUT.mp4|DIR [--at F,F] [--codec apple|soft|av1|ffmpeg] [--kbps K | --quality Q]+//! render PAGE.html -o OUT.mp4|OUT.png|DIR [--at F,F] [--alpha] [--codec apple|soft|av1|ffmpeg] [--kbps K | --quality Q]//! shots [--size WxH] [--root DIR] plain HTML pages' first frames as PNGs, over white: stdin lines `PAGE\tOUT.png`,//! one `ok OUT` or `err OUT: why` line each (bench/wpt's reftests)@@ -53,7 +53,10 @@ fn run(args: Vec<String>) {"render" => {let out = PathBuf::from(flag("-o").unwrap_or_else(|| fail("render needs -o OUT.mp4|DIR")));let frames = flag("--at").map(|at| at.split(',').map(|f| f.trim().parse().unwrap_or_else(|_| fail(format!("bad frame {f}")))).collect());- let opts = raea_runtime_encode::RenderOpts { frames, codec: flag("--codec"), kbps: flag("--kbps").and_then(|k| k.parse().ok()), quality: flag("--quality").map(|q| raea_io_media::parse_quality(&q).unwrap_or_else(|e| fail(e))), ssim: flag_on("--ssim"), sound: None, ten_bit: flag_on("--10bit") };+ let opts = raea_runtime_encode::RenderOpts { frames, codec: flag("--codec"), kbps: flag("--kbps").and_then(|k| k.parse().ok()), quality: flag("--quality").map(|q| raea_io_media::parse_quality(&q).unwrap_or_else(|e| fail(e))), ssim: flag_on("--ssim"), sound: None, ten_bit: flag_on("--10bit"), alpha: flag_on("--alpha") };+ if opts.alpha && out.extension().is_some_and(|x| x != "png") {+ fail("--alpha writes PNGs (OUT.png or a folder): video here is H.264 or HEVC, which hold no alpha");+ }raea_runtime_encode::render_file(&arg(1), &out, &opts).unwrap_or_else(|e| fail(e));if let Some(note) = raea_page::not_applied::said() {println!("{note}");diff --git a/bench/html-png/check.sh b/bench/html-png/check.shnew file mode 100755index 00000000..fb3d4116--- /dev/null+++ b/bench/html-png/check.sh@@ -0,0 +1,43 @@+#!/bin/bash+# #32: an HTML page renders to PNGs as a TSX composition does. index.html is a half-opaque red box sliding over a canvas+# with nothing else on it. Checked:+# -o DIR --at 0,29 two PNGs, frame-00000.png and frame-00029.png, the box moved between them+# -o DIR again into the folder that's there now (it was "Is a directory")+# -o OUT.png --at 29 one PNG, byte-identical to the folder's frame-00029.png+# -o OUT.png frame 0+# the pixels without --alpha the canvas is white and the box pink (255,128,128); with --alpha the canvas+# is clear (alpha 0) and the box straight red at half alpha (255,0,0,~128)+# --alpha -o OUT.mp4 refused+# Exits 1 on a failure.+# bench/html-png/check.sh (RAEA_BIN: the raea to run, default target/release/raea)+cd "$(dirname "$0")/../.." || exit 2+BIN=${RAEA_BIN:-$PWD/target/release/raea}+export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0+OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-html-png.XXXXXX")+trap 'rm -rf "$OUT"' EXIT+PAGE=bench/html-png/index.html+status=0+ok() { echo "PASS $1"; }+bad() { echo "FAIL $1"; status=1; }+px() { ffmpeg -v error -i "$1" -vf "crop=1:1:$2:$3" -f rawvideo -pix_fmt rgba - | od -An -tu1 | tr -s ' ' | sed 's/^ //; s/ *$//'; }+near() { # "R G B A" "R G B A": each within 3+ read -r a b c d <<<"$1"; read -r e f g h <<<"$2"+ for p in "$a $e" "$b $f" "$c $g" "$d $h"; do set -- $p; (( ${1:-999} - $2 <= 3 && $2 - ${1:-999} <= 3 )) || return 1; done+}+"$BIN" render $PAGE -o "$OUT/dir" --at 0,29 > "$OUT/log" 2>&1+n=$(ls "$OUT/dir" 2>/dev/null | grep -c '^frame-000\(00\|29\)\.png$')+[ "$n" = 2 ] && ok "-o DIR --at 0,29: two PNGs" || { bad "-o DIR: $n PNGs (want 2)"; cat "$OUT/log"; }+[ "$(px "$OUT/dir/frame-00000.png" 60 60)" != "$(px "$OUT/dir/frame-00029.png" 60 60)" ] && ok "the box moved between frames 0 and 29" || bad "frames 0 and 29 are the same at (60,60)"+"$BIN" render $PAGE -o "$OUT/dir" --at 29 > "$OUT/log" 2>&1 && ok "-o DIR into a folder that's there" || { bad "-o DIR into a folder that's there"; cat "$OUT/log"; }+"$BIN" render $PAGE -o "$OUT/one.png" --at 29 > "$OUT/log" 2>&1+cmp -s "$OUT/one.png" "$OUT/dir/frame-00029.png" && ok "-o OUT.png --at 29 is the folder's frame 29" || { bad "-o OUT.png --at 29 differs from the folder's frame 29"; cat "$OUT/log"; }+"$BIN" render $PAGE -o "$OUT/first.png" > "$OUT/log" 2>&1+cmp -s "$OUT/first.png" "$OUT/dir/frame-00000.png" && ok "-o OUT.png is frame 0" || { bad "-o OUT.png isn't frame 0"; cat "$OUT/log"; }+# frame 0: the box at x 40..140, y 40..140+canvas=$(px "$OUT/first.png" 5 5); box=$(px "$OUT/first.png" 90 90)+near "$canvas" "255 255 255 255" && near "$box" "255 128 128 255" && ok "opaque: white canvas ($canvas), pink box ($box)" || bad "opaque: canvas $canvas (want 255 255 255 255), box $box (want 255 128 128 255)"+"$BIN" render $PAGE -o "$OUT/alpha.png" --alpha > "$OUT/log" 2>&1+canvas=$(px "$OUT/alpha.png" 5 5); box=$(px "$OUT/alpha.png" 90 90)+[ "${canvas##* }" = 0 ] && near "$box" "255 0 0 128" && ok "--alpha: clear canvas ($canvas), straight red at half alpha ($box)" || { bad "--alpha: canvas $canvas (want alpha 0), box $box (want 255 0 0 128)"; cat "$OUT/log"; }+"$BIN" render $PAGE -o "$OUT/a.mp4" --alpha > "$OUT/log" 2>&1 && bad "--alpha to an MP4 wasn't refused" || ok "--alpha to an MP4 is refused"+exit $statusdiff --git a/bench/html-png/index.html b/bench/html-png/index.htmlnew file mode 100644index 00000000..6249227e--- /dev/null+++ b/bench/html-png/index.html@@ -0,0 +1,16 @@+<!doctype html>+<!-- #32: an HTML page to PNGs. Nothing on the canvas but a red box at half opacity sliding right over 30 frames.+ bench/html-png/check.sh -->+<html><head><meta charset="utf-8">+<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>+<style>html,body{margin:0;width:320px;height:180px}#box{position:absolute;left:40px;top:40px;width:100px;height:100px;background:#ff0000;opacity:.5}</style>+</head><body>+<div id="root" data-composition-id="main" data-start="0" data-width="320" data-height="180" data-duration="1">+<div id="box"></div>+</div>+<script>+window.__timelines=window.__timelines||{};+var tl=gsap.timeline({paused:true});+tl.to('#box',{x:120,duration:1,ease:'none'},0);+window.__timelines.main=tl;+</script></body></html>diff --git a/engine/cli/src/cli.rs b/engine/cli/src/cli.rsindex 125527a7..a1efce7b 100644--- a/engine/cli/src/cli.rs+++ b/engine/cli/src/cli.rs@@ -345,7 +345,7 @@ pub fn run(args: &[String]) -> R<String> {}if args.first().map(String::as_str) != Some("render") || args.len() < 2 {return Err(format!(- "raea render EDIT.tsx -o OUT.mp4|OUT.png|DIR [--frame N | --at A,B] [--composition ID] [--w W] [--h H] [--fps FPS] [--frames N] [--words W.json] [--perception P.json] [--input I.json|inputs.rrl] [--manifest render.json] [--stage WxH] [--10bit] [--aov] [--alpha] [--kbps N | --quality draft|high|master|0..1] [--clay] (also: --lite --comps)\n raea render EDIT.tsx --review DIR [--frame N] (fixed cameras hero, front, right, top, iso, low in colour and clay: DIR/colour.png, clay.png, review.json)\n raea render PAGE.html -o OUT.mp4|DIR [--at A,B] (an HTML composition)\n raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)+ "raea render EDIT.tsx -o OUT.mp4|OUT.png|DIR [--frame N | --at A,B] [--composition ID] [--w W] [--h H] [--fps FPS] [--frames N] [--words W.json] [--perception P.json] [--input I.json|inputs.rrl] [--manifest render.json] [--stage WxH] [--10bit] [--aov] [--alpha] [--kbps N | --quality draft|high|master|0..1] [--clay] (also: --lite --comps)\n raea render EDIT.tsx --review DIR [--frame N] (fixed cameras hero, front, right, top, iso, low in colour and clay: DIR/colour.png, clay.png, review.json)\n raea render PAGE.html -o OUT.mp4|OUT.png|DIR [--at A,B] [--alpha] (an HTML composition)\n raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)raea media probe|still|sheet|audio|loudness|motion|cuts|freezes|proxy|trim|concat FILE ... | ffmpeg ARGS | ffprobe ARGS (media work, native: media help)raea bundle EDIT.tsx --composition-bundle -o OUT.js [--portable DIR] (a composition for render_bundle, on the Mac or the iPhone)\n raea add PKG[@RANGE]... [--dev] | remove NAME... | install [--offline] [--in DIR] (npm packages for the project: raea.lock, node_modules)\n {} (foley, local)\n {} (an instrument's notes, local)\n raea setup-audio [--check] [sao|tokensynth] (install or check the local audio models)\n {} (the song's energy map: beats, sections, builds, drops, stops, hits, cuts per bar; also: --backend NAME)\n raea sounds [WORDS] | sounds get PACK/INSTRUMENT [--notes ..|--all] [-o DIR] (open sample libraries for a Sampler)\n {} (the clip's camera solved, for <Matchmove>)",tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGEdiff --git a/runtime/encode/src/html.rs b/runtime/encode/src/html.rsindex 82e0b6a7..374758f1 100644--- a/runtime/encode/src/html.rs+++ b/runtime/encode/src/html.rs@@ -82,6 +82,10 @@ pub fn lower(path: &Path) -> Result<Lowered, String> {pub fn render_file(edit: &str, out: &Path, opts: &crate::RenderOpts) -> Result<(), String> {let path = PathBuf::from(edit);let dir = crate::dir_of(edit);- let l = lower(&path)?;+ let mut l = lower(&path)?;+ // --alpha: the canvas clear, so the PNGs are transparent where the page draws nothing (#32)+ if opts.alpha {+ l.rows[0].vals.insert("bg".into(), V::S("#00000000".into()));+ }crate::render_with(&l.prog, &l.rows, &dir, out, opts, Some(l.page))}diff --git a/runtime/encode/src/lib.rs b/runtime/encode/src/lib.rsindex ba36e5d9..cbc32230 100644--- a/runtime/encode/src/lib.rs+++ b/runtime/encode/src/lib.rs@@ -36,6 +36,8 @@ pub struct RenderOpts {/// RGB exactly; 8-bit limited-range H.264 errs up to 2/255 by its own round trip. The direct and fed renders/// take it; RAEA_EXPORT_10BIT=1 asks for it too. 3D through the engine stays 8-bit.pub ten_bit: bool,+ /// PNGs kept transparent where the composition draws nothing: an HTML page's canvas clear instead of white (#32)+ pub alpha: bool,}impl RenderOpts {diff --git a/runtime/encode/src/render.rs b/runtime/encode/src/render.rsindex 879744cb..b5d8555a 100644--- a/runtime/encode/src/render.rs+++ b/runtime/encode/src/render.rs@@ -15,6 +15,20 @@ pub fn render(prog: &Program, rows: &[Tup], dir: &Path, out: &Path, ro: &RenderO/// textures). `prog` is the picture's program (its size, rate, length and background; no rows: the page is the/// picture), and `sound_of` the sound's, asked for once the last frame is made (the caller learns it from the frames):/// a track mixed and mastered already (the one mixer core's bounce, raea-mixer).+/// The composite is premultiplied; a PNG holds straight colour. Only a transparent clear (render --alpha) leaves alpha+/// under 255, so an opaque frame is written as it comes.+fn straight(mut px: Vec<u8>) -> Vec<u8> {+ for p in px.chunks_exact_mut(4) {+ let a = p[3] as u32;+ if a > 0 && a < 255 {+ for c in &mut p[..3] {+ *c = ((*c as u32 * 255 + a / 2) / a).min(255) as u8;+ }+ }+ }+ px+}+/// A direct render's frame `f`: to the encoder's queue, or with none (an .txt out) its NV12 hash to `lines`.fn direct_sink(tx: Option<&std::sync::mpsc::SyncSender<Vec<u8>>>, lines: &mut Vec<String>, f: i64, px: Vec<u8>) -> Result<(), String> {if let Some(tx) = tx {@@ -211,13 +225,24 @@ pub fn render_with(prog: &Program, rows: &[Tup], dir: &Path, out: &Path, ro: &Relet (w, h) = (v.w, v.h);let setup_s = t0.elapsed().as_secs_f64();let hashes = out.extension().is_some_and(|x| x == "txt");- let ten = ro.wants_10bit() && !hashes;- v.ten_bit = ten;+ // PNGs (#32): OUT.png is one frame (the first unless --at names it), a folder one PNG a frame, each read back+ // as the composite's RGBA+ let still = out.extension().is_some_and(|x| x == "png");+ let pngs = still || !out.extension().is_some_and(|x| matches!(x.to_str(), Some("mp4" | "mov" | "txt")));+ let list = if still && ro.frames.is_none() { vec![0] } else { list };+ if still && list.len() != 1 {+ return Err(format!("{} is one frame, and {} were asked for: --at one frame, or -o a folder for several", out.display(), list.len()));+ }+ if pngs && !still {+ std::fs::create_dir_all(out).map_err(|e| format!("{}: {e}", out.display()))?;+ }+ let ten = ro.wants_10bit() && !hashes && !pngs;+ (v.ten_bit, v.rgba) = (ten, pngs);let mut lines = Vec::new();// the encoder on its own thread (frames over a short queue), so encoding overlaps the next frameslet mut tx = None;let mut enc_thread = None;- if !hashes {+ if !hashes && !pngs {let mix = match &ro.sound { Some(a) => Some(a.clone()), None => sound_tl(&prog, &tl, &rows, dir)? };let codec = ro.codec.clone().unwrap_or_else(raea_sys_frame::media_backend);let opts = ro.encode_opts(w, h, prog.fps, true, engine::has_3d(&rows), ten);@@ -238,8 +263,12 @@ pub fn render_with(prog: &Program, rows: &[Tup], dir: &Path, out: &Path, ro: &Relet mut n = 0;let dt = v.render_nv12(&list, |f, px| {+ match pngs {+ true => save_png(&if still { out.to_path_buf() } else { out.join(format!("frame-{f:05}.png")) }, &straight(px), w, h)?,+ false => direct_sink(tx.as_ref(), &mut lines, f, px)?,+ }n += 1;- direct_sink(tx.as_ref(), &mut lines, f, px)+ Ok(())});let t = std::time::Instant::now();drop(tx);@@ -372,23 +401,7 @@ pub fn render_with(prog: &Program, rows: &[Tup], dir: &Path, out: &Path, ro: &Re} else {std::fs::create_dir_all(&out).map_err(|e| e.to_string())?;let nv12 = e.nv12;- // the composite is premultiplied; a PNG holds straight colour. Only a transparent clear (render --alpha) leaves- // alpha under 255, so an opaque frame is written as it comes- let rgba_of = |px: Vec<u8>| {- if nv12 {- return raea_io_media::yuv::nv12_to_rgba(&px, w as usize, h as usize);- }- let mut px = px;- for p in px.chunks_exact_mut(4) {- let a = p[3] as u32;- if a > 0 && a < 255 {- for c in &mut p[..3] {- *c = ((*c as u32 * 255 + a / 2) / a).min(255) as u8;- }- }- }- px- };+ let rgba_of = |px: Vec<u8>| if nv12 { raea_io_media::yuv::nv12_to_rgba(&px, w as usize, h as usize) } else { straight(px) };let mut n = 0;e.frames(&list, |f, px| {save_png(&out.join(format!("frame-{f:05}.png")), &rgba_of(px), w, h)?;diff --git a/runtime/view/src/cpuview.rs b/runtime/view/src/cpuview.rsindex 7e27ac4f..14ed4d81 100644--- a/runtime/view/src/cpuview.rs+++ b/runtime/view/src/cpuview.rs@@ -183,18 +183,7 @@ impl CpuView {let rows2d: Vec<serde_json::Value> = rows.iter().filter(|t| crate::rows::is_2d(&t.kind)).map(|t| crate::rows::row2d(t, rows).1).collect();let rw = crate::rows2d::Rows::new(&rows2d, w, h, prog.frames.max(1), dir)?;// the background: the camera's clear colour- let bg = rows.iter().find(|t| t.kind == "camera").and_then(|t| match t.vals.get("bg") {- Some(V::S(s)) => Some(s.clone()),- _ => None,- });- let rgb = bg- .and_then(|s| {- let hx = s.trim_start_matches('#').to_string();- let b = |i: usize| u8::from_str_radix(hx.get(i..i + 2)?, 16).ok();- Some([b(0)?, b(2)?, b(4)?])- })- .unwrap_or([13, 10, 26]);- let word = rgb[0] as u32 | (rgb[1] as u32) << 8 | (rgb[2] as u32) << 16 | 255 << 24;+ let word = u32::from_le_bytes(crate::camera_bg(&rows));let threads = std::env::var("RAEA_CPU_THREADS").ok().and_then(|t| t.parse().ok()).unwrap_or_else(|| std::thread::available_parallelism().map(|n| n.get()).unwrap_or(4));Ok(CpuView {diff --git a/runtime/view/src/gpuview.rs b/runtime/view/src/gpuview.rsindex 4865587d..7b0b07b0 100644--- a/runtime/view/src/gpuview.rs+++ b/runtime/view/src/gpuview.rs@@ -155,6 +155,8 @@ pub struct GpuView {/// the direct render hands P010 (p010buf.k: 10-bit BT.709 limited, w x h x 3 bytes) instead of NV12, for a/// 10-bit encoder (RenderOpts.ten_bit)pub ten_bit: bool,+ /// the direct render hands the composite as it is, RGBA8 premultiplied (w x h x 4), for PNGs from a page (#32)+ pub rgba: bool,/// RAEA_GPU_TIMES: timestamps around the direct render's GPU stages (8 per frame)ts: Option<wgpu::QuerySet>,/// uploads timed this frame (query pairs from 8)@@ -202,18 +204,8 @@ impl GpuView {let rows2d: Vec<serde_json::Value> = rows.iter().filter(|t| crate::rows::is_2d(&t.kind)).map(|t| crate::rows::row2d(t, rows).1).collect();let rw = crate::rows2d::Rows::new(&rows2d, w, h, prog.frames.max(1), dir)?;// the background: the camera's clear colour (the engine's camera clears to it)- let bg = rows.iter().find(|t| t.kind == "camera").and_then(|t| match t.vals.get("bg") {- Some(V::S(s)) => Some(s.clone()),- _ => None,- });- let rgb = bg- .and_then(|s| {- let h = s.trim_start_matches('#').to_string();- let b = |i: usize| u8::from_str_radix(h.get(i..i + 2)?, 16).ok();- Some([b(0)?, b(2)?, b(4)?])- })- .unwrap_or([13, 10, 26]);- let texels: Vec<u8> = (0..(w * (h + 1)) as usize).flat_map(|_| [rgb[0], rgb[1], rgb[2], 255]).collect();+ let bg = crate::camera_bg(&rows);+ let texels: Vec<u8> = (0..(w * (h + 1)) as usize).flat_map(|_| bg).collect();let tex = gpu.device.create_texture(&wgpu::TextureDescriptor {label: None,size: wgpu::Extent3d { width: w, height: h + 1, depth_or_array_layers: 1 },@@ -262,6 +254,7 @@ impl GpuView {no_mask,nv12: None,ten_bit: false,+ rgba: false,ts: None,ts_uploads: 0,upload_cpu_ms: 0.0,diff --git a/runtime/view/src/gpuview/render.rs b/runtime/view/src/gpuview/render.rsindex 7f7fdf27..cce1edd4 100644--- a/runtime/view/src/gpuview/render.rs+++ b/runtime/view/src/gpuview/render.rs@@ -1,4 +1,5 @@-//! The direct render: frames in order made NV12 on the device and read back three in flight, from rows or fed in.+//! The direct render: frames in order made NV12 (or P010, or kept RGBA) on the device and read back three in flight,+//! from rows or fed in.use super::*;@@ -24,13 +25,16 @@ impl GpuView {use std::sync::Arc;const RING: usize = 3;let (w, h) = (self.w, self.h);- // P010: two bytes a sample (a luma word holds two samples, a chroma word one Cb Cr pair)- let (words, bytes) = if self.ten_bit {+ // RGBA: the composite itself (`rgba`); P010: two bytes a sample (a luma word holds two samples, a chroma word one+ // Cb Cr pair)+ let (words, bytes) = if self.rgba {+ ((w * h) as usize, (w * h * 4) as usize)+ } else if self.ten_bit {((w * h / 2 + w * h / 4 + 1) as usize, (w * h * 3) as usize)} else {((w * h / 4 + w * h / 8 + 1) as usize, (w * h * 3 / 2) as usize)};- if self.nv12.is_none() {+ if self.nv12.is_none() && !self.rgba {let k = raea_core_k::parse(if self.ten_bit { P010BUF_K } else { NV12BUF_K })?;let sc: HashMap<&str, i32> = [("w", w as i32), ("h", h as i32), ("T_w", w as i32)].into();let c = self.gpu.compile_tex(&k, &["F"], &["T"], &sc, &["px"])?;@@ -105,14 +109,19 @@ impl GpuView {dt.decode_upload += ft.decode_upload;dt.uploads += ft.uploads;let t = Instant::now();- let (c, nb) = self.nv12.as_ref().unwrap();- self.gpu.dispatch_ts(c, &[&self.out], &[&self.bg_view], &[nb], words, false, self.ts.as_ref().map(|q| (q, 4)));+ let src = match self.nv12.as_ref().filter(|_| !self.rgba) {+ Some((c, nb)) => {+ self.gpu.dispatch_ts(c, &[&self.out], &[&self.bg_view], &[nb], words, false, self.ts.as_ref().map(|q| (q, 4)));+ nb+ }+ None => &self.out,+ };let slot = n % RING;let mut enc = self.gpu.device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("raea-render frame") });if let Some(q) = self.ts.as_ref() {enc.write_timestamp(q, 6);}- enc.copy_buffer_to_buffer(nb, 0, &ring[slot], 0, (words * 4) as u64);+ enc.copy_buffer_to_buffer(src, 0, &ring[slot], 0, (words * 4) as u64);if let Some(q) = self.ts.as_ref() {enc.write_timestamp(q, 7);enc.resolve_query_set(q, 0..16, &resolve, 0);diff --git a/runtime/view/src/lib.rs b/runtime/view/src/lib.rsindex b32b1bf4..d5618d4a 100644--- a/runtime/view/src/lib.rs+++ b/runtime/view/src/lib.rs@@ -10,3 +10,17 @@ pub mod gpuview;pub mod masks;pub mod rows;pub mod rows2d;++/// The camera's clear colour (its `bg`, #rrggbb or #rrggbbaa) as a premultiplied RGBA texel; raea's dark blue when it+/// has none. An alpha under ff (an HTML page's canvas under --alpha, #00000000) stays: it was read as opaque, so the+/// clear canvas came out black (#32).+pub(crate) fn camera_bg(rows: &[raea_core_program::eval::Tup]) -> [u8; 4] {+ let hex = rows.iter().find(|t| t.kind == "camera").and_then(|t| match t.vals.get("bg") {+ Some(raea_core_program::ir::V::S(s)) => Some(s.trim_start_matches('#').to_string()),+ _ => None,+ });+ let b = |h: &str, i: usize| u8::from_str_radix(h.get(i..i + 2)?, 16).ok();+ let Some((rgb, a)) = hex.and_then(|h| Some(([b(&h, 0)?, b(&h, 2)?, b(&h, 4)?], if h.len() == 8 { b(&h, 6)? } else { 255 }))) else { return [13, 10, 26, 255] };+ let pre = |c: u8| ((c as u32 * a as u32 + 127) / 255) as u8;+ [pre(rgb[0]), pre(rgb[1]), pre(rgb[2]), a]+}diff --git a/sdk/skills/raea/reference/cli.md b/sdk/skills/raea/reference/cli.mdindex 0227d6c1..551a2de4 100644--- a/sdk/skills/raea/reference/cli.md+++ b/sdk/skills/raea/reference/cli.md@@ -12,7 +12,7 @@ Access: HEADLESS. Arguments besides flags: 1.```raea render EDIT.tsx -o OUT.mp4|OUT.png|DIR [--frame N | --at A,B] [--composition ID] [--w W] [--h H] [--fps FPS] [--frames N] [--words W.json] [--perception P.json] [--input I.json|inputs.rrl] [--manifest render.json] [--stage WxH] [--10bit] [--aov] [--alpha] [--kbps N | --quality draft|high|master|0..1] (also: --lite --comps)-raea render PAGE.html -o OUT.mp4|DIR [--at A,B] (an HTML composition)+raea render PAGE.html -o OUT.mp4|OUT.png|DIR [--at A,B] [--alpha] (an HTML composition)raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)```