Making of: Even icon


(Yes, it's there.)

There will be a number of examples to illustrate the working with Flat. To start things off with something simple, here is the making of the icon for Even for Mac. The snippet below creates some images with different dimensions, paints them to ever more transparent white and exports them in PNG format. For the documentation of image and other objects see the reference.

from flat import image

for scale in (True, False):
    for size in (16, 32, 128, 256, 512):
        count = size * 2 if scale else size
        i = image(count, count, 'rgba')
        for y in range(count):
            alpha = 255 - int(round(y * (255.0 / (count - 1))))
            for x in range(count):
                i.put(x, y, 255, 255, 255, alpha)
        i.png('src/icon_%dx%d%s.png' % (size, size, '@2x' if scale else ''))

And then run iconutil -c icns even.iconset.

— 29. 10. 2013