Reputation: 7150
Is it possible to combine two RGB
values to create another color in livecode
?
Example:
First color: (0,0,255) //BLUE
Second color: (255,0,0) //RED
In this case, I would like to store the result of the two colors into a variable.
Let's say, put "0, 0, 255" + "255, 0, 0" into CombinedColors
Upvotes: 2
Views: 1106
Reputation: 2435
It isn't exactly clear how you want to combine the colours. If you want to blend the colours, you might simply add them.
put 255,0,0 into myRed
put 0,0,255 into myBlue
put 0,10,100 into myGreen
repeat with x = 1 to 3
put min(item x of myRed + item x of myBlue + item x of myGreen,255) into \
item x of myNewColor
end repeat
The formula I'm using here doesn't make much sense. If you can more specific in your question, I'll be able to adjust my answer with a better formula.
You may also use weighted values:
put min(.333*item x of myRed + .333*item x of myBlue + .334*item \
x of myGreen,255) into item x of myNewColor
You can adjust the weights to make the blend appear more natural. (This example is with 3 colours, to demonstrate the weights).
Upvotes: 1
Reputation: 1164
For combining 2 colours using RGB values, there are 2 ways.
If you need a lighter texture, the formulae you need to use is
(r1, g1, b1) + (r2, g2, b2) =
(min(r1+r2, 255), min(g1+g2, 255), min(b1+b2, 255))
If you need a slightly darker texture , use
(r1, g1, b1) + (r2, g2, b2) =
((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2)
Or if you just want to avoid the hassle , use this simple online tools http://meyerweb.com/eric/tools/color-blend/
Upvotes: 1