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

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

"opaque pixels"

Post by Samuele » Fri Jan 21, 2022 10:38 am

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: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 » Fri Jan 21, 2022 1:52 pm

There is no "way" as it happens automatically:
-
Pixels.jpg
Attachments
Pixels.livecode.zip
Here's the stack.
(207.58 KiB) Downloaded 149 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: "opaque pixels"

Post by dunbarx » 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.

Craig

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

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 4:01 pm

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: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: "opaque pixels"

Post by dunbarx » Fri Jan 21, 2022 4:17 pm

Not near my computer.

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

Craig

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

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 4:40 pm

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: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 » Fri Jan 21, 2022 5:21 pm

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: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 5:43 pm

richmond62 wrote:
Fri Jan 21, 2022 5:21 pm
There 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: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 » Fri Jan 21, 2022 5:50 pm

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: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 5:53 pm

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: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: "opaque pixels"

Post by jacque » 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 7:34 pm

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: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: "opaque pixels"

Post by richmond62 » Fri Jan 21, 2022 7:38 pm

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: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 8:01 pm

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: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: "opaque pixels"

Post by Klaus » Fri Jan 21, 2022 8:24 pm

@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 142 times

Post Reply