How to draw a rectangle with only two rounded corners?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

stam
Posts: 3092
Joined: Sun Jun 04, 2006 9:39 pm

Re: How to draw a rectangle with only two rounded corners?

Post by stam » Fri Nov 19, 2021 10:51 am

Further to this, i got in touch with the author (Andreas Strauch) via facebook and he's generously agreed to share a new version...

stam
Posts: 3092
Joined: Sun Jun 04, 2006 9:39 pm

Re: How to draw a rectangle with only two rounded corners?

Post by stam » Fri Nov 19, 2021 11:55 am

The author, Andreas Strauch, has kindly been in touch and confirmed his widget CustomRect is released as openSource.
If used in a project please do acknowledge him. It goes without saying, but he's asked that the widget itself is not exploited financially.

He's kindly shared the source with me and i've mirrored this on MediaFire.com
Link : https://www.mediafire.com/file/vo7a7rs0 ... w.zip/file

Use the extension manager (Tools menu -> extension manager -> + ) to install.

After installation, you get a new icon in the Tools palette:
tools.jpg

Double-click (or drag/drop) this to add a new customRect to your card
new customRect.jpg

Invoke the properties panel (eg double-click) and adjust each corner as needed
customRect properties panel.jpg

I've been using this for quite a while and it's been rock solid - I can only thank Andreas for creating this and re-sharing it. Hopefully others will find this useful as well...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to draw a rectangle with only two rounded corners?

Post by bn » Fri Nov 19, 2021 2:26 pm

Hi Stam,

I agree that Andreas Strauch's CustomRect is a nice and versatile widget. The only advantage compared to Ralph Bitter's Universal Button is that you can change the radius of every corner individually. Universal button only lets you change the corner radius for all corners that are rounded at once.

However Universal Button has some advantages.
1. It is MIT licensed. (as long as you include the license somewhere in your project you are free to do what you want, that includes using it in commercial applications.)

2. It includes an API i.e. you can find its properties in the LC dictionary (I know it is tedious to write them but I think a widget for public consumption needs and API which could be an inline documentation in the LCB file from which the API is extracted automatically for the dictionary)

3. I has not some of the minor drawing issues that CustomRect has.


Kind regards
Bernd

Andreas S.
Posts: 5
Joined: Fri Nov 19, 2021 1:12 pm

Re: How to draw a rectangle with only two rounded corners?

Post by Andreas S. » Fri Nov 19, 2021 2:41 pm

Hello together
I am the author of customRect and welcome any comments with constructive criticism.

Regarding the widget by Ralph Bitter:
I know it and it has a completely different approach than my widget. His widget is based on buttons, mine on the other hand on a graphical representation.

As for the matter of the licence... it's getting too stupid for me to go into discussions now, so I'll make short work of it: It's now a Puplic Domain and the source will be available for everyone on Github from Sunday. Full stop.

As for the API. Since I originally wrote the widget just for myself, I didn't see any need... So if you want to... do your thing....

have a nice day

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to draw a rectangle with only two rounded corners?

Post by bn » Fri Nov 19, 2021 4:17 pm

Hi Andreas,

welcome to the forum.

In my previous post it was not my intention to put your widget "customRect" down.
I see every widget as a welcome addition to the available widgets.
I just wanted to point out some differences to Ralf's "Universal Button" which has the same functionality for the original poster.
And I know that the original poster does commercial apps

In case you felt offended by my comments I would like to ask you to accept my appologies.

Kind regards
Bernd

Andreas S.
Posts: 5
Joined: Fri Nov 19, 2021 1:12 pm

Re: How to draw a rectangle with only two rounded corners?

Post by Andreas S. » Fri Nov 19, 2021 5:27 pm

All fine, bernd

both widgets are just different. Not the same.
CustomRect never wrote for button use. Its just a designelement.

stam
Posts: 3092
Joined: Sun Jun 04, 2006 9:39 pm

Re: How to draw a rectangle with only two rounded corners?

Post by stam » Fri Nov 19, 2021 6:06 pm

I've used customRect as a button, no problem - it just needs a short script (which can be added as a behaviour) to give a visual response to mouse click and it works perfectly (pretty much as with any rect).

I only once had a weird visual artefact (a straight line showing around the curve) when 'switching off' some corners.
But this was eliminating by switching on all corners and setting the ones i wanted orthogonal to '1', and i've never since had any graphical oddities with it (admittedly, tested on Mac only).

As for the API (if you want to control in script) the 2 functions it has work just fine:

Code: Select all

set TopLeftRadius|TopRightRadius|BottomLeftRadius|BottomRightRadius of widget "Custom Rect" to [Number]
 
set showTopLeft|showTopRight|showBottomLeft|showBottomRight of widget "Custom Rect" to true|false
I wasn't previously aware of it Universal Button - On quick testing this seems to be a button on steroids and a useful addition indeed!
Will definitely make use of it.
But hard to control each corner independently (at least from the properties panel).

The OP was asking how to create a rect with 2 orthogonal corners and 2 rounded corners - it's a breeze with customRect.

But great discussion as I've now also found Universal button, and hopefully others have found customRect.

And thanks to both Andreas and Ralph for providing these great widgets!

Andreas S.
Posts: 5
Joined: Fri Nov 19, 2021 1:12 pm

Re: How to draw a rectangle with only two rounded corners?

Post by Andreas S. » Sat Nov 20, 2021 12:10 pm

https ://github. com/Hoerwi/LC-Widget-customRect

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: How to draw a rectangle with only two rounded corners?

Post by richmond62 » Sat Nov 20, 2021 2:01 pm

This might be a very goofy question indeed, but it won't be my first, so here goes:

If I set up a 'standard' rounded rectange graphic object on a stack, vis:
-
SShot 2021-11-20 at 14.58.13.png
-
Is there a way I can get a list of its points like those in a hand-drawn graphic?
-
SShot 2021-11-20 at 15.00.58.png
-
SShot 2021-11-20 at 15.05.27.png
-
Ah, well; eternally hopeful and eternally naive. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: How to draw a rectangle with only two rounded corners?

Post by richmond62 » Sat Nov 20, 2021 2:19 pm

Code: Select all

set the editmode of grc "P2" to "polygon"
DIDN'T with a Rounded Rectangle. :(

stam
Posts: 3092
Joined: Sun Jun 04, 2006 9:39 pm

Re: How to draw a rectangle with only two rounded corners?

Post by stam » Sat Nov 20, 2021 2:41 pm

richmond62 wrote:
Sat Nov 20, 2021 2:01 pm
Is there a way I can get a list of its points like those in a hand-drawn graphic?
You can get the points but don't think you can set them directly - but you can assign these to a polygon graphic.

to get the points of a rounded rect:

Code: Select all

put the effective points of grc "Round Rectangle"
if you have a polygon, you can assign the roundRect points to it's points - which means you can transform as needed.

Code: Select all

set the points of grc "polygon" to the effective points of arc "rounded rectangle"
but for the purpose of the OPs question, just use the customRect widget, it's just so much easier ;)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: How to draw a rectangle with only two rounded corners?

Post by richmond62 » Sat Nov 20, 2021 3:08 pm

it's just so much easier
Indeed: not everyone is as bloody-minded as I am. :?

RogGuay
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 122
Joined: Fri Apr 28, 2006 12:10 am

Re: How to draw a rectangle with only two rounded corners?

Post by RogGuay » Sat Nov 20, 2021 4:51 pm

Just as an aside, I fondly remember my absolute favorite tool in SuperCard . . . I think it was called the Shrink Tool. With it, you could assemble, for example, a rounded corner rect or button and a squared corner rect or button and then use the Shrink Tool to collapse a single polygon around around the assembled items. It also worked to expand a polygon inside open objects.

I've tried to recreate this tool in LC, but so far, no cigar. Now there's a challenge for the many more talented of you out there!

Roger

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to draw a rectangle with only two rounded corners?

Post by jacque » Sat Nov 20, 2021 8:53 pm

Andreas S. wrote:
Sat Nov 20, 2021 12:10 pm
https ://github. com/Hoerwi/LC-Widget-customRect
I wasn't able to get this link to work, even after removing the extra spaces. But I downloaded it from stam's link and it works. This is a useful addition and a good companion to the Universal Button widget. I now have both and it's great to have choices. Thank you for sharing this.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: How to draw a rectangle with only two rounded corners?

Post by richmond62 » Sat Nov 20, 2021 9:18 pm

Code: Select all

set the points of grc "polygon" to the effective points of arc "rounded rectangle"
-
Queer, very queer indeed:
-
SShot 2021-11-20 at 22.16.57.png
-
I really wonder what happened there.

I was expecting a full replica of my rounded rectangle . . . but, obviously, I was wrong. :(
-
SShot 2021-11-20 at 22.21.53.png
-
SShot 2021-11-20 at 22.22.37.png
-
Err, I dragged P3 back to its original position for display purposes.

Post Reply