Well, we want some RGB (HEX) operations like:
Add color (will add two RGB colors)
Multiply color (will multiply two colors)
Red, Blue, Green, Alpha (each function will extract the color's component)
The last one is the most important to me since I'm stuck here:
changecolor(cx as color)
var/icon/I=new(icon)
I.MapColors(cx.r,cx.g,0,0,cx.g,cx.b,cx.r,0,cx.b)
looks like i can't extract the red component (or the blue or green.)
ID:2130483
Aug 11 2016, 6:39 pm
|
|||||||
| |||||||
Aug 11 2016, 6:57 pm
|
|
Do you know about color matrices?
|
Not very much but what i know is that there isn't even a way to convert color HEX to color matrix. And the verb input only returns HEX.
|
In response to MKG
|
|
By HEX do you mean hexadecimal color codes, like "#rrggbbaa"? Those are automatically converted to a color matrix when the atom.color variable is assigned to them. You can read the elements as a list to get the RGB components as numbers.
You shouldn't be using /icon objects if you just want to recolor something in-game, unless you're making some kind of custom icon editor, or need to save the modified icons as files. |
I don't know how to assign the atom.color.
Also, how i do extract each component of the color? |
Well, I've found a way anyways, I had to do my function manually.
First, I declared this global variable var/global/hex=list("0"=0,"1"=1,"2"=2,"3"=3,"4"=4,"5"=5,"6"= 6,"7"=7,"8"=8,"9"=9,"a"=10,"b"=11,"c"=12,"d"=13,"e"=14,"f"=1 5) Then I used this to get the red component hex[copytext(colour,2,3)]*16+hex[copytext(colour,3,4)] Now that I made the procs, You can download the code: https://www.dropbox.com/s/6d33957grj9lvqs/hexcolors.dm?dl=0 (Fixed) |