This library handles the overhead for processing icons. If you want to run a custom operation of every pixel of every icon state in an icon, there are lots of loops and other things you need to write. This library handles all of that.
The library works by providing the IconProcessor datum which contains procs for manipulating icons. It has procs that are automatically called for every icon state and for each pixel - all you have to do is override these procs to define the operation you want to perform. The IconProcessor object also has procs to perform useful operations (interpolation, sampling, etc.).
To change the opacity of an entire icon, here's all you have to do:
parent_type = /IconProcessor
opacity = 0
opacity = o
// to apply the fade effect we process each state
// pixel by pixel.
// output the icon, state name, direction, and frame number
// get the color at the current x/y
var/Color/c = get(x, y)
// if the pixel isn't already more than transparent
// than desired, set its alpha value.
if(c.a > opacity)
c.a = opacity
And to run it:
// create an instance of the fade processor that makes the
// icons 20% opaque
var/Fade/fade = new(0.2)
// process the sample icon
var/icon/result = fade.process('icon-processor-demo-icons.dmi')
// save the result as "fade.dmi"
src << ftp(result, "fade.dmi")