Hello, I think this is a very basic question but I don’t know how to find the answer.
I make variables for color:
col1 = 128
col2 = 45
col3 = 89
and then I put them together
to put them into the fill command but I need commas fill(128,45,89)
If I do it this way: colo= col1,col2,col3 it wont work (it just takes the first numbers, before comma) and I know why, because (the comma is a string?) however, no number.
Ok, I can use
COLOR = col1,col2,col3
This seemed to be a solution (I don’t get an error) but it just takes the first value, so there is still something wrong.
Ok, it works via
color( , , , ,)
What I don’t understand in the reference is that I should have to int color.r g and b, but this seems to work automatically and if I put this in the setup, I get errors
For what is COLOR good for? It’s not listed in the reference, so is it obsolete or dead?
@bllr When you do COLOR=col1,col2,col3 you’re creating a variable named COLOR and assigning whatever col1 is to COLOR.
As for color.r, not everything you see in the reference is legit. A lot of changes have been made to Codea over the years and the reference hasn’t been updated exactly to reflect everything.
Is there another way to combine
(value with ,)
or something similar to color()?
For example xy(0,0)?
@bllr It all depends if the command supports the use of commas. You can set variables with values and commas by doing var1,var2,var3=23,56,23 . But as for other things, look at the code in the Examples and Craft folders and see how thing are done in those programs to get ideas.
@dave1707 Thank you, vec is this what I was looking for
To make and store a single colour, use the
myColour = color(col1, col2, col3)
You can then use
myColour wherever you might have used the three numbers individually, so
fill(col1, col2, col3)
fill(128, 45, 89)
will all achieve the same thing.
If you want to modify an existing colour then you can change its red, green, and blue (and alpha) components individually by accessing them directly:
myColour.r = 192
changes just the red channel.
vec4 are the same thing but for your code I recommend treating them as if they were different.