Putting image into a circle shape

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Putting image into a circle shape

Post by EddieLee » Sat Nov 24, 2018 9:21 am

Hi all, the livecode built in image only allows square images . The property does not have any ways to change the shape. Do I have to use a graphic in this case?


Thank you for your kind replies.
Eddie :D

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Putting image into a circle shape

Post by SparkOut » Sat Nov 24, 2018 9:38 am

What are you trying to do with the image? There are different ways of dealing with this depending on what your interactions with the image are (eg collision detection, mouseover actions etc).
Most can probably be dealt with by transparency settings, but can be enhanced with one of Hermann's nifty stacks with frame masking, or possibly as a background pattern in a graphic if it really needs to be, as in the hex tile creation thread. http://forums.livecode.com/viewtopic.php?f=22&t=31212

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9383
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Putting image into a circle shape

Post by richmond62 » Sat Nov 24, 2018 9:56 am

Personally I'd make a circular graphic, store your image off-screen
and then set the backGroundPattern of the graphic to your picture.
-
Donald.jpg
-

Code: Select all

on mouseUp
   set the backGroundPattern of grc "oo" to the ID of image "tt"
end mouseUp
-
If you want to save storage space you can subsequently take a snapshot
of the circular graphic and delete both it and the original image.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Putting image into a circle shape

Post by SparkOut » Sat Nov 24, 2018 10:02 am

Is that supposed to have a cross-hair reticule?

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Re: Putting image into a circle shape

Post by EddieLee » Sat Nov 24, 2018 10:20 am

Hi Richmond,

Thanks, what I was trying to do is exactly what you have posted. I will try to use the backgroundpattern to do it. However in your post, is there a way to centralise the image so that I can fully see Donald Trump's face?
Eddie :D

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Putting image into a circle shape

Post by jmburnod » Sat Nov 24, 2018 11:23 am

Hi,
is there a way to centralise the image
You may try to set the rect of your img to the rect of your grc.
If the human face is on the middle of your image that should work.
Best
Jean-Marc
https://alternatic.ch

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Putting image into a circle shape

Post by Klaus » Sat Nov 24, 2018 11:37 am

Hi Eddie,

yep, the backgroudpattern is the easy-peasy-new-york-teenie version, but has its limits like the part you will see in the pattern is alway starting at the the topleft.

To have more control of the excerpt you want to display use INKS and a group.
INKS are still a complete mistery to me :-) but some testing revealed this solution to me:
1. Create a graphic object (oval, rect, roundrect, polygon) for your mask

2. Set it to OPAQUE and backgroundcolor to WHITE

3. Set its INK to -> BlendDestIn
lcmask1.jpg
4. Now group this grahic and your image and set the INK of the GROUP to -> blendSrc
lcmask2.jpg
5. Example of same rect for graphic and group:
lcmask3.jpg
6.Now you can postion your graphic inside of the group to display the part of the image you always wanted to but you need to set the rect of the group to the (new) rect of the mask graphic :-)
lcmask4.jpg
Have fun!


Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9383
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Putting image into a circle shape

Post by richmond62 » Sat Nov 24, 2018 3:57 pm

is there a way to centralise the image so that I can fully see Donald Trump's face?
If you must, you must:
-
Donald2.jpg
-
HOWEVER, as you can see, that is far from satisfactory as his cheesy muzzle
is in the centre of a non-square image, and back patterns tile.

Of course you can "fiddle around" with the Donald Trump picture outwith LiveCode
with an image editor such as GIMP so that you end up with his cheesy muzzle
in the centre of a square picture.

This does seem to be etched in stone:
The backgroundPattern of controls is drawn starting at the control's upper left corner: if the control is moved, the pattern does not shift.
Last edited by richmond62 on Sat Nov 24, 2018 4:02 pm, edited 2 times in total.

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Putting image into a circle shape

Post by Klaus » Sat Nov 24, 2018 3:59 pm

Eddie, no idea why you really want to fully see Donald Trump's face!? :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9383
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Putting image into a circle shape

Post by richmond62 » Sat Nov 24, 2018 4:03 pm

no idea why you really want to fully see Donald Trump's face!?
Oh, come on, Klaus, we all have our "little kinks"
(and I won't tell about yours if you don't tell about mine). 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9383
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Putting image into a circle shape

Post by richmond62 » Sat Nov 24, 2018 4:06 pm

setht eINK of the GROUP
Why do I feel that needs a bit of clarification?

Or is November 24 Metathesis Day?

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Putting image into a circle shape

Post by Klaus » Sat Nov 24, 2018 4:07 pm

I have nothing to hide, just go ahead! :D

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Putting image into a circle shape

Post by Klaus » Sat Nov 24, 2018 4:10 pm

richmond62 wrote:
Sat Nov 24, 2018 4:06 pm
setht eINK of the GROUP
Why do I feel that needs a bit of clarification?
Because you do not have the slightest touch of imagination? 8)

I corrected this little faux-pas in the meantime.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9383
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Putting image into a circle shape

Post by richmond62 » Sat Nov 24, 2018 4:15 pm

Because you do not have the slightest touch of imagination?
Wow! That's the first time I have been accused of that.
-
tt1.jpg
trump2.jpg
trump2.jpg (116.32 KiB) Viewed 6067 times
-
Trumped.jpg
-
All stand for "Hail to the Cheese."

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Putting image into a circle shape

Post by Klaus » Sat Nov 24, 2018 4:18 pm

Did you notice the questionmark at the end of my first sentence? 8)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”