Repository navigation
Fix Rectangle::chord endpoint distance for diagonal angles - #3529
Open
akasakariko wants to merge 1 commit into
Open
akasakariko wants to merge 1 commit into
akasakariko wants to merge 1 commit into
Conversation
Compute the half-length as the minimum of the ray intersection distances with the rectangle slabs instead of the maximum of the projected half-extents This puts both endpoints on the boundary for non-axis-aligned angles and leaves axis-aligned chords unchanged
alpCaner
pushed a commit
to alplabai/iced
that referenced
this pull request
Nov 4, 2026
…or diagonal angles
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.
Fixes #3504
Rectangle::chordcomputed the half-length asmax(|r.x| * width / 2, |r.y| * height / 2), which is not a ray/box intersection. For diagonal angles this placed endpoints inside the rectangle, or outside it for non-square bounds, so linear gradients were compressed or overflowedThe half-length is now
min((width / 2) / |r.x|, (height / 2) / |r.y|), with infinities when a component is zero, so both endpoints always lie on the boundary100x100at 45 degrees:(25, 75) -> (75, 25)becomes(0, 100) -> (100, 0)100x20at 45 degrees:(25, 35) -> (75, -15)becomes(40, 20) -> (60, 0)0and90degree chords are unchangedA regression test in
core/src/rectangle.rscovers axis-aligned and diagonal chordsLocal checks
cargo test -p iced_corecargo fmt --all -- --checkRUSTFLAGS="--deny warnings" cargo clippy -p iced_core --all-targetsRUSTFLAGS="--deny warnings" cargo check -p iced_graphics -p iced_tiny_skia