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
Two paint bugs, each held to what Chrome draws (bench/paint-order/check.sh). #241: a stacking context's z-index: -1 children go under its own content, so a box behind a word no longer covers it: the element's text was drawn before every child, the negative ones included. #240: a miter join between tangents within a quarter of a degree of one line is a bevel: after an arc, a long line's tangent passed the join's absolute test, and the miter point, taken from two points a fraction of a pixel apart, landed across the page as a bar from x=0 (a rounded rect's stroke under a negative viewBox origin, at some widths)
shinyobjectz5d5da4f3d8ea
diff --git a/bench/paint-order/check.sh b/bench/paint-order/check.shnew file mode 100755index 00000000..5423ddc5--- /dev/null+++ b/bench/paint-order/check.sh@@ -0,0 +1,30 @@+#!/bin/bash+# Two paint bugs, each held to what Chrome draws. Exits 1 on a failure.+# #241 z.html: a stacking context's z-index: -1 child goes under its text. White pixels (the word) must be there:+# before the fix the box covered the word and the frame had none.+# #240 miter.html: a stroked rounded rect under a negative viewBox origin. Nothing blue left of the outline (x 0-60,+# y 84-130: the outline starts at x 92), and the outline's top-left corner is round (dark at its square corner).+# bench/paint-order/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-paint-order.XXXXXX")+trap 'rm -rf "${OUT:?}"' EXIT+status=0+for p in z miter; do+ "$BIN" render "bench/paint-order/$p.html" -o "$OUT/$p.png" > "$OUT/$p.log" 2>&1 || { echo "FAIL render $p (log below)"; sed 's/^/ /' "$OUT/$p.log"; exit 1; }+done+# how many pixels of a region are near a colour+count() { magick "$OUT/$1.png" -alpha off -crop "$2" +repage -fuzz "${4:-6}%" -fill black +opaque "$3" -fill white -opaque "$3" -colorspace Gray -format "%[fx:int(mean*w*h+0.5)]" info:; }+white=$(count z 600x300+0+0 "#ffffff")+(( white > 2000 )) || { echo "FAIL #241: $white white pixels, the word is under its z-index: -1 child"; status=1; }+box=$(count z 600x300+0+0 "#10203C" 3)+(( box > 3000 )) || { echo "FAIL #241: $box pixels of the box behind the word"; status=1; }+bar=$(count miter 60x46+0+84 "#3c82f0")+(( bar == 0 )) || { echo "FAIL #240: $bar blue pixels left of the outline (the miter join's bar)"; status=1; }+corner=$(count miter 6x6+91+99 "#3c82f0")+(( corner == 0 )) || { echo "FAIL #240: the outline's top-left corner is square ($corner blue pixels at its corner)"; status=1; }+edge=$(count miter 200x6+400+97 "#3c82f0")+(( edge > 300 )) || { echo "FAIL #240: the outline's top edge isn't drawn ($edge pixels)"; status=1; }+[ $status = 0 ] && echo "PASS paint order: #241 text over a negative z-index child, #240 a miter join after an arc"+exit $statusdiff --git a/bench/paint-order/miter.html b/bench/paint-order/miter.htmlnew file mode 100644index 00000000..c4a8bfbc--- /dev/null+++ b/bench/paint-order/miter.html@@ -0,0 +1,7 @@+<!doctype html>+<!-- #240: a thin rounded outline, nothing left of it (896 wide under a viewBox that starts at -20 drew a bar from x=0) -->+<html><body style="margin:0;background:#111">+<div data-composition-id="main" data-start="0" data-duration="1" data-width="1080" data-height="600" style="position:relative;width:1080px;height:600px;background:#111">+<svg width="936" height="440" viewBox="-20 -20 936 440" style="position:absolute;left:72px;top:80px"><rect x="0" y="0" width="896" height="400" rx="24" fill="none" stroke="#3c82f0" stroke-width="3"/></svg>+</div>+</body></html>diff --git a/bench/paint-order/z.html b/bench/paint-order/z.htmlnew file mode 100644index 00000000..dc441859--- /dev/null+++ b/bench/paint-order/z.html@@ -0,0 +1,7 @@+<!doctype html>+<!-- #241: white "Hollow" over a blue box that is its own z-index: -1 child -->+<html><body style="margin:0;background:#111">+<div data-composition-id="main" data-start="0" data-duration="1" data-width="600" data-height="300" style="position:relative;width:600px;height:300px;background:#111;display:flex;align-items:center;justify-content:center">+<span style="position:relative;display:inline-block;z-index:1;color:#fff;font:700 80px sans-serif"><div style="position:absolute;inset:0;z-index:-1;background:#10203C;border:3px solid #3474D6"></div>Hollow</span>+</div>+</body></html>diff --git a/vendor/blitz-paint/src/render.rs b/vendor/blitz-paint/src/render.rsindex 63454f03..b0310aeb 100644--- a/vendor/blitz-paint/src/render.rs+++ b/vendor/blitz-paint/src/render.rs@@ -1395,6 +1395,9 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> {x: -node.scroll_offset().x * self.scale,y: -node.scroll_offset().y * self.scale,});+ // raea: a stacking context's negative z-index children go under its own content+ // (CSS 2.1 Appendix E step 3): its text was drawn first and they covered it (#241)+ cx.draw_negative_z(scene, cx.transform, child_clip_rect);cx.draw_image(scene);#[cfg(feature = "svg")]cx.draw_svg(scene);@@ -1405,7 +1408,7 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> {cx.draw_text_input_text(scene, content_position);cx.draw_inline_layout(scene, content_position);cx.draw_marker(scene, content_position);- cx.draw_children(scene, cx.transform, child_clip_rect);+ cx.draw_from_z_zero(scene, cx.transform, child_clip_rect);cx.draw_select_chevron(scene);},);@@ -2171,8 +2174,13 @@ impl ElementCx<'_, '_> {parent_style_transform: Affine,clip_rect: Rect,) {- // Negative z_index hoisted nodes+ self.draw_negative_z(scene, parent_style_transform, clip_rect);+ self.draw_from_z_zero(scene, parent_style_transform, clip_rect);+ }+ /// raea: the negative z-index children of this stacking context, which paint over its background and under+ /// everything else of it, its own text included (#241)+ fn draw_negative_z(&self, scene: &mut impl PaintScene, parent_style_transform: Affine, clip_rect: Rect) {if let Some(hoisted) = &self.node.stacking_context {for hoisted_child in hoisted.neg_z_hoisted_children().filter(|c| !self.from_above(c.node_id)) {let position = hoisted_child.position(self.node.tree(), self.node.id);@@ -2190,7 +2198,10 @@ impl ElementCx<'_, '_> {(0..clips).for_each(|_| scene.pop_layer());}}+ }+ /// raea: the children in tree order, then the positive z-index ones (see [`Self::draw_negative_z`])+ fn draw_from_z_zero(&self, scene: &mut impl PaintScene, parent_style_transform: Affine, clip_rect: Rect) {// Regular childrenif paint_phases() {for phase in [Phase::Blocks, Phase::Floats, Phase::Inlines, Phase::Positioned] {diff --git a/vendor/vello_shaders/shader/flatten.wgsl b/vendor/vello_shaders/shader/flatten.wgslindex f1857f98..bf62b80c 100644--- a/vendor/vello_shaders/shader/flatten.wgsl+++ b/vendor/vello_shaders/shader/flatten.wgsl@@ -553,6 +553,9 @@ fn draw_cap(write_line_with_transform(line_ix, path_ix, start, end, transform);}+// raea: the least sine of the angle between two tangents that still gets a miter point (see draw_join, #240)+const MITER_SINE_MIN = 4e-3;+fn draw_join(path_ix: u32, style_flags: u32, p0: vec2f,tan_prev: vec2f, tan_next: vec2f,@@ -589,6 +592,12 @@ fn draw_join(// tangents.if 2. * hypot < (hypot + d) * miter_limit * miter_limit&& abs(cr) > TANGENT_THRESH * TANGENT_THRESH+ // raea: and when the tangents are within a quarter of a degree of one line, whatever their lengths+ // (`cr` grows with them, so a long line after an arc passed the test above): the intersection is+ // taken from two points a fraction of a pixel apart, lost in f32 at page coordinates, and the miter+ // point landed hundreds of pixels away, a bar across the page (raea #240). A bevel there is the miter+ // to within 0.003 px+ && abs(cr) > MITER_SINE_MIN * hypot{let is_backside = cr > 0.;let fp_last = select(front0, back1, is_backside);diff --git a/vendor/vello_shaders/src/cpu/flatten.rs b/vendor/vello_shaders/src/cpu/flatten.rsindex 26e42493..9ffb06a6 100644--- a/vendor/vello_shaders/src/cpu/flatten.rs+++ b/vendor/vello_shaders/src/cpu/flatten.rs@@ -459,6 +459,8 @@ fn draw_join(if 2. * hypot < (hypot + d) * miter_limit * miter_limit&& cr.abs() > TANGENT_THRESH.powi(2)+ // raea: as flatten.wgsl's MITER_SINE_MIN (raea #240)+ && cr.abs() > 4e-3 * hypot{let is_backside = cr > 0.;let fp_last = if is_backside { back1 } else { front0 };