Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I needed to round just the top corners of an image and leave the bottoms square for a project so I wrote a patch that allows each corner on an image to be rounded at any radius. Previously you could only set one radius that would be used on all corners.
Please review this patch and get back to me with comments and suggestions.
Comment | File | Size | Author |
---|---|---|---|
#6 | imagecache_actions.jquery.js_.zip | 514 bytes | mason@thecodingdesigner.com |
imagecache_actions-[independent-rounded-corners].patch | 6.62 KB | mason@thecodingdesigner.com |
Comments
Comment #1
dman CreditAttribution: dman commentedThanks for this. It makes sense. I knew this was going to be a request eventually. Thanks for looking at it for us.
Visually the code looks fine. I'd like to roll it up a little more to avoid repetition, but the approach is just right.
Glad you figured out how to use the 'mask' shape bulder :-}
I'll give it a full review and roll it in soon.
Comment #2
dman CreditAttribution: dman commentedPatch applied clean.
I got some PHP complaints about undefined variables (normal).
Tweaked it to expand the UI if selected.
It certainly does the job.
Thanks for the logic on filling in the blocks there. I think I get it. SHould work as long as nobody tries to make radiuses larger than half the image.
... next thing we know, someone will want ellipse corners ;-)
I trimmed down the UI cut & paste a bit, eg I renamed the individual '$radiustl' sorta variables into a real array, and worked with the array directly, producing code more like :
... it's more elegant in some places. Not much advantage in others (possibly actually less readable), but I tend to fold repeated text up into loops where I can.
(I also added some UI tweaks to alert prople to the limitations of imagemagick - this is a different issue, but I rolled it today anyway.)
all in DRUPAL-6--1 DEV.
Not a release yet. Needs testing I guess. I wish a test suite were possible for images :-}
Comment #3
mason@thecodingdesigner.com CreditAttribution: mason@thecodingdesigner.com commentedThanks for the feedback and I like the code reformatting. It's definitely cleaner to treat the corners as an array. I'll use this version in my project and report back any issues. I'll also try to have some others take a look at it.
Two quick things:
I can only dl this version thru cvs. The dev snapshot on the project page is still the older version.
And you didn't include the imagecache_actions.jquery.js file in your commit.
Comment #4
dman CreditAttribution: dman commentedCVS not getting bundled is sorta normal. The changes roll overnight or over some hours or something. The date now says Mar 15, so I'm thinking it's ready.
What is imagecache_actions.jquery.js ? It didn't come with your patch either, although I saw it mentioned. ;-)
Comment #5
dman CreditAttribution: dman commentedNote, I found some issues where my changes to the maths had incorrectly re-used the $radius variable as a counter, not a default. My logic bad.
Fixing in dev now. CVS tarball may take a while. Continue to use CVS direct to checkout for now.
Comment #6
mason@thecodingdesigner.com CreditAttribution: mason@thecodingdesigner.com commentedAhh, got it. I didn't know about how the tarballs were made. I'm new to cvs.
I'm attaching the .js file. It's not much, but it disables the appropriate input fields when you check and uncheck the 'independent radius' checkbox.
Comment #7
dman CreditAttribution: dman commentedOK.
It's pretty small stuff, but it certainly got the 'unobtrusive' bit working because I never noticed it missing.
I've reviewed it, and added a shorter modified version that gets jquery to do the hard work for us:
"#independent-corners-set-wrapper .form-text"
:-B I always vaporize repetition when I see it!
Comment #8
mason@thecodingdesigner.com CreditAttribution: mason@thecodingdesigner.com commentedSweet. Die, repetition, die!
or
Die, repetition.
Comment #9
dman CreditAttribution: dman commentedhttp://drupal.org/node/413948 committed to current version
Comment #10
mason@thecodingdesigner.com CreditAttribution: mason@thecodingdesigner.com commentedSweet, thanks!