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_drag_and_drop ports at 0.9990. A bevy_ui Outline's colour goes as written, for the page to blend in linear light, instead of mixed into the parent's background: it lies outside the node and over its siblings, so a Color::NONE outline drew 2 px grey seams over every tile. 87 of 91 ported examples pass

shinyobjectz1a23d1f9bbc1
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index 3dbc84ab..f642574f 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -90,3 +90,4 @@ ui/scroll_and_overflow/overflow_debug
ui/text/font_query
ui/images/image_node_resizing
ui/render_ui_to_texture
+ui/ui_drag_and_drop
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index 377f1489..7089bc24 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -89,3 +89,4 @@ ui/scroll_and_overflow/overflow_debug - 10
ui/text/font_query - 10
ui/images/image_node_resizing - 10
ui/render_ui_to_texture - 10
+ui/ui_drag_and_drop - 10
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index 06b57f9a..00d0bfd9 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 **90**, passing **86**, excluded **16** (docs/bevy-parity/excluded.tsv), left **336**.
+Examples: **438**, ported **91**, passing **87**, excluded **16** (docs/bevy-parity/excluded.tsv), left **335**.
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.
@@ -107,7 +107,6 @@ doesn't pay.
| ui/scroll_and_overflow/overflow_clip_margin | 10 | 0.997488 | 7 | 0 / 0 | 465 / 492 | 5 / 7 | 1 / 1 | 32.281 / 1.412 = 1.203 + 0.209 | yes | |
| ui/widgets/button | 10 | 0.999633 | 8 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 33.01 / 1.219 = 1.046 + 0.173 | yes | |
| ui/text/letter_spacing | 10 | 0.996458 | 13 | 0 / 0 | 455 / 492 | 5 / 7 | 1 / 1 | 33.285 / 1.088 = 0.961 + 0.127 | yes | |
-| ui/styling/borders | 10 | 0.992828 | 9 | 0 / 0 | 591 / 492 | 5 / 7 | 1 / 1 | 33.521 / 1.111 = 1.02 + 0.091 | yes | |
| ui/window_fallthrough | 10 | 0.992068 | 16 | 0 / 0 | 441 / 492 | 5 / 7 | 1 / 1 | 32.32 / 1.116 = 0.98 + 0.136 | yes | |
| ui/layout/z_index | 10 | 1.000000 | 0 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 32.169 / 1.386 = 1.231 + 0.155 | yes | |
| ui/styling/stacked_gradients | 10 | 0.994550 | 1 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 46.978 / 1.428 = 1.255 + 0.173 | yes | |
@@ -129,23 +128,25 @@ doesn't pay.
| ui/text/strikethrough_and_underline | 10 | 0.990823 | 15 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 2.3 / 2.548 = 2.548 + 0 | yes | |
| ui/text/strikethrough_and_underline | 5 | 0.990823 | 15 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 72.797 / 3.018 = 3.018 + 0 | yes | |
| ui/text/text | 10 | 0.990913 | 8 | 0 / 0 | 459 / 492 | 5 / 7 | 1 / 1 | 37.635 / 1.586 = 1.586 + 0 | yes | |
-| ui/text/generic_font_families | 10 | 0.990063 | 19 | 0 / 0 | 457 / 492 | 5 / 7 | 1 / 1 | 40.255 / 1.221 = 1.221 + 0 | yes | |
| ui/text/font_variations | 10 | 0.993984 | 20 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 2.066 / 1.468 = 1.468 + 0 | yes | |
| ui/text/font_variations | 5 | 0.993984 | 20 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 73.631 / 2.268 = 2.268 + 0 | yes | |
| ui/text/font_query | 10 | 0.993297 | 19 | 0 / 0 | 467 / 492 | 5 / 7 | 1 / 1 | 53.646 / 2.847 = 2.847 + 0 | yes | |
| ui/images/image_node | 10 | 0.999965 | 0 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 2.37 / 1.44 = 1.44 + 0 | yes | |
| ui/images/image_node | 5 | 0.999965 | 0 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 80.896 / 2.154 = 2.154 + 0 | yes | |
-| ui/images/ui_texture_atlas | 10 | 0.999776 | 6 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 1.721 / 1.091 = 1.091 + 0 | yes | |
-| ui/images/ui_texture_atlas | 5 | 0.999776 | 6 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 67.844 / 3.078 = 3.078 + 0 | yes | |
| ui/images/ui_texture_slice | 10 | 0.998941 | 8 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 38.224 / 1.264 = 1.264 + 0 | yes | |
| ui/images/ui_texture_atlas_slice | 10 | 0.990813 | 16 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 42.832 / 2.831 = 2.831 + 0 | yes | |
| ui/images/ui_texture_slice_flip_and_tile | 10 | 1.000000 | 0 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 45.245 / 2.59 = 2.59 + 0 | yes | |
-| ui/text/inline_image | 10 | 0.998473 | 8 | 0 / 0 | 446 / 492 | 5 / 7 | 1 / 1 | 43.171 / 2.018 = 2.018 + 0 | yes | |
| ui/ui_scaling | 10 | 0.999856 | 5 | 0 / 0 | 446 / 492 | 5 / 7 | 1 / 1 | 42.162 / 2.411 = 2.411 + 0 | yes | |
| ui/scroll_and_overflow/overflow_transform | 10 | 0.995397 | 12 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 45.188 / 2.255 = 2.255 + 0 | yes | |
| ui/scroll_and_overflow/overflow_debug | 10 | 0.996511 | 10 | 0 / 0 | 463 / 492 | 5 / 7 | 1 / 1 | 39.92 / 1.736 = 1.736 + 0 | yes | |
| ui/images/image_node_resizing | 10 | 0.998112 | 9 | 0 / 0 | 455 / 492 | 5 / 7 | 1 / 1 | 31.752 / 1.604 = 1.604 + 0 | yes | |
-| ui/render_ui_to_texture | 10 | 0.999980 | 1 | 1 / 1 | 450 / 495 | 6 / 8 | 2 / 2 | 39.73 / 2.716 = 2.716 + 0 | yes | |
+| ui/render_ui_to_texture | 10 | 0.999980 | 1 | 1 / 1 | 450 / 496 | 6 / 8 | 2 / 2 | 57.111 / 1.819 = 1.819 + 0 | yes | |
+| ui/images/ui_texture_atlas | 10 | 0.999776 | 6 | 0 / 0 | 445 / 493 | 5 / 7 | 1 / 1 | 2.412 / 1.68 = 1.68 + 0 | yes | |
+| ui/images/ui_texture_atlas | 5 | 0.999776 | 6 | 0 / 0 | 445 / 493 | 5 / 7 | 1 / 1 | 67.98 / 3.726 = 3.726 + 0 | yes | |
+| ui/styling/borders | 10 | 0.992828 | 9 | 0 / 0 | 591 / 493 | 5 / 7 | 1 / 1 | 42.558 / 2.218 = 2.218 + 0 | yes | |
+| ui/text/generic_font_families | 10 | 0.990063 | 19 | 0 / 0 | 457 / 493 | 5 / 7 | 1 / 1 | 38.156 / 1.782 = 1.782 + 0 | yes | |
+| ui/text/inline_image | 10 | 0.998473 | 8 | 0 / 0 | 446 / 493 | 5 / 7 | 1 / 1 | 40.112 / 2.347 = 2.347 + 0 | yes | |
+| ui/ui_drag_and_drop | 10 | 0.999046 | 3 | 0 / 0 | 1241 / 493 | 5 / 7 | 1 / 1 | 39.102 / 1.416 = 1.416 + 0 | yes | |
## Excluded
diff --git a/sdk/raea/bench/bevy-parity/ui/ui_drag_and_drop.tsx b/sdk/raea/bench/bevy-parity/ui/ui_drag_and_drop.tsx
new file mode 100644
index 00000000..fb5d5b58
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/ui/ui_drag_and_drop.tsx
@@ -0,0 +1,36 @@
+// Bevy v0.20.0 examples/ui/ui_drag_and_drop.rs in raea's TSX (docs/control.feature FC0a): a grey (0.4) grid centred in
+// the window, ten columns by ten rows of 40 px tiles with 4 px borders, alternating srgb(0.2, 0.2, 0.8) and
+// srgb(0.8, 0.2, 0.2) (by row parity plus column), each border its tile's colour darker(0.025), each tile showing its
+// index (column + row x 10) in Bevy's default font, a 2 px outline of Color::NONE until it's dragged. Hovering lightens a
+// tile and dragging lifts it with a white outline and swaps it on a drop: only under a pointer, which no render has.
+// Bevy's Camera2d over the default clear colour is the layered <Canvas3D>, in Bevy's default 1280 x 720 window.
+import { AbsoluteFill, Composition, registerRoot } from "raea";
+import { Canvas3D } from "raea/3d";
+import { GridPlacement, Node, Text, UiRect, px } from "raea/ui";
+import { Srgba } from "raea/color";
+
+const COLUMNS = 10;
+const ROWS = 10;
+const TILE_COLORS = [new Srgba(0.2, 0.2, 0.8), new Srgba(0.8, 0.2, 0.2)];
+
+function Tile({ column, row }: { column: number; row: number }) {
+ const color = TILE_COLORS[((row % 2) + column) % TILE_COLORS.length];
+ return (
+ <Node width={px(40)} height={px(40)} border={UiRect.all(px(4))} grid_row={GridPlacement.start(row + 1)} grid_column={GridPlacement.start(column + 1)} align_items="Center" justify_content="Center" border_color={color.darker(0.025)} background_color={color} outline={{ width: px(2), offset: px(0), color: new Srgba(0, 0, 0, 0) }}>
+ <Text>{`${column + row * COLUMNS}`}</Text>
+ </Node>
+ );
+}
+
+function Shot() {
+ const tiles = [];
+ for (let column = 0; column < COLUMNS; column++) for (let row = 0; row < ROWS; row++) tiles.push(<Tile key={`${column},${row}`} column={column} row={row} />);
+ return (
+ <AbsoluteFill>
+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />
+ <Node display="Grid" align_self="Center" justify_self="Center" background_color={new Srgba(0.4, 0.4, 0.4)}>{tiles}</Node>
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={1280} height={720} />);
diff --git a/sdk/render/src/bevy3d/ui.tsx b/sdk/render/src/bevy3d/ui.tsx
index 1022e88d..66241179 100644
--- a/sdk/render/src/bevy3d/ui.tsx
+++ b/sdk/render/src/bevy3d/ui.tsx
@@ -148,9 +148,10 @@ export function nodeCss(who: string, p: NodeProps, back?: Backdrop, scale = 1):
// (its corners as Bevy resolves them, of its size when that is in px)
const wh = [p.width, p.height].map((v) => (typeof v === "string" && /^[\d.e+-]+px$/.test(v) ? parseFloat(v) : NaN));
if (p.border_radius !== undefined) s.borderRadius = radiusCss(who, p.border_radius, wh.every(Number.isFinite) ? (wh as [number, number]) : undefined);
- // (the outline is outside the node: over what is under the node, not its own background)
+ // (the outline is outside the node, over whatever is there: its siblings too, not only the parent's background, so a
+ // translucent one goes as written and the page blends it in linear light, as Bevy does; Color::NONE draws nothing)
if (p.outline !== undefined) {
- s.outline = `${checkVal(who, "outline.width", p.outline.width)} solid ${over(who, "outline.color", p.outline.color ?? "#ffffff", back).css}`;
+ s.outline = `${checkVal(who, "outline.width", p.outline.width)} solid ${over(who, "outline.color", p.outline.color ?? "#ffffff", undefined).css}`;
if (p.outline.offset !== undefined) s.outlineOffset = checkVal(who, "outline.offset", p.outline.offset);
}
if (p.background_color !== undefined) ({ css: s.backgroundColor, back } = over(who, "background_color", p.background_color, back));