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:
Fade
parent_type = /IconProcessor
var
opacity = 0
New(o)
opacity = o
// to apply the fade effect we process each state
// pixel by pixel.
state()
per_pixel()
// output the icon, state name, direction, and frame number
show_progress()
pixel()
// 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
return c
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")
The template object's add_state() proc can also take a number of directions (1, 4, or 8) and the number of frames of animation. This way you can generate directional icons or animated icons if you'd like.