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

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

Re: How to get the current brush color ?

Post by richmond62 » Thu Jun 03, 2021 8:14 am

https://youtu.be/kN9xP4aq3iA

Well done bogs: very impressive channel! 8)

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: How to get the current brush color ?

Post by kdjanz » Fri Jun 04, 2021 12:41 am

Sticking to LC you can use

Code: Select all

the colornames
and if you

Code: Select all

put the length of the colornames
into the message box, I found that LC understands 5390 colornames out of the box. Should be a good start.

In a former life I was an architect, and every office has a product library in a backroom somewhere that is filled with flooring, carpet, paint, plastic laminate etc. samples. Each of these products come in various colours - sometimes MANY colours (paint!) which each have a code and an English name. These names were a source of huge amusement and we all wondered who on earth came to the office each morning and dropped a tab of LSD, then toked up a big one and then sat down to name this year's set of colours. Some of the names very clearly had chemical help in their conception!

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

Re: How to get the current brush color ?

Post by richmond62 » Fri Jun 04, 2021 8:20 am

I found that LC understands 5390 colornames out of the box.
Well, be that as it may, when I did this:

Code: Select all

put the colornames into fld "COLOURS"
followed by this:

Code: Select all

put the number of lines of fld "COLOURS"
I got 552.

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

Re: How to get the current brush color ?

Post by bogs » Fri Jun 04, 2021 11:46 am

Heh, "length" ≠ the number of lines of the colorNames, whatever on earth made you use length? Length returns the number of characters in a string, so I am VERY sure that 500+ names could easily return 10x that in characters :D

As Richmond points out, the colorNames function puts the names on separate lines by default, from the msg box you could simply use

Code: Select all

put the number of lines of the colorNames

or, if you really wanted to get fancy, maybe even

Code: Select all

put the number of lines of the colorNames & " Color Names are in the following list:" & cr & cr & the colorNames
In any case, I completely agree with you, Lc provides more than enough color names. I wrote the utility I posted the link to there mostly because I thought it would be easier to actually see the color, and copy whatever values I needed from it, than it was to keep going back to the message box and get that information long hand from scratch each time.

Shockingly, it worked out rather well, if not overly attractive.
Image

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”