xxxxxxxxxx
/*
Art 3001 Robot Assignment 2
-a simple robot drawn with basic processing commands using variables
Created by Travis McDaniel
on 1/19/17
Travis959200@gmail.com
*/
void setup() //Sets up the Canvas
{
size(600, 800);
}
void draw() //Draws the Robot
{
//Variable Declarations
//Measurement Bases
//Mouse mode
float centerX = mouseX;
float centerY = mouseY;
//Static mode
//float centerX = width/2;
//float centerY = height/2;
//Limb variables
float rArmX = centerX-250;
float lArmX = centerX-50;
float armY;
float armYStart = centerY-100;
float armYEnd = centerY+70;
float rLegX = centerX-85;
float lLegX = centerX-115;
float legY;
float legYStart = centerY+120;
float legYEnd = centerY+315;
float limbLinkW = 50;
float limbLinkH = 10;
//Hands and Feet
float handSize = 75;
float handAngle1 = 2.36;
float handAngle2 = 7.05;
float footW = 150;
float footH = 75;
float rightFootAngle = 3.14;
float sharedFootAngle = 4.71;
float leftFootAngle = 6.28;
//Head and Body
float headDimension = 100;
float bodyW = 150;
float bodyH = 250;
//Shoulders
float shoulderW = 115;
float shoulderH = 75;
float shoulderAngle1 = 3.14;
float shoulderAngle2 = 4.71;
float shoulderAngle3 = 6.28;
//Eyes
float eyeSize = 25;
float pupilSize =10;
//Mouth
float mouthStartX = centerX-35;
float mouthY = centerY-175;
float mouthSegments = 8;
float mouthSegmentW = 10;
float mouthSegmentH = 20;
//Neck
float neckStartY = centerY-150;
float neckSegments = 7;
//Color presets
float bodyGrey = 127;
float limbGrey = 200;
float white = 255;
float black = 0;
float yellow[] = new float [3];
yellow[0] = 255;
yellow[1] = 255;
yellow[2] = 0;
//Set rectMode to CENTER
rectMode(CENTER);
//Draw the background
background(black);
//Antenna
noFill();
stroke(bodyGrey);
strokeWeight(3);
beginShape();
curveVertex(centerX,centerY-250);
curveVertex(centerX,centerY-250);
curveVertex(centerX,centerY-300);
curveVertex(centerX-50,centerY-300);
curveVertex(centerX-50,centerY-300);
endShape();
fill(limbGrey);
noStroke();
ellipse(centerX-50,centerY-300,10,10);
//Arms, Legs, and Neck
stroke(bodyGrey);
fill(limbGrey);
//Arms
for (armY = armYStart; armY < armYEnd; armY +=5)
{
//Right Arm
ellipse(centerX-100,armY,limbLinkW,limbLinkH);
//Left Arm
ellipse(centerX+100,armY,limbLinkW,limbLinkH);
}
//Legs
for (legY = legYStart; legY < legYEnd; legY +=5)
{
//Right Leg
ellipse(centerX-40,legY,limbLinkW,limbLinkH);
//Left Leg
ellipse(centerX+40,legY,limbLinkW,limbLinkH);
}
//Neck
for (float y=0; y<neckSegments; y++)
{
ellipse(centerX,neckStartY+(y*5),limbLinkW,limbLinkH);
}
noStroke();
//Shoulders
stroke(black);
strokeWeight(1);
fill(bodyGrey);
arc(centerX-75,centerY-100,shoulderW,shoulderH,shoulderAngle1,shoulderAngle2);
arc(centerX+76,centerY-100,shoulderW,shoulderH,shoulderAngle2,shoulderAngle3);
//Head
rect(centerX,centerY-200,headDimension,headDimension);
//Body
rect(centerX,centerY,bodyW,bodyH);
//Hands
arc(centerX-100,armYEnd,handSize,handSize,handAngle1,handAngle2);
arc(centerX+100,armYEnd,handSize,handSize,handAngle1,handAngle2);
//Feet
arc(centerX-10,legYEnd,footW,footH,rightFootAngle,sharedFootAngle);
arc(centerX+10,legYEnd,footW,footH,sharedFootAngle,leftFootAngle);
//Face
//Eyes
fill(white);
rect(centerX-20,centerY-220,eyeSize,eyeSize);
rect(centerX+20,centerY-220,eyeSize,eyeSize);
fill(black);
rect(centerX-28,centerY-213,pupilSize,pupilSize);
rect(centerX+13,centerY-213,pupilSize,pupilSize);
//Mouth
for (float x = 0; x < mouthSegments; x++)
{
//Every even rectangle is yellow, every odd one is white.
if (x % 2 == 0)
{
fill (yellow[0], yellow[1], yellow[2]);
}
else
{
fill (white);
}
rect(mouthStartX+(x*mouthSegmentW),mouthY, mouthSegmentW, mouthSegmentH);
}
//Make it speak
if (mousePressed)
{
println("Beep Boop");
}
}