ascii image thing
- 3 Devlogs
- 12 Total hours
Image to layered ASCII in cyan, magenta, and yellow.
Image to layered ASCII in cyan, magenta, and yellow.
Basic image editor
I’ve implemented a vector drawing editor with smooth curves and pressure sensitivity, and I created a worker to process the updated canvas after every stroke to convert it into glyphs.
I intend to implement color support and layers later.
I want the glyph rendering to be real-time, so I have a lot of optimization work to do.
The video looks a bit choppy because I’m using a tablet laptop that has a very low detection range for its drawing pen. So the cursor teleports.
Refactor for speed
Initially, I attempted using kd-trees like I mentioned before. But that led to what felt like at 50x slower execution. So I just sat for a few minutes, staring at the code.
Then I realized the three separate color channels didn’t have to be linked together… so I refactored the logic to compute the channels separately, and now it’s running over 240x faster than the original.
For the Stardance logo (with the outline I added), it went from taking 290.9 seconds to only 1.2, with what looks like the same output.
I need to stop overthinking things.
I also realized I was calculating the width of a character without applying the correct font size. Things don’t warp anymore.
I was inspired by the typewriter’s inability to erase, and subtractive color mixing.
Now I have a program that generates three layers of stacked ASCII in cyan, magenta, and yellow, to replicate an image.
It generates very slowly at the moment–every character requires checking against 857,375 patterns to find the best fit. My plan is to use a kd-tree to reduce that to about 20 matches instead.
I also have to figure out why the images are squished vertically (or stretched horizontally).