Page 1 of 2
is a color
Posted: Wed Apr 10, 2024 11:45 am
by Zax
I'm a little confused about the results of "is a color" in LC 9.6.11
According to the inline dictionary example, "
red" is indeed a color but I have doubts about the relevance of
4520 for example.
In my opinion,
4520 is more of an integer.
returns YES
Code: Select all
if 4520 is a color then put "YES" else put "NO"
if "4520" is a color then put "YES" else put "NO"
if 0 is a color then put "YES" else put "NO"
if "0" is a color then put "YES" else put "NO"
returns NO
Code: Select all
if "" is a color then put "YES" else put "NO"
Re: is a color
Posted: Wed Apr 10, 2024 11:51 am
by richmond62
Maybe colours have numbers assigned to them.
Mind you 4250 does NOT look like an rgb code.
Re: is a color
Posted: Wed Apr 10, 2024 12:08 pm
by Klaus
Code: Select all
set the backcolor of btn 1 to 4520
Results in BLACK, RGB 0,0,0
Code: Select all
set the backcolor of btn 1 to 0815
Results in BLACK, RGB 0,0,0
However:
Code: Select all
set the backcolor of btn 1 to 125889963
Results in WHITE, RGB 255,255,255
Obiously LC treats all (not RGB or Hex) numbers < XXX as BLACK and
all numbers >= XXX to white. But what might the value of XXX be?
Best
Klaus
Re: is a color
Posted: Wed Apr 10, 2024 12:37 pm
by Zax
I suppose it's for vanilla Hypercard compatibility: what is not white is black

Re: is a color
Posted: Wed Apr 10, 2024 1:52 pm
by dunbarx
Now I am confused. The dictionary states:
Colors can be referred to by color name, HTML -style specification, or as three comma-separated numbers between zero and 255 (one for each of red, blue, and green).
so "red" would do here, as would "222,111,000"
Where do we get the idea that an
integer belongs to any of the above criteria?
Craig
Re: is a color
Posted: Wed Apr 10, 2024 1:57 pm
by richmond62
Where do we get the idea that an integer belongs to any of the above criteria?
I didn't get that idea.
But the proof of the pudding is in the eating.
Doing something like this:
Code: Select all
on mouseDown
set the backGroundColor of grc "xyz" to 231
end mouseDown
ends up with this:
-
-
interestingly enough this:
Code: Select all
on mouseDown
set the backGroundColor of grc "xyz" to 200, 45
end mouseDown
throws a bluey.
Re: is a color
Posted: Wed Apr 10, 2024 10:18 pm
by bn
richmond62 wrote: ↑Wed Apr 10, 2024 1:57 pm
Code: Select all
on mouseDown
set the backGroundColor of grc "xyz" to 231
end mouseDown
The other day I stumbled across this hidden feature.
You can indicate a color as a single digit from 0 to 255
Probably a remnant of 256 color monitors.
Code: Select all
on mouseUp
local tHeight, tWidth, tName, tColorCounter
reset the templateGraphic
set the rect of the templateGraphic to 0,0,10,10
set the style of the templateGraphic to "Rectangle"
set the opaque of the templateGraphic to true
put 10 into tHeight
put 10 into tWidth
put 0 into tColorCounter
repeat with i = 0 to 15
repeat with j = 0 to 15
put "g" & tColorCounter into tName
create graphic tName
set the backgroundcolor of graphic tName to tColorCounter
add 1 to tColorCounter
set the left of graphic tName to j * tWidth
set the top of graphic tName to i * tHeight
end repeat
end repeat
end mouseUp
gives you a 16 by 16 color table with colors from 0 to 255
Kind regards
Bernd
Edit: see also
export image [with metadata metadata] to {file filePath | container} as {gif | png} with colorCount color [optimized] palette
Re: is a color
Posted: Thu Apr 11, 2024 2:38 pm
by dunbarx
All.
I opened another thread here, "Strange Colors", which should have been an extension of this thread. It was due to an error I made as regards another forum.
Perhaps these two can be joined together?
Craig
Re: is a color
Posted: Thu Apr 11, 2024 3:27 pm
by Zax
I understand a color can be defined as a single digit from 0 to 255 but but I still think that the "is a color" test returning true for an integer is not very useful and can even lead to errors.
Or else, a sort of “is an RGB color” test should be implemented.
Re: is a color
Posted: Thu Apr 11, 2024 3:48 pm
by richmond62
If the "is a color" test returned 'Yes' for numbers only between 0 and 255/6 that might make a bit more sense.
Re: is a color
Posted: Thu Apr 11, 2024 4:29 pm
by dunbarx
No.
Simply update the dictionary to include that format as a valid reference. Then the "is a" no longer causes angst.
What the integers refer to is another story since only a tiny fraction of colors (255 out of sixteen million) are included, and there seems little method to them. Bernd is likely correct in stating that it is a forgotten leftover from early days.
Craig
Re: is a color
Posted: Thu Apr 11, 2024 4:56 pm
by richmond62
-
Seemingly pretty random.
Re: is a color
Posted: Thu Apr 11, 2024 5:26 pm
by dunbarx
Richmond.
Seemingly pretty random.
No, look at your display again. There is a pattern that repeats, sort of, every 36 integer values. My stack output shows this, and your color display does as well, just graphically. Find the "white" squares. You can see six groups in succession, even though those groups are not quite the same. And after 216, the start of the seventh group, all bets are off, the sequences go off the rails.
Craig
Re: is a color
Posted: Thu Apr 11, 2024 7:03 pm
by richmond62
It would be interesting to know the numbers and colours way back when we all thought that sixteen squared was a vast number.
And, Yes, there is a sort of periodicity visible in my snapshot.
Re: is a color
Posted: Thu Apr 11, 2024 7:16 pm
by dunbarx
Richmond.
The real question is "why 36"? It really does not matter, since a mapping is a mapping, but there seems no binary pattern involved.
Craig