Sunday, 31 August 2014

Pencil lab 2

float r = 0, g = 0, b = 0;
void setup(){
  size(300, 300);
}
void draw(){
  draw_penc();
}
void draw_penc(){
  background(200, 150, 0);
  noStroke();
  fill(#800000);
  beginShape();
  vertex(mouseX, mouseY);
  vertex(mouseX+10, mouseY-30);
  vertex(mouseX+30, mouseY-10);
  vertex(mouseX, mouseY);
  endShape();
  fill(r, g, b);
  quad(mouseX+10, mouseY-30, mouseX+80, mouseY-105, mouseX+100, mouseY-85, mouseX+30, mouseY-10);
  fill(#F3E5AB);
  quad(mouseX+80, mouseY-105, mouseX+80+70-60, mouseY-105-75+64, mouseX+100+70-60, mouseY-85-75+64, mouseX+100, mouseY-85);
  fill(0);
  triangle(mouseX, mouseY, mouseX+5, mouseY-15, mouseX+15, mouseY-5);
}
void mousePressed() {
    r = random(0, 255); g = random(0, 255); b = random(0, 255);
}



Saturday, 30 August 2014

Animation Hope lab 2

float col= 255;
float changepositonx = 300, changepositony = 0, changep2 = -100;
void setup() {
  size(323, 200);
  background(11, 222, 111);
}

void draw(){
  background(11, 222, 111);
  draw_car(changepositony);
  draw_car(changep2);
}
void draw_car(float changepositony){
  draw_colour();
  changepositonx = changepositonx - 1;
  if(changepositonx < -180){changepositonx = 300 ;}
rect(changepositonx+60, changepositony+135, 170, 40);
rect(changepositonx+100, changepositony+105, 100, 30);
fill(1, 1, 1);
ellipse(changepositonx+100, changepositony+170, 35, 35);
ellipse(changepositonx+190, changepositony+170, 35, 35);
fill(200);
ellipse(changepositonx+100, changepositony+170, 30, 30);
ellipse(changepositonx+190, changepositony+170, 30, 30);
rect(changepositonx+110, changepositony+110, 35, 20);
rect(changepositonx+155, changepositony+110, 35, 20);
fill(1, 1, 1);
ellipse(changepositonx+100, changepositony+170, 20, 20);
ellipse(changepositonx+190, changepositony+170, 20, 20);
fill(255);
ellipse(changepositonx+70, changepositony+150, 15, 10);
}
void draw_colour(){
 col = col - 0.5;
if(col == 40){col = 255;}
fill(col, 184, 222);
}


Friday, 29 August 2014

Animation Topic lab 2

int movex=75, movey=-10;
void setup() {
  size(323, 200);
  background(150, 50, 25);
  frameRate(1);
fill(200);
draw();
}
int a = 0;
void draw(){
  a = a + 1;
  if(a == 1){
    draw_2();
  line(65+movex, 150+movey, 80+movex, 110+movey);
}
  if(a == 2){
    draw_2();
line(65+movex, 150+movey, 80+movex, 110+movey);
line(95+movex, 150+movey, 80+movex, 110+movey);
}
  if(a == 3){
    draw_2();
line(65+movex, 150+movey, 80+movex, 110+movey);
line(95+movex, 150+movey, 80+movex, 110+movey);
line(72+movex, 130+movey, 87+movex, 130+movey);
}
if(a == 4){
    draw_2();
    a = 0;
}
}
void draw_2(){
  background(150, 50, 25);
  fill(200);
rect(20+movex, 25+movey, 140, 150);
line(25+movex, 40+movey, 25+movex, 70+movey);
line(45+movex, 50+movey, 45+movex, 60+movey);
line(40+movex, 55+movey, 50+movex, 55+movey);
line(65+movex, 40+movey, 65+movex, 70+movey);
line(90+movex, 50+movey, 100+movex, 50+movey);
line(90+movex, 60+movey, 100+movex, 60+movey);
line(120+movex, 40+movey, 140+movex, 40+movey);
line(140+movex, 40+movey, 140+movex, 55+movey);
line(120+movex, 55+movey, 140+movex, 55+movey);
line(120+movex, 55+movey, 120+movex, 70+movey);
line(120+movex, 70+movey, 140+movex, 70+movey);
}

Wednesday, 27 August 2014

Animation tree lab 2

void setup()

{

  size(500, 400);

  stroke(255);  

  frameRate(100);

}



float y = 200;
float x = 0;

void draw()

{


  if ((y > 0) && (x == 0)) {  y = y - 1; // y = 100 - 1>> 0 x = 0

  draw_tree(x, y, y);
  }
   if ((x < 200) && (y == 0)){  x = x + 1; // x = 0 +1 >>200

  draw_tree(x, x, x);
 }
  if ((y < 200) && (x > 199)) {  y = y + 1;  // y = 200 x = 200

  draw_tree(y, y, x);
  }

if (y == 200){  x = x - 1; // x = 200-1>> 0
  draw_tree(x, y, x);
 
 }

}
void draw_tree(float r, float g, float b){
background(10, 185, 255);
fill(b, r, g);
rect(165+x, 110+y, 40, 10);
rect(145+x, 80+y, 20, 90);

fill(r, g, b);
ellipse(135+x, 46+y, 100, 80);
ellipse(175+x, 46+y, 100, 80);
ellipse(155+x, 46+y, 100, 80);

fill(b, r, g);
rect(105+x, 80+y, 20, 90);
rect(65+x, 80+y, 20, 90);
fill(r, g, b);
ellipse(85+x, 46+y, 100, 80);
ellipse(125+x, 46+y, 100, 80);
ellipse(105+x, 46+y, 100, 80);
ellipse(65+x, 46+y, 100, 80);
fill(r*g/b);
rect(195+x, 95+y, 10, 20);
}




Monday, 25 August 2014

Convert from Pound to Kilograms lab 1

int pound=5;
float conv=0.453592;
void setup(){
  print(pound+" Pound = ");
  print(pound*conv+" Kilograms");
}

Convert from Celsius to Fahrenheit lab 1

int cons=32, celsius=5;
float consx=1.8, cal;
void setup(){
  cal = celsius*consx;
  print(celsius+" Celsius = ");
  print(cal+cons+" Fahrenheit");
}

Find volume of cylinder lab1

int RadiusTwo, Radius=5, Height=10;
float Pie=3.14;
void setup(){
  RadiusTwo = Radius*Radius;
  println("The volum of this cylinder is "+RadiusTwo*Height*Pie);
}

Convert from feet to meter lab 1

int feet=15 ;
float conv=0.3048;
void setup(){
  println(feet+" Feet = "+feet*conv+" Meter ");
}

Spoon and Fork lab 1

void setup(){
  size(200, 200);
  background(200);
  fill(255);
  stroke(255);
  quad(100, 25, 25, 100, 100, 175, 175, 100);
  stroke(180);
  fill(180);
  rect(45, 70, 10, 70);
  rect(145, 70, 10, 70);
  quad(135, 55, 165, 55, 155, 72, 145, 72);
  ellipse(50, 50, 30, 45);
  rect(135, 30, 30, 25);
  stroke(190);
  fill(190);
  ellipse(50, 50, 26, 36);
  rect(47, 72, 6, 66);
  rect(147, 72, 6, 66);
  quad(138, 55, 162, 55, 153, 72, 147, 72);
  rect(138, 32, 3, 25);
  rect(145, 32, 3, 25);
  rect(152, 32, 3, 25);
  rect(159, 32, 3, 25);
}

Football Field lab 1

void setup(){
  size(500, 300);
  background(70, 190, 70);
  stroke(255);
  strokeWeight(10);
line(0, 0, 500, 0);
line(0, 0, 0, 300);
line(500, 300, 500, 0);
line(0, 300, 500, 300);
line(250, 0, 250, 300);
noFill();
ellipse(250, 150, 100, 100);
line(500, 100, 430, 100);
line(500, 200, 430, 200);
line(430, 200, 430, 100);
line(0, 100, 70, 100);
line(0, 200, 70, 200);
line(70, 200, 70, 100);
arc(0, 0, 60, 60, 0, PI/2);
arc(500, 300, 60, 60, PI, TWO_PI-PI/2);
arc(500, 0, 60, 60, PI/2, PI);
arc(0, 300, 60, 60, TWO_PI-PI/2, TWO_PI);

Star lab 1

void setup() {
  size(300, 300);
  background(255, 255, 11);
  noStroke();
  fill(0, 200, 200);
 quad(150, 0, 50, 300, 150, 200, 250, 300);
 triangle(0, 100, 300, 100, 150, 200);
 rotate(PI/18);
 fill(200, 10, 10);
 quad(150, 0, 50, 300, 150, 200, 250, 300);
 triangle(0, 100, 300, 100, 150, 200);
 rotate(PI/9);
 fill(10, 200, 10);
 quad(150, 0, 50, 300, 150, 200, 250, 300);
 triangle(0, 100, 300, 100, 150, 200);
 rotate(PI/8);
 fill(10, 10, 200);
 quad(150, 0, 50, 300, 150, 200, 250, 300);
 triangle(0, 100, 300, 100, 150, 200);
}

Hope lab 1

int colred=-1, colgreen=256, colblue=80;
void setup() {
  size(323, 200);
  background(11, 222, 111);
 if(colred > 254 || colred < 0){ colred = 255; }
 if(colblue > 254 || colblue < 0){ colblue = 255; }
 if(colgreen > 254 || colgreen < 0){ colgreen = 255; }
fill(colred, colgreen, colblue);
rect(60, 135, 170, 40);
rect(100, 105, 100, 30);
fill(1, 1, 1);
ellipse(100, 170, 35, 35);
ellipse(190, 170, 35, 35);
fill(200);
ellipse(100, 170, 30, 30);
ellipse(190, 170, 30, 30);
rect(110, 110, 35, 20);
rect(155, 110, 35, 20);
fill(1, 1, 1);
ellipse(100, 170, 20, 20);
ellipse(190, 170, 20, 20);
fill(255);
ellipse(70, 150, 15, 10);
}

Topic lab 1

int movex=75, movey=-10;
void setup() {
  size(323, 200);
  background(150, 50, 25);

fill(200);
rect(20+movex, 25+movey, 140, 150);
line(25+movex, 40+movey, 25+movex, 70+movey);
line(45+movex, 50+movey, 45+movex, 60+movey);
line(40+movex, 55+movey, 50+movex, 55+movey);
line(65+movex, 40+movey, 65+movex, 70+movey);
line(90+movex, 50+movey, 100+movex, 50+movey);
line(90+movex, 60+movey, 100+movex, 60+movey);
line(120+movex, 40+movey, 140+movex, 40+movey);
line(140+movex, 40+movey, 140+movex, 55+movey);
line(120+movex, 55+movey, 140+movex, 55+movey);
line(120+movex, 55+movey, 120+movex, 70+movey);
line(120+movex, 70+movey, 140+movex, 70+movey);
line(65+movex, 150+movey, 80+movex, 110+movey);
line(95+movex, 150+movey, 80+movex, 110+movey);
line(72+movex, 130+movey, 87+movex, 130+movey);
}

Tree lab 1

int x=30 ,y=0;
void setup() {
  size(323, 200);
  background(10, 185, 255);
  
fill(204, 102, 0);
rect(165+x, 110+y, 40, 10);
rect(145+x, 80+y, 20, 90);

fill(20, 155, 10);
ellipse(135+x, 46+y, 100, 80);
ellipse(175+x, 46+y, 100, 80);
ellipse(155+x, 46+y, 100, 80);

fill(204, 102, 0);
rect(105+x, 80+y, 20, 90);
rect(65+x, 80+y, 20, 90);
fill(20, 155, 10);
ellipse(85+x, 46+y, 100, 80);
ellipse(125+x, 46+y, 100, 80);
ellipse(105+x, 46+y, 100, 80);
ellipse(65+x, 46+y, 100, 80);
fill(155);
rect(195+x, 95+y, 10, 20);
}

Wednesday, 13 August 2014

Lab 0 (Tree, Topic, Hope)

void setup() {
  size(323, 200);
  background(10, 185, 255);
  
fill(204, 102, 0);
rect(165, 110, 40, 10);
rect(145, 80, 20, 90);

fill(20, 155, 10);
ellipse(135, 46, 100, 80);
ellipse(175, 46, 100, 80);
ellipse(155, 46, 100, 80);

fill(204, 102, 0);
rect(105, 80, 20, 90);
rect(65, 80, 20, 90);
fill(20, 155, 10);
ellipse(85, 46, 100, 80);
ellipse(125, 46, 100, 80);
ellipse(105, 46, 100, 80);
ellipse(65, 46, 100, 80);
fill(155);
rect(195, 95, 10, 20);
}


void setup() {
  size(323, 200);
  background(150, 50, 25);
  
fill(200);
rect(20, 25, 140, 150);
line(25, 40, 25, 70);
line(45, 50, 45, 60);
line(40, 55, 50, 55);
line(65, 40, 65, 70);
line(90, 50, 100, 50);
line(90, 60, 100, 60);
line(120, 40, 140, 40);
line(140, 40, 140, 55);
line(120, 55, 140, 55);
line(120, 55, 120, 70);
line(120, 70, 140, 70);
line(65, 150, 80, 110);
line(95, 150, 80, 110);
line(72, 130, 87, 130);
}


void setup() {
  size(323, 200);
  background(11, 222, 111);
  
fill(255, 10, 10);
rect(60, 135, 170, 40);
rect(100, 105, 100, 30);
fill(1, 1, 1);
ellipse(100, 170, 35, 35);
ellipse(190, 170, 35, 35);
fill(200)
ellipse(100, 170, 30, 30);
ellipse(190, 170, 30, 30);
rect(110, 110, 35, 20);
rect(155, 110, 35, 20);
fill(1, 1, 1);
ellipse(100, 170, 20, 20);
ellipse(190, 170, 20, 20);
fill(255);
ellipse(70, 150, 15, 10);


}