fix(renderer): guard card shadow from clipping at canvas edge - #25
Merged
Conversation
Single source of truth for shadow blur/offset shared by the canvas and SVG pipelines. SVG derives dy/stdDeviation from the same values, so the two renderers cannot drift apart.
The card drop shadow paints up to blur + offsetY beyond the card edge, but text metrics (measureText) are blind to painted overflow. compute_layout now clamps the effective padding to CARD_SHADOW_SAFE_MARGIN when the window frame is on, so a small padding (UI minimum is 16px, shadow extent is 30px) can no longer cut the shadow off at the canvas edge. The split-screen divider now follows the clamped card_y instead of raw options.padding.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The code-card drop shadow paints up to
blur + offsetY(30px) beyond the card edge, but the canvas padding is user-controlled down to 16px (UI slider minimum). The shadow was silently clipped at the canvas edge — the exact 'painted overflow invisible to text metrics' class of bugmeasureText()is blind to.Changes
shadowBlur 20 / offsetY 10) fromcanvas.rsinto shared constants inrenderer::layout; the SVG pipeline now derivesdy/stdDeviationfrom the same constants (single source of truth).compute_layoutclamps the effective padding toCARD_SHADOW_SAFE_MARGIN(30px) whenever the window frame is on, so the shadow always fits inside the canvas. Split-screen dividers follow the clampedcard_yinstead of rawoptions.padding.layout.rs(no DOM needed): padding below the margin is raised, padding at/above it is untouched, and the no-frame path is unaffected.Verification
cargo fmt --all --check✓cargo clippy --workspace --all-targets -- -D warnings✓cargo test --workspace✓ (13 renderer tests, incl. 3 new)Known limitation (follow-up)
The SVG drop-shadow filter region (
x="-10%" y="-5%") is percentage-based and can also clip on very short cards; out of scope here.