It’s been a while since I’ve done anything significant on my Granny Square Pattern Generator (GSC), and since I’ve already contributed to a game release this week, I figured I hadn’t quite checked enough “public-facing actions” boxes this week until I did some work on GSC.
Biggest missing feature (and biggest complaint!) is that blankets weren’t printable. Now they are!
Log in with something like Facebook or Twitter, generate a blanket, and save the blanket. When you look at the details of the blanket, you can now get it as a printable image, and toggle between the two styles of seeing the blanket.
My next task is to make authentication more seamless.
The site, by default, shows a blanket as an HTML table of nested background colors. Browsers don’t print background colors by default, so users were like, “Frown.”
Took me plenty long enough, calendar-wise, but now that’s fixed. Technically speaking, generating an image is easy, and storing it is cheap.
The Python Imaging Library is the de facto standard, but if you take a skim of the ImageDraw class, you’ll see the interface listed and described, but only one lonely example at the top. It really is pretty straightforward if you’re comfy with Python, although if you’re new to including PIL in your projects, please save yourself some devops hell and pip pillow instead of the mess we used to need to do. (Check and see if the library was in place; if not, grab the tarball, decompress, install, etc.)
The only thing that tripped me up for a second is that if you’re doing a hex code for the fill color, you need to use ImageColor.getrgb():
draw.rectangle((x1, y1, x2, y2), fill=ImageColor.getrgb(color.color_hex))