This is a simple Win32 project originally created for this YouTube video to illustrate an interesting persistence of vision effect that I first came across when messing around with simple graphics on a BBC micro back in the 80s. Repeatedly drawing random white lines on a black background in XOR (exlcusive OR) mode results in new lines appearing on a random field of black and white pixels. Although this means that the lines don't show up as lines, your eyes and brain still detect the switching of a line of pixels from one state to the other as a line appearing, just for a fraction of a second.
I wanted to mimic the big, crisp pixels of an old 8-bit computer with a low-resolution display. I tried it in Javascript and then in a UWP Windows app, but it wasn't easy to get the effect I wanted (or perhaps I just didn't find the right technique).
In Win32, it's easy - I just create a low-resolution off-screen display context (DC), draw my lines etc on that and then copy it to the main window of the app using StretchBlt which does exactly what I wanted - a perfectly enlarged copy of the smaller bitmap with perfectly crisp edges to all the enlarged pixels.
This version is updated for this follow-up YouTube video. This version is much more complete, with a configuration dialog available allowing on-the-fly adjustment of the screen resolution, line width, line colour, and more. There are still a few bugs but it mostly works as you'd expect and is fun to play with.
The animation starts as soon as the app launches. Press F to open the configuration dialog; from there you can start/stop the animation, clear the screen, etc. When focus is on the main window, even when the config dialog is closed, you can press L to draw a single random line or M to draw multiple (10) lines, press S to start/stop the animation, press C to toggle the cube, N to toggle the line and T to toggle the text. Press E to toggle whether the background is erased on each new frame of the animation. Pressing P changes the colour of the lines being drawn to the next one of the 16 randomly-generated colours.
Press R to reset everything (stop the animation and clear the screen).