ID:2346179
 
(See the best response by Kaiochao.)
Hello,

I was curious if there was a way to make a specific color of an icon animate. I know we've gotten further with allowing color to be changeable using the color matrix. I could've sworn MapColors() allowed me at one point to change specific colors to something else but now I'm thinking it may of been SwapColor. Basically I'm curious if you can animate a black outline to any color for various powerups. Something kinda like the following where I swap a black outline to red? I know a proc isn't possible within animate but maybe a color matrix could help achieve a similar effect which I'm terrible at.

Code:
mob/proc/GlowRed()
while()
animate(src,color = SwapColor(rgb(0,0,0),rgb(255,0,0)),time = 10)
sleep(10)
animate(src,color = null,time = 10)
sleep(10)


Best response
You could use a filter for the outline instead of having as part of the icon. You could then animate the outline filter's color. Filters are a 512 beta feature, though.

It's not possible to have a color matrix that only affects a specific part of any given icon.
Thanks, I guess I'll wait for 512 and experiment with this again. Appreciate the insight.
As long as you're not going to wait for the beta, there is one way to get a color matrix to just effect one part of an icon, but it only works in limited cases. The idea is that you treat your icon like three different icons based on color channels, and then apply a different color to each channel.

In your case, you'd create an icon that was all red (different shades from black to "#f00") with a blue "#00f" outline. Then you'd apply the color matrix:

color = list(
"#nnn", // Color to apply to the red channel
"#000", // We're not using the greeen channel
"#NNN", // Color of the outline
)

The resulting icon will be monochrome with a colored border. Once you get used to the idea of how that works, you can include the greeen channel to add extra color. In many simple cases you can achieve a graphic that's just as colorful as the original.

Because of the attention to detail needed when creating the graphic, this isn't a solution I'd recommend for larger games like RPGs where all the classes have their own icons. For simpler games where everyone has the same icon, it can be a great solution.
You could also draw the outline as a different state outright and use a color matrix on that. This way you could also have white/black as a part of the outline. Just draw the outline the way you want it to appear when it's #f00 red. Then the color matrix winds up like this:

//Let's set the color to "#08f" rgb(0, 136, 255), which is cyan
var/r = round(0/255, 0.1)
var/g = round(136/255, 0.1)
var/b = round(255/255, 0.1)
color = list(r,g,b, 1-r,1-g,1-b, 0,0,0) // list(0,0.5,1, 1,0.5,0, 0,0,0)
Thank you both for your incite as well. This gives me something to think about in terms of design and what I could use it for.