Get Flat Icon
Created by David "DarkCampainger" Braun
Released under the Unlicense (see Unlicense.txt)
Version 2.0 - August 27, 2013
Please see 'demo/demo.dm' for the example usage
Summary

The Get Flat Icon library flattens an object's appearance into a single dynamic icon at runtime. The icon can then easily be shown in a browser, output, label, ect.

The library fully supports all types of overlays: icon files, icon states, objects, object types, images, dynamic icons, and images with dynamic icons. It correctly handles inheriting the icon, icon_state, and dir* from the base mob; as well as FLOAT_LAYER. It can even handle pixel_x/y values that move overlays outside of the base icon's bounds.

The library also has a fully functional cache, to avoid flattening the same icon twice.

(*note: there is a limitation with the dir variable where the library cannot distinguish between an overlay that inherits its direction from its parent and one that is set to face SOUTH. If an overlay's direction is set to SOUTH, the library will always assume it inherits from the parent)

Reference
getFlatIcon(atom/A, dir, cache=1)
Return value: /icon object
Parameters:
  • atom/A - the atom you want a flattened icon of
  • dir - the direction you want the atom rendered in (defaults to current direction)
  • cache - determines how the cache is used (default 1)
    • 0 - Cache is ignored and not written to
    • 1 - Cache is checked
    • 2 - Cache is not checked, but generated icon is written to it
Version History
Version 2 (August 27, 2013)
Improved handling of overlays that inherit directions, as much as can be done
Version 1 (December 27th, 2011)
Improved the handling of directions
Changed internal variable names to make them more readable
Version 0 (May 31th, 2011)
Initial release