is a color
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
is a color
It tried testing input for "is a color"
I found "255,255,1000" returns true.
It this expected?
Should rgb colors return true when they have a value that is out of range, such as >255 for in individual value?
I found "255,255,1000" returns true.
It this expected?
Should rgb colors return true when they have a value that is out of range, such as >255 for in individual value?
gmcrev
Re: is a color
You might want to look at this lesson. In particular,
I suspect that 3 separated values = some sort of valid color reference.if pColorName is an RGB triplet, the function just returns that triplet, so we don't try to make sure that pColorName is a color name, just that it's some sort of valid color reference.
-
- VIP Livecode Opensource Backer
- Posts: 9833
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: is a color
What happens if you attempt to set the color of an object to that value?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 9375
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: is a color
If one does something like this:
set the backGroundColor of graphic "MyShape" to 255,255,1000
it sets the backGroundColor of graphic "MyShape" to 255,255,235
for the rather obvious reason that 1000 - (3 x 255) = 235
This does not, however, explain why one ended up with 255,255,1000 in the first place.
set the backGroundColor of graphic "MyShape" to 255,255,1000
it sets the backGroundColor of graphic "MyShape" to 255,255,235
for the rather obvious reason that 1000 - (3 x 255) = 235
This does not, however, explain why one ended up with 255,255,1000 in the first place.
Re: is a color
I was testing to see if I need to do any custom validation for an input field for a color and just added a 0 to the end value, expecting it to be invalid.
Who was to know that "is a color" would allow rgb values out of range.
Further to that who would know that setting a backcolor to an rgb value that was out of range would work since it seems to do an automatic mod 255 on each numeric rgb value.
If someone knows exactly what is happening it would be nice to add this knowledge to the dictionary wherever RGBcolor parameters are mentioned.
A similar thing happens with dateitems which makes it very useful when performing numeric additions to individual values within RGB color and dateitems such that there is no need to worry about going out of range since it is taken care of automatically.
Who was to know that "is a color" would allow rgb values out of range.
Further to that who would know that setting a backcolor to an rgb value that was out of range would work since it seems to do an automatic mod 255 on each numeric rgb value.
If someone knows exactly what is happening it would be nice to add this knowledge to the dictionary wherever RGBcolor parameters are mentioned.
A similar thing happens with dateitems which makes it very useful when performing numeric additions to individual values within RGB color and dateitems such that there is no need to worry about going out of range since it is taken care of automatically.
gmcrev
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: is a color
Obviously we have:
Each comma delimited-list of three integers is a color.
This has its own logic:
The following color setting algorithm is used by LC for each input integer, making any input of three integers to a color.
If abs(<integer>) > 255 then it is taken modulo 255.
If the result or <integer> is negative then 255 is added.
Example.
"500,-1000,-1" is converted to the valid color "245,20,254" because
1. 500 mod 255 = 245,
2. -1000 mod 255 = -235 and -235 + 255=20,
3. -1 + 255 =254.
This may not be the conversion you want because you obviously think of
the cutting method min(255, max(0, <integer>)),
which would convert "500,-1000,-1" to "255,0,0".
But the LC modulo method makes also sense for some color handling procedures.
And the handling of negative integers in range [-255,-1] by adding 255 makes the same good sense as counting chars from the end of a string by using negative integers.
Each comma delimited-list of three integers is a color.
This has its own logic:
The following color setting algorithm is used by LC for each input integer, making any input of three integers to a color.
If abs(<integer>) > 255 then it is taken modulo 255.
If the result or <integer> is negative then 255 is added.
Example.
"500,-1000,-1" is converted to the valid color "245,20,254" because
1. 500 mod 255 = 245,
2. -1000 mod 255 = -235 and -235 + 255=20,
3. -1 + 255 =254.
This may not be the conversion you want because you obviously think of
the cutting method min(255, max(0, <integer>)),
which would convert "500,-1000,-1" to "255,0,0".
But the LC modulo method makes also sense for some color handling procedures.
And the handling of negative integers in range [-255,-1] by adding 255 makes the same good sense as counting chars from the end of a string by using negative integers.
shiftLock happens
Re: is a color
Makes sense to me. Sure glad you could explain it, cause I know I wouldn't have been able to.
-
- Livecode Opensource Backer
- Posts: 9375
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: is a color
I'm just glad I had a glass of rather decent red wine to hand when I read that postingSure glad you could explain it
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: is a color
@Richmond.
A glass of wine is also for me good for thinking about colors ...
What was the fill of the glass after reading: 50% or -50%? Half full or half empty?
[@all.
What's nice with that is that the inverse of a color (r, g, b) is (-r, -g, -b),
where r,g,b are integers in range [0,255] and not equal to zero.
TMHO easier to understand for a child than (255-r, 255-g, 255-b).]
A glass of wine is also for me good for thinking about colors ...
What was the fill of the glass after reading: 50% or -50%? Half full or half empty?
[@all.
What's nice with that is that the inverse of a color (r, g, b) is (-r, -g, -b),
where r,g,b are integers in range [0,255] and not equal to zero.
TMHO easier to understand for a child than (255-r, 255-g, 255-b).]
shiftLock happens
Re: is a color
I don't know about his glass, but my hookie was about 50% water and 150% whacky tobaccy[-hh] wrote: ↑Wed Feb 14, 2018 7:26 pm@Richmond.richmond62 wrote: ↑Wed Feb 14, 2018 6:43 pmI'm just glad I had a glass of rather decent red wine to hand when I read that postingbogs wrote:Sure glad you could explain it
A glass of wine is also for me good for thinking about colors ...
What was the fill of the glass after reading: 50% or -50%? Half full or half empty?
-
- Livecode Opensource Backer
- Posts: 9375
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: is a color
Red wine or whacky baccy?hh, could you add something about that to the dictionary?
Re: is a color
Just picturing the entry in the dictionary under 'whackyTobaccy' made me shoot coffee from my noserichmond62 wrote: ↑Thu Feb 15, 2018 6:48 pmRed wine or whacky baccy?hh, could you add something about that to the dictionary?
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: is a color
Schrodinger's glass is half-empty *and* half-full until the winefunction collapses.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: is a color
Is that the one where it doesn't collapse as long as you don't drink...erm...look at the glass? Or was that cats? Maybe I'm confuzzled