Implemented another ellipse drawing algorithm#4523
Implemented another ellipse drawing algorithm#4523hugovk merged 19 commits intopython-pillow:masterfrom xtsm:ellipse
Conversation
Co-Authored-By: Andrew Murray <[email protected]>
Adjusted symmetry test
src/libImaging/Draw.c
Outdated
| const void* ink, int fill, int width, int op) | ||
| { | ||
| return ellipse(im, x0, y0, x1, y1, 0, 360, ink, fill, width, CHORD, op); | ||
| return ellipseNew(im, x0, y0, x1, y1, ink, fill, width, op); |
There was a problem hiding this comment.
Is there any chance new implementation is used for other functions? At least for ImagingDrawChord?
There was a problem hiding this comment.
Yeah, but it would involve another layer of processing that clips ellipse down to arc.
I've got it more or less done locally, maybe I'll commit that later. The code is gonna look funky though due to all the floating point geometry and special cases processing...
There was a problem hiding this comment.
Arcs, chords and pies are kinda working now.
At least compared to whatever was in master before.
I also added a test for various size ellipses. I added it long ago but forgot to push.
|
All test images are circles, actually, not ellipses. Could you add ones? |
@xtsm Little reminder for ^ this, thanks! |
Co-authored-by: Hugo van Kemenade <[email protected]>
|
Thanks! Please also update the release notes if you think it's necessary: https://github.com/python-pillow/Pillow/blob/master/docs/releasenotes/8.0.0.rst |
|
Release notes PR: #4976 |
Add #4523 ellipse-drawing algorithm changes to release notes
…s to no longer be polygons
This PR changes ellipse drawing algorithm from simply drawing 360-gon to something that resembles Bresenham's algo for circles. It works like 100x faster (on my machine, according to randomized test) and produces nicer results, especially for smaller ellipse sizes.
Arcs, pies, etc. are left untouched for now.
Upd: I've also changed some tests (e.g. ellipse_symmetric and ellipse_edge) according to new drawing behavior. If now they're not checking what they were supposed to check, please tell me.