ID:149426
 
The code below works fine. However, it doesn't do exactly what I want it to and I'm not sure how to change that...

This code will give me four different versions of an icon -- the original plus four darker shades. However, I don't want to darken the RGB values equally... I want the red to fade a lot faster than the green or blue. So what I really want is something like this:

L[2] = myAtom.icon * rgb(0.6, 0.9, 0.9)

Is there any way to do that in BYOND? The icon arithmetic help seems to indicate it isn't (and trying it just gave me black icons), but I figured I'd ask.


proc/RegisterIcon(atom/myAtom)
var/L[5]
L[1] = myAtom.icon
L[2] = myAtom.icon * 0.9
L[3] = myAtom.icon * 0.8
L[4] = myAtom.icon * 0.7
L[5] = myAtom.icon * 0.6
IconRegistry[myAtom.type] = L
Gughunter wrote:
The code below works fine. However, it doesn't do exactly what I want it to and I'm not sure how to change that...

This code will give me four different versions of an icon -- the original plus four darker shades. However, I don't want to darken the RGB values equally... I want the red to fade a lot faster than the green or blue. So what I really want is something like this:

L[2] = myAtom.icon * rgb(0.6, 0.9, 0.9)

Is there any way to do that in BYOND? The icon arithmetic help seems to indicate it isn't (and trying it just gave me black icons), but I figured I'd ask.

This has been in since about the earliest 307 beta. Supply the rgb like a normal rgb() value set, 0-255:
L[2] = myAtom.icon * rgb(153, 230, 230)

Alternatively, you can use the new /icon class:
var/icon/ic = new /icon(myAtom.icon)
ic.Blend(rgb(153, 230, 230), ICON_MULTIPLY)
L[2] = fcopy_rsc(ic)

/icon is good to use if you do a lot of icon arithmetic, particularly if you want to do a lot of arithmetic before assigning the final icon.

Lummox JR
In response to Lummox JR
This has been in since about the earliest 307 beta. Supply the rgb like a normal rgb() value set, 0-255:
L[2] = myAtom.icon * rgb(153, 230, 230)


Thanks for the info! Unfortunately, I made the change (and no other changes) and now I'm getting black icons for all but the original again. Maybe I'll play with the icon blending thing tonight and see if that does the trick.

proc/RegisterIcon(atom/myAtom)
var/L[5]
L[1] = myAtom.icon
L[2] = myAtom.icon * rgb(220,240,240)
L[3] = myAtom.icon * rgb(200,220,220)
L[4] = myAtom.icon * rgb(180,200,200)
L[5] = myAtom.icon * rgb(160,180,180)
IconRegistry[myAtom.type] = L