The Incredible SuperCard Shrink Tool

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3548
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: The Incredible SuperCard Shrink Tool

Post by bn » Tue Nov 23, 2021 8:29 am

Thanks Stam and Roger,

Roger, if you want to understand what is going on then this link is from where I got the idea how to do it
http://www.imageprocessingplace.com/dow ... m/ray.html

In this particular implementation the algorithm scans the maskData of an image with transparencies. That is the step where you take the snapshot from the group that provides the transparencies around the opaque graphics. In an image with transparencies the maskData gives you byteToNum = 0 for transparent and 255 for opaque for all pixels. Only those 2 values are provided by the maskData. This information is used in the tracing algorithm.
That code was a pain to write and is a pain to understand...
I also made a version for color where you extract the colors of an image to turn the image into graphics that you can colorize (I limit it to max 12 colors).
It was fun to take an algorithm and turn it into actual code though.
Kind regards
Bernd

stam
Posts: 830
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: The Incredible SuperCard Shrink Tool

Post by stam » Tue Nov 23, 2021 2:08 pm

bn wrote:
Tue Nov 23, 2021 8:29 am
Roger, if you want to understand what is going on then this link is from where I got the idea how to do it
http://www.imageprocessingplace.com/dow ... m/ray.html
Dear Bernd, that's a really interesting link and i'm in awe that you turned this into such well functioning LC code!
Having read this, your code makes a bit more sense and i'll try to digest your code in full when i get some time (the most precious commodity!)

Thank you for sharing this,
Stam

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

Re: The Incredible SuperCard Shrink Tool

Post by RogGuay » Tue Nov 23, 2021 7:03 pm

Bernd,

I just had to take a moment to tell you how impressed I am with your TraceOutlineOfGraphics stack. As near as I can tell at this early stage, you not only have managed to create a tool that mimics the old SuperCard Shrink tool, but also have provided me a treasure trove of LC scripting lessons. Thank you for contributing so much to me and this community. Can't wait to find time to dive into this deeper.

Also to the mothership: This should be added to the tool pallet! In the meantime I will use Bernd's stack as a plugin.

Rectangle with only 2 rounded corners ....Pshaw, absolutely no problem!!

Roger

scott_morrow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 17
Joined: Tue Jun 27, 2006 8:35 pm
Location: Bellingham, WA USA
Contact:

Re: The Incredible SuperCard Shrink Tool

Post by scott_morrow » Wed Nov 24, 2021 6:13 am

Bernd,
I'm with Roger and stam on this one. Your "TraceOutlineOfGraphics.livecode" stack is just too cool!
--Scott
Elementary Software
...now with 20% less chalk dust!

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

Re: The Incredible SuperCard Shrink Tool

Post by RogGuay » Wed Nov 24, 2021 10:35 pm

In case there is anyone left here that wants to continue playing, consider another approach to the Incredible SuperCard Shrink Tool:

The points of a polygon that has been tightly shrunk to fit (think superimposed) around an assembly of other overlapping polygons are all contained in a subset of the points of the original assembled polygons. for example, consider 2 overlapping polygons Poly1 and Poly2 . The desired polygon Poly3 which superimposes the outer edge of the assembled Poly1 and Poly2 will have tPoints3 where

tPoints3 = tPoints1 + tPoints2 - Poly1 points that lie within Poly2 - Poly2 points that lie within Poly1

So far I have not found a reliable repeatable way to peel away the “inside" points and stitch together the remaining points that would define Poly3. The Peeling away part would be easy if the "within" function were not restricted to rectangles. Major bummer!! Perhaps the Bernd method might be used somehow leaving only only the stitching together part???

Any ideas?

Roger

Post Reply

Return to “Talking LiveCode”