Skip to content

armgit / raea

Public Imported from GitHub
0

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.

FC0a: ui/layout/size_constraints passes (SSIM 0.9915): its radio buttons are bevy_ui_widgets' headless RadioButton, so they're their Nodes

shinyobjectz1acea1b83ef2
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index 2b7e2cec..aee6c9e7 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -78,3 +78,4 @@ ui/text/text_wrap_debug
ui/layout/grid
ui/ui_scaling
ui/layout/anchor_layout
+ui/layout/size_constraints
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index 77f97649..78cf4950 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -77,3 +77,4 @@ ui/text/text_wrap_debug - 10
ui/layout/grid - 10
ui/ui_scaling - 10
ui/layout/anchor_layout - 10
+ui/layout/size_constraints - 10
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index 7724c369..c3df4671 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 and
frame time at most 1.25x the example's). Wall time is one machine's, measured in the same run.
-Examples: **438**, ported **78**, passing **74**, excluded **16** (docs/bevy-parity/excluded.tsv), left **348**.
+Examples: **438**, ported **79**, passing **75**, excluded **16** (docs/bevy-parity/excluded.tsv), left **347**.
raea's frame ms is its update's plus the time React takes to step a frame for its 3D (step), which the example
doesn't pay.
@@ -134,6 +134,7 @@ doesn't pay.
| ui/layout/grid | 10 | 0.995059 | 14 | 0 / 0 | 482 / 492 | 5 / 7 | 1 / 1 | 34.457 / 1.496 = 1.496 + 0 | yes | |
| ui/ui_scaling | 10 | 0.999856 | 5 | 0 / 0 | 446 / 492 | 5 / 7 | 1 / 1 | 37.383 / 2.14 = 2.14 + 0 | yes | |
| ui/layout/anchor_layout | 10 | 0.997421 | 9 | 0 / 0 | 468 / 492 | 5 / 7 | 1 / 1 | 33.145 / 1.417 = 1.417 + 0 | yes | |
+| ui/layout/size_constraints | 10 | 0.991466 | 19 | 0 / 0 | 608 / 492 | 5 / 7 | 1 / 1 | 31.358 / 0.993 = 0.993 + 0 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index b342a140..41c51906 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -121,3 +121,4 @@
{"example":"ui/layout/grid","frame":10,"ssim":0.995059,"tile":14,"bevy":{"batch_keys":0,"entities":482,"extents":[],"frame":10,"frame_ms":34.457,"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.496,"step_ms":null,"cost_ms":1.496},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/ui_scaling","frame":10,"ssim":0.999856,"tile":5,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":37.383,"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":2.14,"step_ms":null,"cost_ms":2.14},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/layout/anchor_layout","frame":10,"ssim":0.997421,"tile":9,"bevy":{"batch_keys":0,"entities":468,"extents":[],"frame":10,"frame_ms":33.145,"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.417,"step_ms":null,"cost_ms":1.417},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"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":""}
diff --git a/sdk/raea/bench/bevy-parity/ui/layout/size_constraints.tsx b/sdk/raea/bench/bevy-parity/ui/layout/size_constraints.tsx
new file mode 100644
index 00000000..45f06f4f
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/ui/layout/size_constraints.tsx
@@ -0,0 +1,67 @@
+// Bevy v0.20.0 examples/ui/layout/size_constraints.rs in raea's TSX: on black, centred, a column of "Size Constraints
+// Example" (33 px FiraSans-Bold, 0.9 grey), a yellow bar (padding 10) round a black 100 px track (padding 4) holding the
+// white Bar node, and a yellow panel (padding 10, 50 px down) of four black radio groups (min_size, flex_basis, size,
+// max_size): a 200 px label, then buttons Auto (checked: antique-white border, white inside, black text) and 0% to
+// 125% (black border, navy inside, half-grey text), each 100 px wide in a 2 px border. The radio buttons are headless
+// (bevy_ui_widgets' RadioButton draws nothing), so they are their Nodes. 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 } from "raea";
+import { Canvas3D } from "raea/3d";
+import { Node, Text, UiRect, percent, px } from "raea/ui";
+import { Srgba } from "raea/color";
+
+const FONT = staticFile("fonts/FiraSans-Bold.ttf");
+const SIZE = { Px: 33 };
+const [BLACK, WHITE, YELLOW] = [new Srgba(0, 0, 0), new Srgba(1, 1, 1), new Srgba(1, 1, 0)];
+const ANTIQUE_WHITE = new Srgba(250 / 255, 235 / 255, 215 / 255);
+const NAVY = new Srgba(0, 0, 128 / 255);
+const GREY = new Srgba(0.5, 0.5, 0.5);
+const VALUES = ["Auto", "0%", "25%", "50%", "75%", "100%", "125%"];
+
+function Radio({ label, active }: { label: string; active: boolean }) {
+ return (
+ <Node align_items="Center" justify_content="Center" border={UiRect.all(px(2))} margin={UiRect.horizontal(px(2))} border_color={active ? ANTIQUE_WHITE : BLACK}>
+ <Node width={px(100)} justify_content="Center" background_color={active ? WHITE : NAVY}>
+ <Text font={FONT} font_size={SIZE} color={active ? BLACK : GREY} justify="Center">{label}</Text>
+ </Node>
+ </Node>
+ );
+}
+
+function Group({ label }: { label: string }) {
+ return (
+ <Node flex_direction="Column" padding={UiRect.all(px(2))} align_items="Stretch" background_color={BLACK}>
+ <Node flex_direction="Row" justify_content="End" padding={UiRect.all(px(2))}>
+ <Node min_width={px(200)} max_width={px(200)} justify_content="Center" align_items="Center">
+ <Text font={FONT} font_size={SIZE} color={new Srgba(0.9, 0.9, 0.9)}>{label}</Text>
+ </Node>
+ <Node>
+ {VALUES.map((v, i) => <Radio key={v} label={v} active={i === 0} />)}
+ </Node>
+ </Node>
+ </Node>
+ );
+}
+
+function Shot() {
+ return (
+ <AbsoluteFill>
+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />
+ <Node width={percent(100)} height={percent(100)} justify_content="Center" align_items="Center" background_color={BLACK}>
+ <Node flex_direction="Column" align_items="Center" justify_content="Center">
+ <Text font={FONT} font_size={SIZE} color={new Srgba(0.9, 0.9, 0.9)} margin={UiRect.bottom(px(25))}>Size Constraints Example</Text>
+ <Node flex_basis={percent(100)} align_self="Stretch" padding={UiRect.all(px(10))} background_color={YELLOW}>
+ <Node align_items="Stretch" width={percent(100)} height={px(100)} padding={UiRect.all(px(4))} background_color={BLACK}>
+ <Node background_color={WHITE} />
+ </Node>
+ </Node>
+ <Node flex_direction="Column" align_items="Stretch" padding={UiRect.all(px(10))} margin={UiRect.top(px(50))} background_color={YELLOW}>
+ {["min_size", "flex_basis", "size", "max_size"].map((l) => <Group key={l} label={l} />)}
+ </Node>
+ </Node>
+ </Node>
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={1280} height={720} />);