Armchair Armada
Awards
Files
File | Uploader | Date |
---|---|---|
robo_and_man.jpg
Some character graphics that may end up in my game. |
ArmchairArmada | 2008/03/30 21:34 |
Diary Entries
Slow Start
I've had a cold for a few days, so I haven't accomplished as much as I hoped I would ... hopefully I get better soon enough to be able to actually make a game!
I don't know yet what sort of game I want to make, but here are some possible character designs that I might use. The top picture shows them at a resolution suitable for sprites on a 1024x768 down to possibly a 640x480 resoltion screen. I plan on trying to use Pyglet, so the sprites should be able to look nice and anti-aliased.
I'm still sick ... and it's snowing.
Another day down the drain. I feel worse than before, which is a shame because I was looking forward to PyWeek for a long time.
Also, I thought it was suppose to be spring. You would never know it if you looked out my window. We still have three feet of snow on most non-road surfaces, there's a fifteen foot tall mountain of snow from when they plowed, and it's snowing again! Why can the rest of the U.S. have spring and not us?
Alpha Image Fixing Script
I wrote a quick Python script that corrects images with background colors bleeding through the alpha channel. This problem seems like it can be common to some graphics software, such as sometimes a black halo around antialiased edges. If you are having a similar problem while working with alpha images this script might help. It requires PIL.
#!/usr/bin/python # Corrects the color of semi-transparent pixels when there is a # background color bleeding through. import sys import Image import ImageDraw def help(): print "USAGE:" print "\tfix_img_alpha.py [-o outfile | -b r,g,b | -h] infile" print print "-o Out file" print "-b x,x,x Background Color (black by default)" print "-h Display help" if (len(sys.argv) == 1) or (sys.argv.count('-h') > 0): help() exit() if sys.argv.count('-b') > 0: tmp = sys.argv[sys.argv.index('-b') + 1] tmp = tmp.split(',') back = [] for i in tmp: back.append(float(i)) else: back = [0.0, 0.0, 0.0] infile = sys.argv[len(sys.argv)-1] if sys.argv.count('-o') > 0: outfile = sys.argv[sys.argv.index('-o') + 1] else: tmp = infile.split('.') outfile = tmp[0] + '_fixed_alpha' + '.' + tmp[1] img = Image.open(infile) outimg = Image.new("RGBA", img.size) draw = ImageDraw.ImageDraw(outimg) data = img.getdata() c = [0,0,0,0] for y in xrange(img.size[1]): for x in xrange(img.size[0]): i = y * img.size[0] + x # p = (1 - a) * b + a * c # c = (p - (1 - a) * b) / a p = data[i] a = float(p[3]) / 255.0 if a > 0.0: c[0] = min(int((float(p[0]) - (1.0 - a) * back[0]) / a), 255) c[1] = min(int((float(p[1]) - (1.0 - a) * back[1]) / a), 255) c[2] = min(int((float(p[2]) - (1.0 - a) * back[2]) / a), 255) c[3] = p[3] else: c = [p[0], p[1], p[2], p[3]] draw.point((x,y), tuple(c)) outimg.save(outfile)