How to get the current brush color ?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

How to get the current brush color ?

Post by jmburnod » Tue Jun 01, 2021 9:04 am

Hi All,
Is there a way to get the current brush color ?
It seems brushcolor property is "set only".
Best regards
Jean-Marc
Last edited by jmburnod on Tue Jun 01, 2021 12:09 pm, edited 2 times in total.
https://alternatic.ch

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?

Post by bogs » Tue Jun 01, 2021 9:18 am

Code: Select all

put the brushColor
works here JM ?

Image
Image

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How to get the current brush color ?

Post by jmburnod » Tue Jun 01, 2021 9:44 am

Thanks Bogs
It works now.
First try was empty because brushcolor was empty. :oops:
Best
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to get the current brush color ?SOLVED

Post by richmond62 » Tue Jun 01, 2021 11:16 am

Partly solved, mainly because I'm stupid and cannot work out from RGB numbers what a colour looks like.

I can type this:

Code: Select all

set the brushColor to "red"
but if I type:

Code: Select all

put the brushColor
I always get an RGB set back.

It would be lovely if one could do this sort of thing:

*get the colorName of the brushColor*

and one would get "green", "blue" or whatever.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?SOLVED

Post by bogs » Tue Jun 01, 2021 12:02 pm

Um...
Image
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to get the current brush color ?

Post by richmond62 » Tue Jun 01, 2021 2:34 pm

Well, Yes . . .

BUT one cannot, for the sake of argument set the brushColor to 123,234,111
and then get it to return a colorname.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?

Post by bogs » Tue Jun 01, 2021 8:39 pm

For the sake of argument, do you know of somewhere else where you can translate the rgbColor into a colorName aside from brushColor in Lc ? Also, aren't there a limited number of colorNames, as opposed to rgb value combinations, hence there wouldn't be a colorName to correspond to every particular triplet value?

On the other hand, if you assign a colorName to a brushColor, I'm pretty sure that is what you'll get back, as demonstrated above.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to get the current brush color ?

Post by richmond62 » Wed Jun 02, 2021 9:22 am

do you know of somewhere else
This might be a good start:

https://www.color-blindness.com/color-name-hue/

"The list of colors comprises 1640 different color names" . . . cripes.

The snag about that website is that the chap who did the work cooked up some distinctly personal names, hence:
-
SShot 2021-06-02 at 11.25.37.png
-
SShot 2021-06-02 at 11.25.06.png
-

I can see it was made using Java script.

This is, also, not bad:

https://htmlcolorcodes.com/color-names/

However, nobody but nobody is going to cook up this number of names:
-
SShot 2021-06-02 at 11.29.16.png
-

https://web.njit.edu/~walsh/rgb.html

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?

Post by bogs » Wed Jun 02, 2021 9:37 am

richmond62 wrote:
Wed Jun 02, 2021 9:22 am
do you know of somewhere else
You seem to have left out a fairly important part of my question...
where you can translate the rgbColor into a colorName aside from brushColor in Lc ?
If all your looking for is a list of names you can translate rgbColor values into, I'm sure any random name generator will work for that, but I don't see how it would be any more helpful than just having the values.

I'm also not sure that using names is better than rgb values, I've seen some colorNames that are way off the mark or just plain silly, but I know for a given value approximately how bright or dark the red, green, and blue will turn out.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to get the current brush color ?

Post by richmond62 » Wed Jun 02, 2021 9:45 am

You seem to have left out a fairly important part of my question...
Indeed, I did not address it directly.

But I am sure that with a little bit of 'jiggery-pokery' one could use the resources from that website with the 1640 colour names
(or any one of the fairly large number that came up with a quick Ecosia web search) to set up
a look-up table that could be incorporated into a stack . . .

As I am a tableField fan one could have a tableField with 3 columns:

RGB
HEX
name

and the rest, as they say, would be "boot scoot and boogie."

[something wrong with that reference, I'm sure . . . 8) ]

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?

Post by bogs » Wed Jun 02, 2021 9:51 am

No, but don't you think this might not only be a better solution, but an easier one?

Image

Values don't help you, *names are arbitrary, but seeing the actual color should leave little doubt as to what your working with.


*Names - what does "AliceBlue" mean to you? To me, it suggests Alice should try to cheer up :P
Image

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?

Post by bogs » Wed Jun 02, 2021 9:57 am

richmond62 wrote:
Wed Jun 02, 2021 9:45 am
As I am a tableField fan one could have a tableField with 3 columns:

RGB
HEX
name

and the rest, as they say, would be "boot scoot and boogie."
You mean like this?

Image
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to get the current brush color ?

Post by richmond62 » Wed Jun 02, 2021 4:21 pm

You mean like this?
Just so!
-
blueMeanie.jpeg
blueMeanie.jpeg (10.71 KiB) Viewed 5032 times
-
Blue Meanie: an off-spectrum colour. 8)

https://youtu.be/ePaHG6g7uFw

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to get the current brush color ?

Post by jacque » Wed Jun 02, 2021 6:45 pm

I wouldn't mind having a copy of that chart. Where did you find it?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the current brush color ?

Post by bogs » Wed Jun 02, 2021 10:45 pm

jacque wrote:
Wed Jun 02, 2021 6:45 pm
I wouldn't mind having a copy of that chart. Where did you find it?
If you click the picture, you'll see exactly where I found it < I made it myself, it is part of the "15 minutes of LiveCode channel I host > :D

{ I suggest playing it back below 1x, possibly .75 or .5 even }
Image

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”