[SOLVED] Testing mouseColor function

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Testing mouseColor function

Post by capellan » Tue Jan 15, 2019 11:53 pm

Bingo!
Changing the color profile to sRGB IEC61966-2.1
on Mac OSX is the solution in my own setup. :D

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Testing mouseColor function

Post by [-hh] » Tue Jan 15, 2019 11:55 pm

Richard wrote:An Alpha channel has no color, it merely determines the degree to which a color may be influenced by colors beneath it.
Not everything in this world is top down. That depends on the blend mode.

In LC's color model ARGB is the first byte of a 32 bit colored-pixel the "alpha" component.
And LC often creates a separate alpha channel from images of resizequality "best".

I dare say: There is no bug with the mouseColor on Mac.

From the dict entry to resizeQuality:
"best" : uses a bicubic filter-i.e.interpolation is done using cubic approximation from near pixels.
So, what should the mouseColor report?

Mac (the real hardware, not the virtual) has a display method different from Linux and Windows. The OS does not necessarily display what LC wants.
There is no "exact color value" that the mousecolor could report, it has always to estimate. Because you don't really wish to fill a large rect with the (interpolated and) antialising gray of one of the black pixels beside it.
Al wrote:Changing the color profile to sRGB IEC61966-2.1 on Mac OSX is the solution in my own setup.
Did you test this also with pixels that are not fully opaque?
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Testing mouseColor function

Post by FourthWorld » Wed Jan 16, 2019 12:02 am

[-hh] wrote:
Tue Jan 15, 2019 11:55 pm
So, what should the mouseColor report?
IMO the RGB value of the pixel from the composite display value. It's what I'm looking at. It seems less useful to try to account for all possible things in the various other buffers that were combined to ultimately produce the thing I'm looking at. I see a pixel on screen; it has a value; give me that value.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: [SOLVED] Testing mouseColor function

Post by [-hh] » Wed Jan 16, 2019 12:14 am

I see a pixel on screen; it has a value; give me that value.
That is the color of a fully opaque snapshot of size 1x1. You can have it by two lines of code.
I would like to have the color of the video buffer before the interpolation is applied, converted to a 32 bit ARGB color.
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [SOLVED] Testing mouseColor function

Post by FourthWorld » Wed Jan 16, 2019 12:19 am

[-hh] wrote:
Wed Jan 16, 2019 12:14 am
I see a pixel on screen; it has a value; give me that value.
That is the color of a fully opaque snapshot of size 1x1. You can have it by two lines of code.
I'll take it. Hopefully the team will fix whatever is needed in the mouseColor function.
I would like to have the color of the video buffer before the interpolation is applied, converted to a 32 bit ARGB color.
Perhaps a new HowTheMouseColorIsDerived function is needed?

How can that be determined for objects outside of LC?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Testing mouseColor function

Post by capellan » Wed Jan 16, 2019 1:05 am

[-hh] wrote:
Tue Jan 15, 2019 11:55 pm
Al wrote:Changing the color profile to sRGB IEC61966-2.1 on Mac OSX is the solution in my own setup.
Did you test this also with pixels that are not fully opaque?
Yes, I imported a screenshot of a group of two vector graphics
(Bouba-Kiki.svg) and the transparent alpha channel changes
the color value of the image pixels in the borders, not in
the solid and flat areas of the transparent bitmap.

By the way, Why LC put a transparent border around the screenshots?

Al
screenshot_transparent_border.png
Last edited by capellan on Wed Jan 16, 2019 1:17 am, edited 1 time in total.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: [SOLVED] Testing mouseColor function

Post by [-hh] » Wed Jan 16, 2019 1:14 am

And how do you get the 4 byte pixel color (incl. the alpha value) from the 3 byte mouseColor?
shiftLock happens

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: [SOLVED] Testing mouseColor function

Post by capellan » Wed Jan 16, 2019 1:19 am

The mousecolor does not provides the alpha channel value.
Just the pixel color under the cursor (or at least the
pixel color value that the OS report to the function).

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: [SOLVED] Testing mouseColor function

Post by [-hh] » Wed Jan 16, 2019 2:07 am

Yes. I know.
But the alpha value A can change without changing the RGB.
But that is then a different color (4 byte pixel color).
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [SOLVED] Testing mouseColor function

Post by FourthWorld » Wed Jan 16, 2019 2:23 am

[-hh] wrote:
Wed Jan 16, 2019 1:14 am
And how do you get the 4 byte pixel color (incl. the alpha value) from the 3 byte mouseColor?
I don't, since for anything outside of LC the alpha value would be a guess, and even within LC may not tell the whole story depending on other properties and antialiasing.

If I set the backColor of a graphic to gray50, the mouseColor reports 128,128,128.

If I then set the blendLevel of that graphic to 50 against a white card, the mouseColor then reports 191,191,191

So if a pixel is visibly 191,191,191, how do we know whether it was 128,128,128 with a 50% blend, or is actually a completely opaque pixel at 191,191,191? The observer cannot know what prior process may have been used to generate the color, only the resulting color.

Interactions between the assigned color, blendLevel, inks, graphic effects, or any other properties that affect rendering of that color no longer matter after the rendering process. What matters to the mouseColor fits what I'm looking for, the answer to the question: What is the RGB value of the pixel I'm looking at?

That's what I would expect. I would not expect it to add a fourth element which determines how the first three are transformed, only the result of the transformation.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: [SOLVED] Testing mouseColor function

Post by capellan » Wed Jan 16, 2019 8:17 pm

This stack demonstrate that mousecolor function
calculates the color of visible pixel, not
the color of the top object.

In this stack with a yellow background,
a flat orange rectangle is made gradually
transparent using an alpha channel.
Screen Shot 2019-01-16 at 3.14.57 PM.png
Al
Flat_color_plus_Alpha_channel.livecode.zip

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: [SOLVED] Testing mouseColor function

Post by [-hh] » Wed Jan 16, 2019 9:47 pm

The computed transformation of four bytes to fully opaque three bytes is NOT reversible except you have full information about the pixels underneath the computed one.
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [SOLVED] Testing mouseColor function

Post by FourthWorld » Wed Jan 16, 2019 10:54 pm

[-hh] wrote:
Wed Jan 16, 2019 9:47 pm
The computed transformation of four bytes to fully opaque three bytes is NOT reversible except you have full information about the pixels underneath the computed one.
True, the recipe for a cake is not a cake.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: [SOLVED] Testing mouseColor function

Post by [-hh] » Wed Jan 16, 2019 11:05 pm

RG wrote:True, the recipe for a cake is not a cake.
Fine allegory. Also related to mouse (sadly cheese is not allowed...)
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [SOLVED] Testing mouseColor function

Post by FourthWorld » Thu Jan 17, 2019 12:19 am

It occurs to me that the mouseControl function could be used to obtain the "recipe, so to speak, for a pixel, at least within a LiveCode window.

Rather than return an RGB value, it could return an array with the relevant properties needed to discern how the object is rendered.

Or if the RGB is all that's needed, it could return the fill color of the object with its blendlevel, perhaps converted to hex and appended as the Alpha value.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Multimedia”