notes
Today's Genuary prompt is: Something you've always wanted to learn.
So many things! But the thing I noticed myself wondering the last few days was how ASCII art is generated. Let me tell a short story on this one.
At my full-time job, I've had the chance to work on a task recently to try and convert a user-uploaded image to a grayscale image so that it can be printed by a receipt printer. Receipt printers don't print in colour, so it's better that we feed it a grayscale image so we can control the way it renders.
This task came at an incredible timing because it coincides with me just starting to create a generative art project a day. The prototype approach I went for at work was to use the browser's `canvas` element and its built-in APIs to obtain a file after manipulating individual pixels to have a gray value that is the average of the original uploaded image's RGB values. Guess where I learned a whole bunch about using HTML canvas and its associated APIs? :)
So while that task simmered in my mind, I started to follow a bunch of Instagram accounts of people who are, like me, taking on the Genuary 2023 challenge - one generative art piece a day for the whole of January. One of those accounts (@julian_hespenheide) does a lot of ASCII art. And not just static ASCII art either - video ASCII art! My programmer's brain started wondering how they did that...
... and then it hit me that every picture is an array of pixels, and if I mapped each pixel to a particular ASCII character, since some characters are denser (and thereby brighter) than others, I could programmatically convert each pixel to a suitable character and print that on the page to achieve ASCII art! 🪄✨
So I went online, found out about Daniel Shiffman (see note below), and found one of his coding challenge tutorials called ASCII text images. Boom - he confirmed for me that my approach will work, because it's the same one as his!
Today I made the incredible discovery by watching this video that The Coding Train YouTube channel is actually run by Daniel Shiffman. That's HUGE because I've been reading a book by some Daniel Shiffman called The Nature of Code, and I had no idea that the person who has been teaching me via his video tutorials is actually the same author whom I'm learning from. 🤯
Resources referred to while creating today's project:
created with p5.js, a JavaScript library for creative coding.