The assignment of Week 4’s homework of the 2D Animation and Interaction Course by Andrew Glassner is to create a painting program. A few things to keep in the back of my head. You can interpret ‘painting’ very broadly. Use the mouse and keyboard. Use at least one while loop. Use at least one for loop. Use each of map, lerp, and dist at least once. You can use the keyboard as a big collection of on/off buttons. Pressing a key can change a boolean variable (usually a global) from true to false, and vice-versa. Remember that you can change all kinds of aspects of your shapes, not just their location and size, but also their fill color, stroke color, and stroke weight. Don’t forget about transparency, Don’t use language elements we haven’t covered yet.
My idea is to make a paint program which is very time-consuming. Not a program like Adobe Photoshop which gives you lots of functionality to enhance your creativity in the cloud. This small paint program should paint very slowly. And because it’s very slow you can concentrate on making beautiful images. It’s a kind of slow motion Adobe Photoshop filter. Hence it’s name: SlowMoShop.
In fact what makes the program slow is the heavy use of transparency. Another thing that makes the program slow is that it is following your cursor many frames behind. In fact you don’t have a cursor anymore. The cursor is taken over by the shape you choose to draw with. If your shape (cursor) is at the bottom of the display and you point it at the top it takes several seconds to do the real drawing from the bottom to the top. It lag’s enormous behind. In the first program I only made use of basic shapes: rectangles and circles. But in a later stage I also could write my own functions to create other shapes like triangles, arcs or a bunch of horizontal and vertical lines. Boxes in boxes and circles in circles. In fact the possibilities are now unlimited. So If I would like to redo this program once I would introduce much more shapes to create images.
To make an image you first have to select a color. You can use one of the lowercase keys r, m, p, b, c, g, y, o. That’s red, magenta, purple, blue, cyan, green, yellow or orange. Or the uppercase R, M, P, B, C, G, Y, O. Those keys would give the same result. After selecting the color you select a shape by choosing the number keys 1 – 9 on top of the keyboard. You can select the space bar to pause the program. And to continue painting you have to choose color and shape again. There is also an option to erase the screen using the delete or backspace key. It’s all very basic and simple. But it works.
At the above link you can find some images which I made during the experimenting and testing of the program. But while working on the program a few questions popped up. I asked the following questions to Andrew Glassner:
Why do we have to be efficient in writing a program? The SlowMoShop program doesn’t cost GB’s or TB’s. The total (inefficient) program was just 41 KB.
When do I recognize that I am writing inefficient code? Is that the moment when you see that certain amounts of code are almost alike? What can I do to avoid repeating code?
I met several times when writing programs that I got stuck. Or I had to start all over again. Or I thought it did not make any sense at all what I had written. Or I could not solve a problem how to get things done with the tools I had. At that moment you enter a kind of code writer’s block. What can you do to avoid such situations?