"""Draws powerUpShield.png for the fredygames.com build of Chromium B.S.U. The original icon of the shield, repair and super-shield power-ups is the Tux penguin, which the site leaves out. This one is a plain heater shield in the same format: 64x64 RGBA with a soft white glow behind it, like the original, which the game tints with the color of each power-up. The PNG made by this script is versioned next to it (chromium-bsu/powerUpShield.png) and goes into the build in place of the original; build-chromium-bsu.sh only copies it. artifacts/tools/venv/bin/python make-shield-icon.py powerUpShield.png # Pillow 12.3.0 Written in 2026 by FredyGames for the fredygames.com build of Chromium B.S.U.; distributed with the game under the Clarified Artistic License (see COPYING). """ import sys from PIL import Image, ImageChops, ImageDraw, PngImagePlugin SIZE = 64 SCALE = 8 # drawn at 8x and scaled down, for smooth edges S = SIZE * SCALE def shield(inset): """Outline of a heater shield (flat top, sides curving to a point), inset by `inset` pixels.""" left, right, top, bottom = 18 * SCALE + inset, 46 * SCALE - inset, 14 * SCALE + inset, 52 * SCALE - inset mid = (left + right) / 2 points = [(left, top), (right, top)] steps = 24 for i in range(1, steps + 1): # right side: straight down, then curving to the point t = i / steps points.append((right - (right - mid) * t ** 2.2, top + (bottom - top) * t)) for i in range(steps - 1, 0, -1): t = i / steps points.append((left + (mid - left) * t ** 2.2, top + (bottom - top) * t)) return points def gradient(top, bottom): """Vertical gradient image from color `top` to color `bottom`.""" image = Image.new('RGBA', (S, S)) draw = ImageDraw.Draw(image) for y in range(S): t = y / (S - 1) draw.line([(0, y), (S, y)], fill=tuple(round(a + (b - a) * t) for a, b in zip(top, bottom))) return image def main(path): # Glow: white, fading out from the center. glow = Image.new('L', (S, S), 0) pixels = glow.load() for y in range(S): for x in range(S): r = ((x - S / 2) ** 2 + (y - S / 2) ** 2) ** 0.5 / (S / 2) pixels[x, y] = round(255 * max(0.0, 1.0 - r) ** 1.1) image = Image.new('RGBA', (S, S), (255, 255, 255, 0)) image.putalpha(glow) # Rim: light steel, then the blue face inside it. rim_mask = Image.new('L', (S, S), 0) ImageDraw.Draw(rim_mask).polygon(shield(0), fill=255) image.paste(gradient((235, 240, 250, 255), (120, 130, 150, 255)), (0, 0), rim_mask) face_mask = Image.new('L', (S, S), 0) ImageDraw.Draw(face_mask).polygon(shield(3 * SCALE), fill=255) image.paste(gradient((90, 150, 255, 255), (20, 40, 140, 255)), (0, 0), face_mask) # A raised band down the middle and a soft highlight on the upper left. band = Image.new('L', (S, S), 0) ImageDraw.Draw(band).rectangle([30 * SCALE, 16 * SCALE, 34 * SCALE, 50 * SCALE], fill=255) band = ImageChops.multiply(band, face_mask) image.paste(gradient((200, 225, 255, 255), (70, 110, 210, 255)), (0, 0), band) shine = Image.new('L', (S, S), 0) ImageDraw.Draw(shine).ellipse([20 * SCALE, 16 * SCALE, 30 * SCALE, 31 * SCALE], fill=90) shine = ImageChops.multiply(shine, face_mask) image.paste(Image.new('RGBA', (S, S), (255, 255, 255, 255)), (0, 0), shine) image = image.resize((SIZE, SIZE), Image.LANCZOS) info = PngImagePlugin.PngInfo() info.add_text('Comment', 'Drawn for the fredygames.com build of Chromium B.S.U. on 2026-10-23 ' '(make-shield-icon.py), replacing the original powerUpShield.png (Tux).') image.save(path, pnginfo=info, optimize=False) if __name__ == '__main__': main(sys.argv[1])