"opaque pixels"

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm

"opaque pixels"

Post by Samuele »

Hi, is there a way to activate "mouseDown" only if the user clicks on the "opaque pixels" of the object?
Thanks!
Samule.
Samuele.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 »

There is no "way" as it happens automatically:
-
Pixels.jpg
Attachments
Pixels.livecode.zip
Here's the stack.
(207.58 KiB) Downloaded 253 times
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: "opaque pixels"

Post by dunbarx »

I believe there is a property, “the mouseColor”, or something like that. I am not near my computer.

Anyway I think it it empty if the cursor is over an “empty” pixel.

Craig
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

dunbarx wrote: Fri Jan 21, 2022 3:57 pm I believe there is a property, “the mouseColor”, or something like that. I am not near my computer.
Anyway I think it it empty if the cursor is over an “empty” pixel.
No, "the mousecolor" will not be empty but return the color of the object behind the object with the opaque pixels, usually the card.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: "opaque pixels"

Post by dunbarx »

Not near my computer.

But then there is a property that returns the “pixelColor”. What is it?

Craig
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

Hm, did not find "pixelcolor" in the dictionary?!
And not in the old Metacard index (dictionay) either.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 »

There is no need to fuss about this as a PNG image containing transparent areas
will only 'catch' mouse messages when the end-user interacts with the opaque
part of the image, as my example stack above demonstrates.
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

richmond62 wrote: Fri Jan 21, 2022 5:21 pmThere is no need to fuss about this ...
Who are you and what have you done to richmind62? :shock:
richmond62 wrote: Fri Jan 21, 2022 5:21 pm ... as a PNG image containing transparent areas will only 'catch' mouse messages when the end-user interacts with the opaque part of the image, as my example stack above demonstrates.
Yes, we already understood this, I was only anwering Craigs questions.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 »

richmind62
only anwering Craigs
and who are you, and what are you 'on' with those mistakes . . . :D

If you want to be "clever" you could have a one pixel image that was always at the mouseLoc and
then use intersect . . . :roll:
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

You should see "richmind62" as an accolade, Sir! :wink:
And I don't want to be clever, I AM clever! 8)
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: "opaque pixels"

Post by jacque »

richmond62 wrote: Fri Jan 21, 2022 5:21 pm a PNG image containing transparent areas will only 'catch' mouse messages when the end-user interacts with the opaque part of the image
Samuele, this is the answer. If the image has an alpha channel, like PNG does, then it will do what you want.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

jacque wrote: Fri Jan 21, 2022 6:52 pm
richmond62 wrote: Fri Jan 21, 2022 5:21 pm a PNG image containing transparent areas will only 'catch' mouse messages when the end-user interacts with the opaque part of the image
Samuele, this is the answer. If the image has an alpha channel, like PNG does, then it will do what you want.
But Samuele actually wants the opposite!
He wrote:
...
is there a way to activate "mouseDown" only if the user clicks on the "opaque pixels" of the object?
...
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 »

No: he does not want the opposite.

In my example stack the opaque pixels constitute the image,
while the transparent ones inwith the image's bounding rectangle are
transparent.
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

If we click on a tranparent pixel in an image, LC does not see this pixel, but the one below it.
So we cannot have "mousedown" here! if we add a mousedown handler to the image, this will
only get executed when clicking a non transparent pixel.

You demonstrated this nicely with your example stack, only "mousedown" in the card script
will get fired when clicking a tranparent pixel.
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus »

@Samuele,

this stack will do what you want, check the card script and the script of the image.


Best

Klaus
Attachments
Pixels2.livecode.zip
(207.53 KiB) Downloaded 238 times
Post Reply