Repository navigation
Draw large and long and thin ellipses without overflow - #10611
Open
aclark4life wants to merge 2 commits into
Open
aclark4life wants to merge 2 commits into
aclark4life wants to merge 2 commits into
Conversation
Calculate the ellipse walk with wrapping unsigned arithmetic, so that large circles draw correctly without signed overflow, and draw nothing for ellipses too large for 64-bit arithmetic. Skip long horizontal runs of the walk, and rows above the image, so that drawing takes time proportional to the image rather than the ellipse. Output is otherwise unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
The ellipse walk shared by
ellipse(),circle(),arc(),chord()andpieslice()calculateda²y² + b²x² - a²b²inint64_t. For large ellipses, that overflowed, and the walk could fail to finish. It also visited every point along the ellipse, so time grew with the size of the ellipse rather than the image.This
uint64_tarithmetic. The result is exact while the values compared fit inint64_t, so large circles draw as before. Ellipses too large for that, more than about 830,000 pixels across, draw nothing.mainellipse((0, 0, 2**30, 1))ellipse((0, 0, 1, 2**30))ellipse((0, 0, 2**28, 2**28))The output is unchanged: comparing with
mainacross 67,834 ellipses, arcs, chords and pieslices with fills and outline widths, including partly visible ones and circles up to 700,000 pixels across, all were pixel-identical.🤖 Generated with Claude Code