FIRST: Create a folder or subdirectory in your 15-104 working area on your computer or in your Andrew private folder for handin-04. You will put all of your work inside this folder and then compress or zip it to create handin-04.zip to submit to Autolab.
In this part of the deliverable, you will download this Word file that contains 4 questions about concepts taught in class. You may download it anywhere on your computer. You should fill in your answers in the spaces provided, and include your name, andrewID and section letter at the top of page 1.
Once you are finished with this part of the deliverable, print/save it as a PDF and store this PDF in your handin-04 folder with the name andrewID-04-concepts.pdf. For example, if your andrewID is acarnegie, then you would save the PDF under the name acarnegie-04-concepts.pdf.
In this Assignment, you will create a program that draws a grid of rotating magenta squares of width 25, whose centers are all separated by 50 pixels horizontally and vertically. The number of squares you will draw will depend on the size of the canvas. You may assume that the canvas is square itself with a size that is a multiple of 50 (e.g. 50 X 50, 100 x 100, 150 x 150, etc.) up to 500 x 500. When the program begins, every other square starts with a orientation that is aligned with the canvas (i.e. no rotation) and the remaining squares start with a rotation of 45 degrees, as shown below for a canvas of 400 x 400. For each repetition of the draw function, the angle should increase by 2 degrees for each square.
Eventually, when you are done, your program should rotate all of the squares for any square canvas size that is a multiple of 50. An example of the final program with 64 squares for a 400 x 400 canvas is shown in the movie below:
IMPORTANT: For a different size canvas, the squares will still be the same size but there will be fewer or more of them. For example, for a 150 x 150 canvas, you should see 9 squares rotating. For a 500 x 500 canvas, you should see 100 squares rotating.
At this point, if you have this working, you will receive 2 of the 3 points.
If you get the more generalized solution to work correctly, you will receive all 3 points for this assignment.
In this Project, you will create a drawing using “string art” techniques. These images convey some of the vast possibilities:
from Google Images: gogeometry.com
from Google Images: bestpatterns.ludug.com
from Google Images: youtube.com
from Google Images: momath.com
How to make “string art”: One basic idea of string art is that you draw lines (stretch string) where the line end-points lie along a progression of points, often in a straight line. If you don’t have a good intuition for this, check out Holly Hatfield’s blog.
The basic idea is illustrated in the following program. In this simple example, there are two reference lines that are connected with 50 lines. The basic algorithm is to draw a line between one point on each of the initial lines. Then advance 1/50th of the way along each of the initial reference lines and draw the next line, and repeat this until you reach the other end of the two reference lines.
var dx1; var dy1; var dx2; var dy2; var numLines = 50; function setup() { createCanvas(400, 400); background(200); line(50, 50, 150, 300); line(300, 300, 350, 100); dx1 = (150-50)/numLines; dy1 = (300-50)/numLines; dx2 = (350-300)/numLines; dy2 = (100-300)/numLines; } function draw() { var x1 = 50; var y1 = 50; var x2 = 300; var y2 = 300; for (var i = 0; i <= numLines; i += 1) { line(x1, y1, x2, y2); x1 += dx1; y1 += dy1; x2 += dx2; y2 += dy2; } noLoop(); }
Since we need to draw 50 lines, we don’t want to do this with 50 line commands. Instead, we can use a loop whose variable (i) acts as a counter. By computing the deltas (dx1, dy1, dx2, dy2) for 1/50th of a step along the reference lines, we can add i deltas to move along the reference lines and connect the opposing points to create string art.
Here are the Project 04 requirements:
You will zip up the handin-04 folder and submit this to Autolab. Your overall folder organization should look something like this (indentation indicates subfolders):
handin-04 andrewID-04-assignment index.html sketch.js andrewID-04-concepts.pdf andrewID-04-project index.html sketch.js