Audrey Zheng – Project 04

I am using one of my autolab grace days for this project.

sketch

// Audrey Zheng
// Section A
// audreyz@andrew.cmu.edu
// Project 04

var cwidth = 300;
var cheight = 400;

var listPoints1 = new Array();
var listPoints2 = new Array();

function setup() {
    createCanvas(cwidth, cheight);
}

function strings() {

	stroke(0);


	var x = 10;
	var y = cheight/2;
	//var listPoints1 = new Array();

	for (var i = 0; i <21; i++) {

		point(x,y);

		var p = new Array(x,y);
		listPoints1.push(p);

		x += 14;

	}

	var x2 = cwidth/2;
	var y2 = 60;
	//var listPoints2 = new Array();

	for (var j = 0; j<21; j++) {

		point(x2,y2);

		var point2 = new Array(x2,y2);
		listPoints2.push(point2);

		y2 += 14;
	}

	noLoop();

	var start = 0;
	var end = 9;

	var start2 = 20;

	var end2 = 11;


	for (var k = 0; k<10; k++) {
		line(listPoints1[start][0], listPoints1[start][1], listPoints2[end][0], listPoints2[end][1]);
		line(listPoints1[start2][0], listPoints1[start2][1], listPoints2[end][0], listPoints2[end][1]);
		line(listPoints1[start2][0], listPoints1[start2][1], listPoints2[end2][0], listPoints2[end2][1]);
		line(listPoints1[start][0], listPoints1[start][1], listPoints2[end2][0], listPoints2[end2][1]);

		start += 1;
		end -= 1;

		start2 -= 1;
		end2 += 1;





	}

}




function draw() {
	background(220);

	stroke(255);
	line(10,cheight/2, 290, cheight/2);
	line(cwidth/2, 60, cwidth/2, cheight-60);

	strings();
    
}

function mousePressed() {
	print(listPoints2.length);
	print(listPoints1.length);
	print("5");

}

Leave a Reply