colour scheme

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

colour scheme

Post by bsouthuk » Thu Aug 25, 2016 12:14 pm

Hi

I have 9 different fields in a card and I'd like the colour scheme to be different when i click on certain buttons.

Button A for example, I'd like the fields to follow the the following field colour scheme: 0,5,64; 88,129,180; 102,145,199; 125,165,216; 147,185,232;175,203,237;198,217,241; 214,231,252; 240,244,250 which is a variation of blue

If I press Button B, I'd like the field background colours to follow a similar scheme but in red. And so on...

Is this possible with a few lines of code?

Help is much appreciated.

Cheers

Daniel

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: colour scheme

Post by dunbarx » Thu Aug 25, 2016 2:01 pm

Hi.

On a new card make three buttons and three fields. I am old-fashioned. Put this in the card script:

Code: Select all

on mouseUp
   if "button" is in the name of the target then
      put "red","green","blue" into tColorList1
      put "yellow","orange","purple" into tColorList2
      put "green","red","orange" into tColorList3
      do "get tColorList" & the number of the target
      repeat with y = 1 to 3
         set the backColor of fld y to item y of it
      end repeat
   end if
end mouseUp
Click on some buttons. This is just one way to accomplish what I think you are after, that is, a way to reference different color schemes based on a control reference. The "do" construction is what is old-fashioned. I took a shortcut in using the button numbers as references. This can be changed...

You can avoid the "do" construction if you list your color scheme explicitly, say in a custom property of each button. In that way, there is no need to deconstruct the contents of a variable. You can read the color data directly. I just like "do".
Craig Newman

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: colour scheme

Post by bsouthuk » Thu Aug 25, 2016 2:33 pm

Perfect, thank you very much for your help!

Post Reply

Return to “Talking LiveCode”