plate maker

creates a plate of images from lost of little ones
you can use this code to write your special one - as all plate makers follow some specific format.
Also writes out simple animations structure you can use in your game.


import os, sys
from random import sample
from pandac.PandaModules import *

plateImages = [ 
    ['frame1','frame2','frame3','frame4'],
    ['still-image']
] 

print plateImages
animations = {} 

number = 0
for animation in plateImages:
    name = animation[0].strip("1234567890")
    animations[name] = (number, len(animation), number+len(animation))
    number += len(animation)
     
import pprint
print "animations = ", pprint.pprint(animations)
by = 16 #int(number**.5) + 1
print by, "x", by, " plate   " , (by*by), " of ", number
size = 2048
partsize = size / by
print "partsize", partsize
plate = PNMImage(size, size, 4)   
i = 0
for animation in plateImages:
    for infile in animation:
        part = PNMImage(Filename("icons/"+infile+".png"))
        scaled = PNMImage(partsize, partsize, 4)
        scaled.gaussianFilterFrom(1, part)
        x, y = int(size/by*(i%by)), int(size/by*(i/by))
        plate.copySubImage(scaled, x, y, 0, 0, partsize, partsize)
        i += 1
       
plate.write(Filename("radarplate.png"))