Anda di halaman 1dari 22

NAMA :

NPM :

Kelas : VI Reg I Cluster II PIOT A

Dosen : Jodi Hendrawan, S.Kom, M.Kom

Matakuliah : Komputer Grafik


Praktikum 1:

buat layar output dengan ukuran bebas tetapi dengan bentuk bujur sangkar, kemudian beri warna
kuning, kemudian ungu, dan coklat.

Untuk Warna kuning

size(500, 500);

background(239,254,0);

Untuk Warna Coklat

size(500, 500);

background(97,59,4);

Untuk Warna ungu

size(500, 500);

background(185,0,254);
Praktikum 2

1.Buatlah sebuah objek lingkaran

2.Buatlah objek berikut dengan menggunakan kombinasi dari bentuk output primitive

lingkaran

size(500, 500);

rectMode(CENTER);

ellipse(130,120,100,100);

output primitive

size(500, 500);

rectMode(CENTER);

ellipse(240,130,70,70);

ellipse(270,80,70,70);

ellipse(210,80,70,70);
primitive

size(500, 500);

rectMode(CENTER);

fill(#6A5ACD);

rect(120,100,50,50);

rect(120,55,30,30);

rect(85,95,10,40);

rect(155,95,10,40);

rect(110,148,16,40);

rect(130,148,16,40);

ellipseMode(CENTER);

fill(255);

ellipse(114,60,10,10);

ellipse(127,60,10,10);
Praktikum 3

1.Buatlah sebuah objek seperti dimodul

2.Buatlah program untuk melakukan proses scalling

No..1

//Lingkaran pelangi

void setup(){

size(300,300);

smooth();

fill(#ff0000);

noStroke();

rect(100,100,90,20);

pushMatrix();

translate(100,100);

rotate(radians(20));

fill(#00FF7F );

rect(0,0,90,20);

popMatrix();

pushMatrix();
translate(100,100);

rotate(radians(40));

fill(#4682B4);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(60));

fill(#F4A460);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(80));

fill(#8B4513);

rect(0,0,90,20);

popMatrix();
pushMatrix();

translate(100,100);

rotate(radians(100));

fill(#668E23);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(120));

fill(#FFF500);

rect(0,0,90,20);

popMatrix();

pushMatrix();
translate(100,100);

rotate(radians(140));

fill(#BB8E23);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(160));

fill(#7B68EE );

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);
rotate(radians(180));

fill(#778899);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(200));

fill(#0000CD);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(220));

fill(#F08080);
rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(240));

fill(#ffff00);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(240));

fill(#00CED1);

rect(0,0,90,20);

popMatrix();
pushMatrix();

translate(100,100);

rotate(radians(260));

fill(#FF1499);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(280));

fill(#BDB766 );

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(300));

fill(#8B000B);

rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(320));

fill(#ffff00);
rect(0,0,90,20);

popMatrix();

pushMatrix();

translate(100,100);

rotate(radians(340));

fill(#006400 );

rect(0,0,90,20);

popMatrix();

Proses scalling dari sembarang titik

void setup()

size(500,500);

stroke(128);

triangle(43,83,73,33,103,83);

stroke(0);

pushMatrix();

scale(2.0);

triangle(43,83,70,30,100,80);

popMatrix();
}

void setup()

size(500,500);

stroke(128);

triangle(43,83,73,33,103,83);

stroke(0);

pushMatrix();

scale(2.0);

triangle(43,83,70,30,100,80);

popMatrix();

}
Praktikum 4

1. Buatlah program untuk membuat objek-objek lingkaran dengan menggunakan pengulangan for.

2.Buat program untuk membuat garis-garis vertical dengan menggunakan pengulangan for, ukuran
dan warna garis bebas.

Nomor 1.

int a;

int b;

void setup()

size(500,500);

noLoop();

void draw(){

for(b=400;b>=0;b=b-50)

fill(b-200,0,b);

stroke(b,0,0);

strokeWeight(2);

ellipse(300,300,b,b);

}
Nomor 2.

void setup()

size(500,500);

void draw()

{ stroke(265,0,0);

strokeWeight(5);

for (int i=10; i<400;i=i+10)

stroke(i,i+20,0);

line(i,0,i,400);

}
praktikum 5 Buatlah sebuah kurva gelombang sinus dengan menggunakan fungsi curve(),
curveVertex() dan bandingkan hasilnya.

//Curve()

int xw=400;

int x;

int yh=200;

int y;

void setup()

size (400,200);

noLoop();

background(50);

void draw (){

//untuk garis pembatas

for (y=0; y<=xw; y=y+50) { line(y,0,y,yh);}

for (x=0; x<=yh; x=x+50) {line(0,x,xw,x);}

//untuk kurva

stroke (255,0,0);

strokeWeight(5);

noFill();

curve(100,800,100,100,200,100,200,800);

curve(200,-600,200,100,300,100,300,-600);

}
//curveVertex()

void setup() {

size (600,400);

noLoop();

void draw (){

stroke (255,0,0);

strokeWeight(5);

noFill();

beginShape();

curveVertex(200, 200);

curveVertex(200,200);

curveVertex(255,150);

curveVertex(345,250);

curveVertex(400,200);

curveVertex(400,200);

endShape();

}
praktikum 6 Membuat objek bola

float frame = 0, speed = 1 / .0125, range = .125;

float rx = PI / 6, ry = -PI / 6, rmax = PI / 240;

void setup () {

size (400, 400, P3D);

void draw () {

if (!mousePressed) {

speed = constrain (dist (128, 128, mouseX, mouseY) / 128, 0, 1) * .02;

range = pow (constrain (dist (128, 128, mouseX, mouseY) / 128, 0, 1), 2) * .65;

} else {

rx = rx + (mouseX - pmouseX) * PI / width;

ry = constrain (ry - (mouseY - pmouseY) * PI / height, -HALF_PI, HALF_PI);

background (255);

translate (128, 128, -192); rotateX (ry); rotateY (rx);

noFill (); stroke (0, 0, 0, 31); box (256, 256, 256);

sphere (50); }

float cycle (float modifier, float displacement) { return cos ((frame * modifier + displacement) *
TWO_PI) / 2; }

class bone {

// constants

int maxchildren = 3;

// variables

float x, y, z, a, b ,c;

int len; bone[] children; }

Anda mungkin juga menyukai