/* 15-100 D Homework #4-B Dae Hong Kim daek@andrew.cmu.edu */ void setup(){ size(300, 300); frameRate(5); smooth(); println("Homework #4B"); println("Printing the initials: DHK random position/size in the screen"); background(0); //drawBigInitial(); // draw big initilal "D" } void draw(){ float x = width/10; //x coordinate float y = height/10; // y coordinate float thetaWidth = width/10 ; // width of each initial float thetaHeight = height/10 ; // height of each initial // calling a method drawInitials( x coordinate, y coordinate, width of each initial, height of each initial) drawInitials(random(width-(thetaWidth*3)), random(height-(thetaHeight)), random(5, thetaWidth), random(5, thetaHeight)); } void drawInitials(float x, float y, float thetaWidth, float thetaHeight){ // Draw Initial D stroke(random(255), random(255), random(255)); strokeWeight(random(6)); noFill(); beginShape(); curveVertex(x, y); curveVertex(x + thetaWidth * 2/10, y); curveVertex(x + thetaWidth * 4/10, y + thetaHeight * 2/10); curveVertex(x, y + thetaHeight * 6/10); curveVertex(x + thetaWidth * 3/10, y + thetaHeight); curveVertex(x + thetaWidth * 3/10, y + thetaHeight); endShape(); beginShape(); curveVertex(x, y); curveVertex(x , y + thetaHeight * 2/10 ); curveVertex(x + thetaWidth * 6/10, y + thetaHeight * 1/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight * 3/10); curveVertex(x + thetaWidth * 9/10, y + thetaHeight * 5/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight * 7/10); curveVertex(x + thetaWidth * 4/10 , y + thetaHeight * 8/10); curveVertex(x , y + thetaHeight * 8/10 ); curveVertex(x , y + thetaHeight * 8/10 ); endShape(); // Draw initial H stroke(random(255), random(255), random(255)); x += thetaWidth; beginShape(); curveVertex(x, y); curveVertex(x, y); curveVertex(x + thetaWidth * 3/10, y + thetaHeight * 2/10); curveVertex(x + thetaWidth * 2/10 , y + thetaHeight * 5/10 ); curveVertex(x + thetaWidth * 3/10, y + thetaHeight * 8/10); curveVertex(x + thetaWidth * 1/10, y + thetaHeight); curveVertex(x + thetaWidth * 1/10, y + thetaHeight); endShape(); beginShape(); curveVertex(x + thetaWidth * 9/10, y); curveVertex(x + thetaWidth * 9/10, y); curveVertex(x + thetaWidth * 7/10, y + thetaHeight * 4/10); curveVertex(x + thetaWidth * 7/10, y + thetaHeight * 7/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight); curveVertex(x + thetaWidth * 8/10, y + thetaHeight); endShape(); beginShape(); curveVertex(x, y + thetaHeight * 6/10); curveVertex(x, y + thetaHeight * 6/10); curveVertex(x + thetaWidth * 2/10, y + thetaHeight * 5/10); curveVertex(x + thetaWidth * 4/10, y + thetaHeight * 6/10); curveVertex(x + thetaWidth * 6/10, y + thetaHeight * 5/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight * 6/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight * 6/10); endShape(); //Draw initial K stroke(random(255), random(255), random(255)); x += thetaWidth; beginShape(); curveVertex(x, y); curveVertex(x + thetaWidth * 2/10, y + thetaHeight * 2/10); curveVertex(x + thetaWidth * 3/10, y + thetaHeight * 3/10); curveVertex(x + thetaWidth * 2/10, y + thetaHeight * 5/10); curveVertex(x, y + thetaHeight * 4/10); curveVertex(x + thetaWidth * 1/10, y + thetaHeight * 1/10); curveVertex(x + thetaWidth * 3/10, y); curveVertex(x + thetaWidth * 5/10, y + thetaHeight * 2/10); curveVertex(x + thetaWidth * 5/10, y + thetaHeight * 6/10); curveVertex(x + thetaWidth * 3/10, y + thetaHeight * 7/10); curveVertex(x, y + thetaHeight); curveVertex(x, y + thetaHeight * 8/10); curveVertex(x, y + thetaHeight * 8/10); endShape(); beginShape(); curveVertex(x + thetaWidth, y); curveVertex(x + thetaWidth, y); curveVertex(x + thetaWidth * 7/10, y + thetaHeight * 6/10); curveVertex(x + thetaWidth * 5/10, y + thetaHeight * 5/10); curveVertex(x + thetaWidth * 6/10, y + thetaHeight * 3/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight); curveVertex(x + thetaWidth, y + thetaHeight * 9/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight * 8/10); curveVertex(x + thetaWidth * 8/10, y + thetaHeight * 8/10); endShape(); } /*void drawBigInitial(){ noFill(); float x = width/10; //x coordinate float y = height/10; // y coordinate float spaceX = width / 6; float spaceY = height / 15; float thetaWidth = width/20 ; // width of each initial float thetaHeight = height/20 ; // height of each initial // Method drawInitials( x coordinate, y coordinate, width of each initial, height of each initial) // drawing initial "D" // drawing the vertical line of inital "D" drawInitials( x, y, thetaWidth, thetaHeight); drawInitials( x, y + spaceY, thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 2), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 3), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 4), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 5), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 6), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 7), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 8), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 9), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 10), thetaWidth, thetaHeight); drawInitials( x, y + (spaceY * 11), thetaWidth, thetaHeight); // drawing curve of initial "D" drawInitials( x + spaceX , y , thetaWidth, thetaHeight); drawInitials( x + spaceX , y + spaceY , thetaWidth, thetaHeight); drawInitials( x + (spaceX * 2), y + spaceY , thetaWidth, thetaHeight); drawInitials( x + (spaceX * 2), y + (spaceY * 2), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 2), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 3), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 4), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 5), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 6), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 7), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 8), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 3), y + (spaceY * 9), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 2), y + (spaceY * 9), thetaWidth, thetaHeight); drawInitials( x + (spaceX * 2), y + (spaceY * 10), thetaWidth, thetaHeight); drawInitials( x + spaceX , y + (spaceY * 10), thetaWidth, thetaHeight); drawInitials( x + spaceX , y + (spaceY * 11), thetaWidth, thetaHeight); */