Let’s learn how to create and paint with objects, by moving them around the canvas with math + code.
1. Go to researchideas.ca/mathart
- Let’s start by creating a point in the middle of the canvas.
- Drag the ‘create point’ block from the ‘Canvas Objects’ category onto the blockly work area, and click ‘Run Code’.
- Notice that Object 0 is now listed in the Object List. This is the Object you just created. Also notice that the coding area is empty, as Object 0 does not yet have any code attached to it.
2. Let’s give Object 0 some code and some motion!
- Under the ‘Canvas Objects’ category, select the ‘Motion’ subcategory.
- Here dx represents the Object’s horizontal rate of change (or speed). Likewise, dy represents the Object’s vertical rate of change.
- Drag, drop the dx and dy blocks and set their values as shown at right. Press Run Code to see how this code makes Object 0 move.
3. Let’s give the path the Object paints some colour.
- Edit your code for Object 0, as shown below.
- Press Run Code to see the result.
- The point should now be moving along the screen and gradually changing its colour as it moves along. The final product should look something like this:
4. Try some more Motion Art with Math+Code.
- See the PDF Tutorial at researchideas.ca/mathart/demos.pdf