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/ui_transform passes (SSIM 0.9991): buttons turned by UiTransform about their centres (a Left turned the other way or an unturned Bottom fails)

shinyobjectz9f91e35a8fdd
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index 1dcd7f46..1252717c 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -82,3 +82,4 @@ ui/layout/size_constraints
ui/scroll_and_overflow/overflow_transform
ui/text/text
ui/text/text_debug
+ui/ui_transform
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index c477f248..7984d09e 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -81,3 +81,4 @@ ui/layout/size_constraints - 10
ui/scroll_and_overflow/overflow_transform - 10
ui/text/text - 10
ui/text/text_debug - 10
+ui/ui_transform - 10
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index f7502ac3..c16031c4 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 **82**, passing **78**, excluded **16** (docs/bevy-parity/excluded.tsv), left **344**.
+Examples: **438**, ported **83**, passing **79**, excluded **16** (docs/bevy-parity/excluded.tsv), left **343**.
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.
@@ -138,6 +138,7 @@ doesn't pay.
| 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 | |
+| ui/ui_transform | 10 | 0.999095 | 6 | 0 / 0 | 463 / 492 | 5 / 7 | 1 / 1 | 36.534 / 1.372 = 1.372 + 0 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index 32f5b6c9..682ae4f0 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -125,3 +125,4 @@
{"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":""}
+{"example":"ui/ui_transform","frame":10,"ssim":0.999095,"tile":6,"bevy":{"batch_keys":0,"entities":463,"extents":[],"frame":10,"frame_ms":36.534,"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.372,"step_ms":null,"cost_ms":1.372},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
diff --git a/sdk/raea/bench/bevy-parity/ui/ui_transform.tsx b/sdk/raea/bench/bevy-parity/ui/ui_transform.tsx
new file mode 100644
index 00000000..b3c2b191
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/ui/ui_transform.tsx
@@ -0,0 +1,54 @@
+// Bevy v0.20.0 examples/ui/ui_transform.rs in raea's TSX: on black, centred, a row (25 px gaps, spaced evenly) of a
+// column of two 50 px white buttons ("<--" and "-", GlobalZIndex 1), a 300 px dark-grey target holding four 80 px
+// white buttons round branding/icon.png (Top; Left turned a quarter anticlockwise; Right a quarter clockwise; Bottom
+// half a turn), and a column of "-->" and "+". The buttons turn and scale the target only when pressed, and the arrow
+// keys move it, so it holds as set up. 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 { ImageNode, Node, Rot2, Text, UiRect, UiTransform, percent, px } from "raea/ui";
+import { Srgba } from "raea/color";
+
+const [BLACK, WHITE] = [new Srgba(0, 0, 0), new Srgba(1, 1, 1)];
+
+function Button({ size, label, turn }: { size: number; label: string; turn?: number }) {
+ return (
+ <Node width={px(size)} height={px(size)} align_items="Center" justify_content="Center" background_color={WHITE} ui_transform={turn === undefined ? undefined : UiTransform.from_rotation(Rot2.radians(turn))}>
+ <Text color={BLACK}>{label}</Text>
+ </Node>
+ );
+}
+
+function Controls({ labels }: { labels: [string, string] }) {
+ return (
+ <Node flex_direction="Column" justify_content="Center" row_gap={px(10)} column_gap={px(10)} padding={UiRect.all(px(10))} background_color={BLACK} global_z_index={1}>
+ <Button size={50} label={labels[0]} />
+ <Button size={50} label={labels[1]} />
+ </Node>
+ );
+}
+
+function Shot() {
+ return (
+ <AbsoluteFill>
+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />
+ <Node width={percent(100)} height={percent(100)} align_items="Center" justify_content="Center" background_color={BLACK}>
+ <Node align_items="Center" justify_content="SpaceEvenly" column_gap={px(25)} row_gap={px(25)} background_color={BLACK}>
+ <Controls labels={["<--", "-"]} />
+ <Node flex_direction="Column" justify_content="SpaceBetween" align_items="Center" width={px(300)} height={px(300)} background_color={new Srgba(169 / 255, 169 / 255, 169 / 255)}>
+ <Button size={80} label="Top" />
+ <Node align_self="Stretch" justify_content="SpaceBetween" align_items="Center">
+ <Button size={80} label="Left" turn={Math.fround(-Math.PI / 2)} />
+ <ImageNode image={staticFile("branding/icon.png")} width={px(100)} height={px(100)} />
+ <Button size={80} label="Right" turn={Math.fround(Math.PI / 2)} />
+ </Node>
+ <Button size={80} label="Bottom" turn={Math.fround(Math.PI)} />
+ </Node>
+ <Controls labels={["-->", "+"]} />
+ </Node>
+ </Node>
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={1280} height={720} />);