image
image copied to clipboard
[feature] copyCropSquircle function
Hi, first of all, I would like to thank you for this incredible library. It saved me an enormous amount of time!
Since I am working on a project which generates app icons, it would be great if you consider implementing copyCropSquircle feature.
Thanks in advance!
@Cyril212 @brendan-duncan was this feature been implemented? I am unable to find any reference to copyCropSquircle
function in the code. The closest one is copyCropCircle
but that isn't the same.
I haven't implement rounded rectangles yet.
@brendan-duncan it would be a handy feature that could be used to generate and update app icons (macos and windows) using Flutter tools like flutter_launcher_icons
Yeah, it's on my list to do. Just have to figure out a good way to draw a rounded rectangle, and not call it squircle :-)
Yeah, it's on my list to do. Just have to figure out a good way to draw a rounded rectangle, and not call it squircle :-)
That is good to hear.
Technically they are not the same. For their icons Apple uses superellipse.

It needs some form of Bezier path support, e.g. this Flutter package depends on the Path
from Flutter https://github.com/Monksc/cupertino_rounded_corners/blob/master/lib/cupertino_rounded_corners.dart
Rounded corners should be simpler - kind of 4 times copyCropCircle
you have, or an extension of calculateCircumference
with the angle range input parameters to produce corner arcs.
BTW, it would be interesting to have an extension of the drawRect
method with similar rounded corners support.
Thanks for the info. Guess I'll have to live with the word "squicle" being a thing. I was thinking of adding a radius arg to drawRect and copyCrop (and copyResizeCropSquare). I want to avoid having to implement full spline path filling, so I'm looking at other solutions.
A quick experiment: with a radius defining circles at the corners of rectangles, analytically discard pixels outside the corner circles to round the corners. Here's a test with a radius of 10:
And here is an outline version using lines and circle arcs:
Much faster than dealing with splines. I'll go ahead and add a radius arg to drawRect, fillRect, and the crop functions and use this approach, unless this isn't quite what you're describing. I'll look up the Material spec to make sure I'm not too far off.
@brendan-duncan thank you for looking into that. Especially on a New Years Eve. :)
It is a great progress without having support for path/curves. Maybe at some point in the future...
Never a lack of things to work on. I'm just doing some quick experiments while the cake is in the oven :-)
It does seem Material uses more rounded rectangles like I have above, and Apple uses more squircles. Guess I'll have to spend the time on cubic splines and path filling.
It does seem Material uses more rounded rectangles like I have above, and Apple uses more squircles. Guess I'll have to spend the time on cubic splines and path filling.
That also would be an awesome addition to the image package.