# Powerup color remapper # Copyright 2006 Larry Hastings for Game Jones Corporation # larry@hastings.org # # This software is provided 'as-is', without any express or implied warranty. # In no event will the authors be held liable for any damages arising from # the use of this software. # # Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute # it freely, subject to the following restrictions: # # 1. The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software # in a product, an acknowledgment in the product documentation would be # appreciated but is not required. # 2. Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. # import colorsys import Image import types names = [] for i in range(25): names.append("") names[ 0] = "hurry up" names[ 1] = "ball slowdown" names[ 2] = "super bomb" names[ 3] = "bomb ball" names[ 4] = "award continue" names[ 5] = "ghost" names[ 6] = "steer" names[ 7] = "multiball" names[ 8] = "ball saver" names[ 9] = "award bonus" names[10] = "bonus hold" names[11] = "bonus multiplier" names[12] = "bonus points" names[13] = "paddle grow" names[14] =("breakthrough", 0.7) names[15] =("alternate warp", 0.8) names[16] = "ball grow" names[17] =("catch", 0.7) names[18] = "score multiplier" names[19] = "score points" names[20] = "activate warp" names[21] = "random award" names[22] = "extra ball" names[23] = "extra time" i = 0 hue = 0.0 gray = Image.new("RGBA", (128, 128), (0xa7, 0xa7, 0xa7, 0) ) gradient = Image.open("gradient.png") f = open("index.html", "wt") column = 0 f.write("Unbrick powerup color remapper\n") def colorFromHueAndBrightness(hue, brightness): (r, g, b) = colorsys.hsv_to_rgb(hue, 1, brightness) map = {} map["r"] = int(r * 255) map["g"] = int(g * 255) map["b"] = int(b * 255) color = "#%(r)02x%(g)02x%(b)02x" % map return color for i in range(24): brightness = 0.5 if isinstance(names[i], types.TupleType): powerup = names[i][0] brightness = names[i][1] else: powerup = names[i] brightShade = Image.new("RGBA", (128, 128), colorFromHueAndBrightness(hue, brightness)) darkShade = Image.new("RGBA", (128, 128), colorFromHueAndBrightness(hue, brightness - 0.1)) shade = Image.composite(brightShade, darkShade, gradient) usingDefault = (len(powerup) == 0) inputFilename = powerup if usingDefault: inputFilename = "random award" if inputFilename[-4:].lower() != ".png": inputFilename = inputFilename + ".png" inputFilename = inputFilename.replace(" ", ".") mask = Image.open(inputFilename) if usingDefault: filename = str(i) + ".png" else: filename = inputFilename Image.composite(shade, gray, mask).save(filename, "PNG") if (column == 0): f.write("") f.write("\n") column += 1 if (column == 4): f.write("\n") column = 0 hue = i / 24.0 f.write("
\n") f.write("" + str(i) + "
" + powerup + "
") f.write("
\n")