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
FC0a: ui/text/text_debug passes (SSIM 0.984): a TextSpan of size 0 or less is left out, as bevy_text's TextPipeline leaves it, and its Text's other runs laid out without it. The port works out the example's frame-rate figures over the host's 1/60 s steps from a first update at elapsed 0 (66.0 avg fps, 2852.5 deviation at frame 10, as Bevy draws them); a first update one step later fails
shinyobjectz99428724de6c
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.listindex e907fd3b..1dcd7f46 100644--- a/bench/bevy-parity/examples.list+++ b/bench/bevy-parity/examples.list@@ -81,3 +81,4 @@ ui/layout/anchor_layoutui/layout/size_constraintsui/scroll_and_overflow/overflow_transformui/text/text+ui/text/text_debugdiff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsvindex edf31a3c..c477f248 100644--- a/bench/bevy-parity/runs.tsv+++ b/bench/bevy-parity/runs.tsv@@ -80,3 +80,4 @@ ui/layout/anchor_layout - 10ui/layout/size_constraints - 10ui/scroll_and_overflow/overflow_transform - 10ui/text/text - 10+ui/text/text_debug - 10diff --git a/docs/bevy-parity.md b/docs/bevy-parity.mdindex 82946500..f7502ac3 100644--- a/docs/bevy-parity.md+++ b/docs/bevy-parity.md@@ -4,7 +4,7 @@ Bevy v0.20.0's examples against their raea TSX ports (docs/control.feature FC0a)don't edit. An example passes when every probed frame passes pixels (SSIM 0.98 and no 32 px tile off by more than 24 of 255) and cost (batch keys andframe time at most 1.25x the example's). Wall time is one machine's, measured in the same run.-Examples: **438**, ported **81**, passing **77**, excluded **16** (docs/bevy-parity/excluded.tsv), left **345**.+Examples: **438**, ported **82**, passing **78**, excluded **16** (docs/bevy-parity/excluded.tsv), left **344**.raea's frame ms is its update's plus the time React takes to step a frame for its 3D (step), which the exampledoesn't pay.@@ -137,6 +137,7 @@ doesn't pay.| ui/layout/size_constraints | 10 | 0.991466 | 19 | 0 / 0 | 608 / 492 | 5 / 7 | 1 / 1 | 31.358 / 0.993 = 0.993 + 0 | yes | || ui/scroll_and_overflow/overflow_transform | 10 | 0.995397 | 12 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 41.134 / 1.724 = 1.724 + 0 | yes | || ui/text/text | 10 | 0.990913 | 8 | 0 / 0 | 459 / 492 | 5 / 7 | 1 / 1 | 34.947 / 1.446 = 1.446 + 0 | yes | |+| ui/text/text_debug | 10 | 0.984022 | 18 | 0 / 0 | 458 / 492 | 5 / 7 | 1 / 1 | 35.188 / 1.093 = 1.093 + 0 | yes | |## Excludeddiff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonlindex 3a3a8024..32f5b6c9 100644--- a/docs/bevy-parity/results.jsonl+++ b/docs/bevy-parity/results.jsonl@@ -124,3 +124,4 @@{"example":"ui/layout/size_constraints","frame":10,"ssim":0.991466,"tile":19,"bevy":{"batch_keys":0,"entities":608,"extents":[],"frame":10,"frame_ms":31.358,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.993,"step_ms":null,"cost_ms":0.993},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}{"example":"ui/scroll_and_overflow/overflow_transform","frame":10,"ssim":0.995397,"tile":12,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":41.134,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.724,"step_ms":null,"cost_ms":1.724},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}{"example":"ui/text/text","frame":10,"ssim":0.990913,"tile":8,"bevy":{"batch_keys":0,"entities":459,"extents":[],"frame":10,"frame_ms":34.947,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.446,"step_ms":null,"cost_ms":1.446},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}+{"example":"ui/text/text_debug","frame":10,"ssim":0.984022,"tile":18,"bevy":{"batch_keys":0,"entities":458,"extents":[],"frame":10,"frame_ms":35.188,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.093,"step_ms":null,"cost_ms":1.093},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}diff --git a/sdk/raea/bench/bevy-parity/ui/text/text_debug.tsx b/sdk/raea/bench/bevy-parity/ui/text/text_debug.tsxnew file mode 100644index 00000000..ed4ae80b--- /dev/null+++ b/sdk/raea/bench/bevy-parity/ui/text/text_debug.tsx@@ -0,0 +1,75 @@+// Bevy v0.20.0 examples/ui/text/text_debug.rs in raea's TSX: two columns spread across the window (each growing, 15 x 5+// px margins, children spaced between), every text in FiraSans-Bold on maroon. Left, at the start: four lines broken by+// hand; a right-justified yellow paragraph at most 300 px wide; and a 300 px block of hand and wrapped breaks. Right, at+// the end: a centred pink 33 px paragraph at most 400 px wide; left-justified yellow and fully justified green-yellow+// 29 px paragraphs; and a 21 px Text whose string and spans change every frame to the frame rate (its own average over+// the frames so far, that average's deviation, and the FrameTimeDiagnosticsPlugin rate and frame time), with a+// zero-size and a negative-size span bevy_text leaves out. The parity host steps Bevy by 1/60 s, so each figure is+// worked out here as the example works it out. Bevy's Camera2d over the default clear colour is the layered+// <Canvas3D>. In Bevy's default 1280 x 720 window.+import { AbsoluteFill, Composition, registerRoot, staticFile, useCurrentFrame } from "raea";+import { Canvas3D } from "raea/3d";+import { Node, Text, TextSpan, UiRect, percent, px } from "raea/ui";+import { Srgba } from "raea/color";++const FONT = staticFile("fonts/FiraSans-Bold.ttf");+const css = (r: number, g: number, b: number) => new Srgba(r / 255, g / 255, b / 255);+const [MAROON, YELLOW, GREEN_YELLOW, RED, ORANGE_RED, LIME, BLUE] = [css(128, 0, 0), css(255, 255, 0), css(173, 255, 47), css(255, 0, 0), css(255, 69, 0), css(0, 255, 0), css(0, 0, 255)];+const STEP_NS = 16_666_667;+// the first update's Time::elapsed, in steps+const FIRST = 0;++// change_text_system's figures after the updates up to frame f: the average rate over its elapsed-time history and+// that average's (population) deviation over the frames, and the diagnostics' smoothed rate and frame time (in ms)+function figures(f: number) {+ const times: number[] = [];+ const fps: number[] = [];+ for (let k = FIRST; k <= f; k++) {+ times.unshift(k * STEP_NS);+ times.length = Math.min(times.length, 120);+ const span = (times[0] - times[times.length - 1]) / 1e9;+ fps.unshift(times.length / Math.max(span, 0.0001));+ fps.length = Math.min(fps.length, 120);+ }+ const mean = fps.reduce((a, b) => a + b, 0) / fps.length;+ const dev = Math.sqrt(fps.reduce((a, b) => a + (mean - b) * (mean - b), 0) / fps.length);+ return { avg: fps[0], dev, rate: 1e9 / STEP_NS, ms: STEP_NS / 1e6 };+}++function Paragraph({ children, ...p }: { children: string } & Parameters<typeof Text>[0]) {+ return <Text font={FONT} background_color={MAROON} {...p}>{children}</Text>;+}++function Shot() {+ const { avg, dev, rate, ms } = figures(useCurrentFrame());+ return (+ <AbsoluteFill>+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />+ <Node width={percent(100)} height={percent(100)} justify_content="SpaceBetween">+ <Node flex_direction="Column" justify_content="SpaceBetween" align_items="Start" flex_grow={1} margin={UiRect.axes(px(15), px(5))}>+ <Paragraph font_size={{ Px: 25 }}>{"This is\ntext with\nline breaks\nin the top left."}</Paragraph>+ <Paragraph font_size={{ Px: 25 }} color={YELLOW} justify="Right" max_width={px(300)}>This text is right-justified. The `Justify` component controls the horizontal alignment of the lines of multi-line text relative to each other, and does not affect the text node's position in the UI layout.</Paragraph>+ <Paragraph font_size={{ Px: 25 }} max_width={px(300)}>{"This\ntext has\nline breaks and also a set width in the bottom left."}</Paragraph>+ </Node>+ <Node flex_direction="Column" justify_content="SpaceBetween" align_items="End" flex_grow={1} margin={UiRect.axes(px(15), px(5))}>+ <Paragraph font_size={{ Px: 33 }} color={new Srgba(0.8, 0.2, 0.7)} justify="Center" max_width={px(400)}>This text is very long, has a limited width, is center-justified, is positioned in the top right and is also colored pink.</Paragraph>+ <Paragraph font_size={{ Px: 29 }} color={YELLOW} justify="Left" max_width={px(300)}>This text is left-justified and is vertically positioned to distribute the empty space equally above and below it.</Paragraph>+ <Paragraph font_size={{ Px: 29 }} color={GREEN_YELLOW} justify="Justified" max_width={px(300)}>This text is fully justified and is positioned in the same way.</Paragraph>+ <Text font={FONT} font_size={{ Px: 21 }} background_color={MAROON}>+ {`${avg.toFixed(1)} avg fps, ${dev.toFixed(1)} frametime variance`}+ <TextSpan font={FONT} font_size={{ Px: 21 }}>{`\nThis text changes in the bottom right - ${rate.toFixed(1)} fps, ${ms.toFixed(3)} ms/frame`}</TextSpan>+ <TextSpan font={FONT} font_size={{ Px: 0 }} color={BLUE}> this text has zero font size</TextSpan>+ <TextSpan font={FONT} font_size={{ Px: 21 }} color={RED}>{"\nThis text changes in the bottom right - "}</TextSpan>+ <TextSpan font={FONT} font_size={{ Px: 21 }} color={ORANGE_RED}>{rate.toFixed(1)}</TextSpan>+ <TextSpan font={FONT} font_size={{ Px: 10 }} color={YELLOW}> fps, </TextSpan>+ <TextSpan font={FONT} font_size={{ Px: 21 }} color={LIME}>{ms.toFixed(3)}</TextSpan>+ <TextSpan font={FONT} font_size={{ Px: 42 }} color={BLUE}> ms/frame</TextSpan>+ <TextSpan font={FONT} font_size={{ Px: -42 }} color={BLUE}> this text has negative font size</TextSpan>+ </Text>+ </Node>+ </Node>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={1280} height={720} />);diff --git a/sdk/raea/conformance/ui.test.tsx b/sdk/raea/conformance/ui.test.tsxindex 9e92662e..9914f4aa 100644--- a/sdk/raea/conformance/ui.test.tsx+++ b/sdk/raea/conformance/ui.test.tsx@@ -129,6 +129,13 @@ describe("ImageNode, Underline and Strikethrough", () => {expect(() => html(<Text font_features={{ sc: 1 }}>a</Text>)).toThrow(/four characters/);expect(() => html(<Text font_features={{ smcp: 0.5 }}>a</Text>)).toThrow(/whole number/);});+ test("a TextSpan of size 0 or less is left out, as bevy_text leaves it, and its Text's other runs drawn", () => {+ const out = html(<Text>a<TextSpan font_size={{ Px: 0 }}>zero</TextSpan><TextSpan font_size={-42}>negative</TextSpan><TextSpan>b</TextSpan></Text>);+ expect(out).not.toContain("zero");+ expect(out).not.toContain("negative");+ expect(out).toMatch(/>b<\/span>/);+ expect(() => html(<Text><TextSpan font_size={NaN}>x</TextSpan></Text>)).toThrow(/font_size/);+ });test("a TextSpan's TextBackgroundColor is a box behind its run, in its own colour", () => {expect(html(<Text><TextSpan text_background_color={new Srgba(1, 0, 0)}>a</TextSpan></Text>)).toMatch(/<span style="[^"]*background-color:rgba\(255, 0, 0, 1\)[^"]*">a<\/span>/);expect(html(<Text><TextSpan>a</TextSpan></Text>)).not.toContain("background-color");diff --git a/sdk/render/src/bevy3d/ui.tsx b/sdk/render/src/bevy3d/ui.tsxindex 8a453562..2cbb834d 100644--- a/sdk/render/src/bevy3d/ui.tsx+++ b/sdk/render/src/bevy3d/ui.tsx@@ -367,6 +367,10 @@ export function Text({ children, font, font_size, weight, style, color, line_hei/** A run of a <Text> in a style of its own (Bevy's defaults, not its Text's, where left out). @bevy bevy_text::text::TextSpan */export function TextSpan({ children, underline, strikethrough, underline_color, strikethrough_color, text_background_color, ...p }: TextStyleProps & TextRunProps & { children?: ReactNode }) {const back = useContext(InUi)?.back;+ // bevy_text leaves out a span whose size is 0 or less (TextPipeline: "Nothing will be displayed"), its Text's other+ // runs laid out without it+ const size = typeof p.font_size === "number" ? p.font_size : p.font_size && Object.values(p.font_size)[0];+ if (typeof size === "number" && Number.isFinite(size) && size <= 0) return null;const t = textCss("TextSpan", p, back);const run = { underline, strikethrough, underline_color, strikethrough_color, text_background_color };return (diff --git a/sdk/skills/raea/reference/sdk.md b/sdk/skills/raea/reference/sdk.mdindex cc41fbba..c8f6633b 100644--- a/sdk/skills/raea/reference/sdk.md+++ b/sdk/skills/raea/reference/sdk.md@@ -99,7 +99,7 @@ with a capital, hooks with `use`. A component's props are in its file.## `raea/ui` (sdk/raea/src/ui.ts)-`AbsoluteFill`, `AngularColorStop`, `BorderRadius`, `BoxShadow`, `ColorStop`, `ConicGradient`, `CornerRadius`, `FontSource`, `FontVariationTag`, `GhostNode`, `GridPlacement`, `GridTrack`, `ImageNode`, `ImagePlugin`, `InlineImage`, `LinearGradient`, `Node`, `Overflow`, `OverflowClipMargin`, `RadialGradient`, `RepeatedGridTrack`, `Rot2`, `Text`, `Text2d`, `TextShadow`, `TextSpan`, `TextureAtlasLayout`, `UiPosition`, `UiRect`, `UiScale`, `UiTargetCamera`, `UiTransform`, `Val2`, `Viewport`, `auto`, `percent`, `px`, `vh`, `vmax`, `vmin`, `vw`+`AbsoluteFill`, `AngularColorStop`, `BorderRadius`, `BoxShadow`, `ColorStop`, `ConicGradient`, `CornerRadius`, `FontFeatureTag`, `FontSource`, `FontVariationTag`, `GhostNode`, `GridPlacement`, `GridTrack`, `ImageNode`, `ImagePlugin`, `InlineImage`, `LinearGradient`, `Node`, `Overflow`, `OverflowClipMargin`, `RadialGradient`, `RepeatedGridTrack`, `Rot2`, `Text`, `Text2d`, `TextShadow`, `TextSpan`, `TextureAtlasLayout`, `UiPosition`, `UiRect`, `UiScale`, `UiTargetCamera`, `UiTransform`, `Val2`, `Viewport`, `auto`, `percent`, `px`, `vh`, `vmax`, `vmin`, `vw`## `raea/video` (sdk/raea/src/video.ts)