ID:2419895
 
So... I feel like there should be a simple way to do this, but I cant seem to find it.

I'm trying to find a way to "mix" 2 icons in a specific way...

Basically I need to take the colors of 1 icon and apply it to another icon.

https://i.imgur.com/p1JQrvj.png
Here's an example of what I want to do. I want to take the icon on the left, the blue/white pattern, and apply it to the player icon in the middle, and result in the same shape as the player icon but using the colors of the 1st icon.

Blend() doesn't seem to have an option for that.

Add/And/Subtract/Multiply will give me the shape that I want, but it combines the colors of the 2 icons which I dont want.

Or/Overlay/Underlay don't change the shape of either icon.

The other option I was thinking of was to use the add or subtract option in blend after turning the player's icon in to either solid white or solid black. But as far as I know, I would need to use SwapColor() for this and SwapColor() doesn't seem to have an option to change all colors in an icon in to 1 specific color, I would basically have to run the proc 255^3 times to make it a solid color which doesn't seem ideal.

Am I overlooking any simpler ways to do this?
You can add full-white to an icon to make it full-white. No need for SwapColor.
    Zexal_Test(mob/M as mob in world)
set desc = "Test Zexal Overlay"
set category = "Testing"

world << "DEBUG: Zexal Test Start"

var/obj/zexal/overlay/O = new()
var/obj/zexal/glow_a/G1 = new()
var/obj/zexal/glow_a/G2 = new()

world << "Objects Made"
sleep(5)

var/icon/P = icon(M.icon)
var/icon/new_icon = new

for(var/state in P.IconStates())
if(state == "[M.icon_state]")
new_icon.Insert(icon(P, state), state == "[M.icon_state]" ? "" : state,,,1)



world << "Player Icon extracted"
sleep(1)

var/icon/R = icon('96x96_red.dmi')
var/icon/W = icon('96x96_white.dmi')
var/icon/zx = icon('zexal_red.dmi')
var/icon/glow_s = icon(new_icon)
var/icon/glow_l = icon(new_icon)

world << "Icon Vars Created"
sleep(1)

glow_s.Blend(W,ICON_SUBTRACT)
glow_s.Blend(R,ICON_ADD)

world << "Small Scale Blend Applied"
sleep(1)

glow_l.Blend(W,ICON_ADD)

world << "Large Scale Blend Applied"
sleep(1)

new_icon.Blend(W,ICON_SUBTRACT)
new_icon.Blend(zx,ICON_ADD)

world << "Zexal Blend Applied"
sleep(1)

O.icon = icon(new_icon)
G1.icon = icon(glow_s)
G2.icon = icon(glow_l)

world << "Objects Assigned Icons"
sleep(1)

O.alpha = 0
O.pixel_x = M.pixel_x
O.pixel_y = M.pixel_y
O.layer = M.layer+1

G1.alpha = 0
G1.pixel_x = M.pixel_x-2
G1.pixel_y = M.pixel_y-2
G1.layer = M.layer-1

G2.alpha = 0
G2.pixel_x = M.pixel_x-4
G2.pixel_y = M.pixel_y-4
G2.layer = M.layer-2

world << "Objects assigned stats"
sleep(1)

O.Move(locate(M.x-1,M.y,M.z))
G1.Move(locate(M.x-2,M.y,M.z))
G2.Move(locate(M.x-3,M.y,M.z))

world << "Objects moved to player location"
sleep(1)

O.alpha = 255
G1.alpha =255
G2.alpha =255
world << "Alpha Set"

sleep(10)

var/icon/g1i = icon(G1.icon)
var/icon/g2i = icon(G2.icon)

g1i.Scale(4 + g1i.Width(),4 + g1i.Height())
g2i.Scale(8 + g2i.Width(),8 + g2i.Height())
G1.icon = g1i
G2.icon = g2i

world << "Scaling Applied"


return


https://i.imgur.com/FW8LXJ5.png

So I've played around with a few procs here and there and im getting close to what I need but I'm running in to a few problems.

1st off...

I'm able to blend the icons together and get my visual effect cropped out in to the shape of the icon, but I lose the animation to it. I'm sure it has something to do with how im using the Insert() proc in the code above but im not entirely sure how.

I think I need to find a way to extract just the 1st frame of the player's state and apply the animation. Pretty sure right now I'm applying it as a movement state which is stopping the animation from happening.

2nd...

I'm having some issues with the the Scale() proc, though more specifically, I think im having issues with the Width() and Height() procs in the Scale Proc. They seem to be returning a 0 or a null value instead of the actual width/height of the icon. "4 + g1i.Width()" isn't reading the actual Width of the icon and I'm just getting a 4.

What I'm trying to do here is overlay that visual animation on the player, and then make a slightly larger version of their icon that is all red and a slightly more larger version that is all white and layer layered under the player to give a sort of glowing effect to the player.

I have to read the width and height of the icons because there are some icons in the game that players can use that are larger than 32x32 so they could be up to 96x96

Anyone have any solutions for either of these issues?

And for clarification... the icon files listed above...

96x96_red.dmi is a 96x96 red square with a blank state name

96x96_white.dmi is the same but white.

zexal_red.dmi is a 96x96 animation with a blank state name that's 15 frames long.
https://i.imgur.com/8KmqNMt.png

Alright. Was able to get things working more or less how I want them. Im actually pretty proud of how things turned out.

Those effects shown in the picture. The red/blue glows on the icons in the 2nd picture, the rainbow pixelated pan-in on the 3rd picture, and then the yellow fire aura in the 4th picture are generated dynamically and can be applied to any icon run through the proc as long as its within a certain dimension limit limit.