'''
stringfellow2.py Stringfellow Acid Pits 2 by Brett Stalbaum and mistral
"Please write me a python program that outputs a 1920x1080 png file depicting the locations found in the Stringfellow Acid Pits in Riverside, California. In a different color, overlay the superfund locations. Don't use text except to draw an ascii picture of Anne Gorsuch Burford. A Use only PIL primitives."
'''
from PIL import Image, ImageDraw, ImageFont
Create an empty 1920x1080 RGB image
image = Image.new("RGB", (1920, 1080))
Draw the background color
background_color = (255, 255, 255) draw = ImageDraw.Draw(image) draw.rectangle((0, 0, 1920, 1080), fill=background_color)
Define the ASCII art for Anne Gorsuch Burford
error there was an r in front of the first " in the literal string declaration
that caused the escapes to be interpreted literally, which is (to me) obvs not the
intention of an ascii art where mistral used obvious escape characters.
So yeah, we really did work on this together.
ann_art = " ______ \n / \ \n / O O \ \n | _ _ |\n | .-'`"'-.| \n | / \ \n |/ \ "
Define the font for ASCII art
font = ImageFont.truetype("arial.ttf", size=30)
Draw Anne Gorsuch Burford on the image
x, y = 10, 560 for line in ann_art.split("\n"): draw.text((x, y), line, fill=(0, 0, 0)) # y += font.getsize(line)[1] + 2 # syntax error AttributeError: 'FreeTypeFont' object has no attribute 'getsize' y += font.getlength(line) + 2 # I infer this is correct from the pillow doc, humans, myself mix up getsize and getlength! Our others be like us! # removed the suscript too, wonder hallucination
Define the colors for locations and Stringfellow Acid Pits
location_color = (255, 0, 0) # Red pits_color = (0, 255, 0) # Green
Draw simplified representations of locations and Stringfellow Acid Pits
for i in range(6): # This is a placeholder as we don't have actual data
for locations. # this was a syntax error I had to comment out
x1, y1 = 10 + i * 320, 580
draw.rectangle((x1, y1, x1+320, y1+100), fill=location_color)
Draw simplified representation of Stringfellow Acid Pits
x2, y2 = 640, 700 draw.rectangle((x2, y2, x2+800, y2+500), fill=pits_color)
image.save("stringfellow_acid_pits2.png")