//Jinhee Lee
//Section C
//jinheel1@andrew.cmu.edu
//Project-04
function setup() {
createCanvas(640,480);
}
function draw() {
background (0);
//violin strings
var neckX = 100; //starting position for neck of violin
var bridgeX = 100; //starting position for bridge of violin
var stringY = 0;
var stringX1 = 10; //spacing for string near neck
var stringX2 = 50; //spacing for string near bridge
for (i = 0; i < 4; i += 1) { //draw four strings
if (i == 0) {
stroke("#87CEFA"); //sky blue "G" string
} else if (i == 1) {
stroke("#ADFF2F"); //light green "D" string
} else if (i == 2) {
stroke("#FFFF00"); //yellow "A" string
} else if (i == 3) {
stroke("#FFA500"); //orange "E" string
}
line(neckX,stringY,bridgeX+stringX2,height);
stringX2 += stringX2; //spacing near bridge grows
neckX += stringX1; //spacing near neck is constant
//the difference in spacing creates a "zoom" effect
}
//violin bow
var bowX = width;
var bowY1 = 240; //y position at right edge
var bowY2 = 280; //y position at left edge
var bowY1step = 0.25; //smaller spacing for right edge
var bowY2step = 0.75; //larger spacing for left edge
stroke("#D2691E"); //brownish color for bow
for (i = 0; i < 50; i += 1) { //relatively small spacing makes "solid" object
line(bowX,bowY1,0,bowY2);
bowY1 += bowY1step; //difference in spacing makes "zoom" effect
bowY2 += bowY2step;
}
//violin bow hairs
//same as bow, on slightly smaller scale
var hairX = width;
var hairY1 = 265;
var hairY2 = 350;
var hairY1step = 0.15;
var hairY2step = 0.5;
stroke("#FFEBCD"); //almond color for bow hairs
for (i = 0; i < 50; i += 1) {
line(hairX,hairY1,0,hairY2);
hairY1 += hairY1step;
hairY2 += hairY2step;
}
}
Originally I had planned to make two branching clusters of branching lines to simulate puppeteer strings, but felt that it lacked variety.
In the end, I opted to create a violin (which I played from elementary to high school) using the same technique I had in mind, but varying the spacing and positions of the “curves” to: a) draw the individual strings and overall bow and b) create a slanted perspective using an artificial “zoom” effect.