Created
May 30, 2020 12:37
-
-
Save spacekitcat/04722b037e85c1331fe1ca228627ddd1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from PIL import ImageFont | |
from PIL import ImageDraw | |
import os | |
# The range of images to generate, which also controls the number of gradient 'stops' | |
imageCount = 30 | |
# How far to increment red for each image, currently tied to imageCount as you can see | |
colorIncrement = 255 / imageCount | |
# Output folder for the images | |
outputDir = "output" | |
# Path to a TTF | |
trueTypeFontPath = "VT323-Regular.ttf" | |
if not os.path.exists(outputDir): | |
os.mkdir(outputDir) | |
currentColor = 20 | |
for x in range(imageCount): | |
img = Image.new('RGB', (32, 32), (int(currentColor), 0, 0)) | |
currentColor += colorIncrement | |
draw = ImageDraw.Draw(img) | |
font = ImageFont.truetype(trueTypeFontPath, 32) | |
draw.text((0, 0), str(x),(255,255,255),font=font) | |
img.save(outputDir + "/" + str(x) + ".png") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment