Muhammad Ripal - Praktikum 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

NAMA : MUHAMMAD RIPAL

NIM : 1804411103
KELAS : 7 GAB 2 MULTIMEDIA
MATA KULIAH : GRAFIKA KOMPUTER

LAPORAN PRAKTIKUM 2
Program Hasil Program

Program 2.1 Hasil Program 2.1


int d = 40;
int p1 = d;
int p2 = p1+d;
int p3 = p2+d;
int p4 = p3+d;
size(200, 200);
background(0);
//Draw line from location (50,50) until
(100,150)
stroke(255);
line(50, 50, 100, 150);

// Draw gray box


stroke(255);
line(p3, p3, p2, p3);
line(p2, p3, p2, p2);
line(p2, p2, p3, p2);
line(p3, p2, p3, p3);

// Draw white points


stroke(255);
point(p1, p1);
point(p1, p3);
point(p2, p4);
point(p3, p1);
point(p4, p2);
point(p4, p4);

Program 2.2 Hasil Program 2.2


size(200, 200);
background(0);

// Draw white line standart


stroke(255);
line(25, 5, 175, 5);
// Draw red line
stroke(255,0,0);
line(25, 25, 175, 25);
// Draw Green line with 5 points thicknes
stroke(0,255,0);
strokeWeight(5);
line(25, 50, 175, 50);
//Draw Blue line with 10 thickness and
square tip line
stroke(0,0,255);
strokeWeight(10);
strokeCap(SQUARE);
line(25, 75, 175, 75);

Program 2.3 Hasil Program 2.3


size(400,150);
background(255);
//draw ellipse
fill(255,0,0);
ellipse(50,50,75,100);
// draw arc 90 degree clockwise
fill(0,0,255);
arc(100,50,100,100,0,1.57);
// draw arc 90 degree
fill(0,255,0);
arc(175,50,100,100,(0*PI)/180,(90*PI)/180);
// draw arc 90 degree
noFill();
stroke(255,0,0);
arc(250,50,100,100,(0*PI)/180,(90*PI)/180);

Program 2.4 Hasil Program 2.4


size(200, 200);
smooth();
background(0);
noStroke(); fill(226); triangle(10, 10, 10, 200,
45, 200); rect(45, 45, 35, 35); quad(105, 10,
120, 10, 120, 200, 80, 200); triangle(160, 10,
195, 200, 160, 200);
Program 2.5 Program 2.5
beginShape(TRIANGLES);
vertex(30, 75);
vertex(40, 20);
vertex(50, 75);
vertex(60, 20);
vertex(70, 75);
vertex(80, 20);
endShape();

Program 2.6 Program 2.6


beginShape(TRIANGLE_STRIP);
vertex(30, 75);
vertex(40, 20);
vertex(50, 75);
vertex(60, 20);
vertex(70, 75);
vertex(80, 20);
vertex(90, 75);
endShape();

Program 2.7 Program 2.7


beginShape(TRIANGLE_FAN);
vertex(57.5, 50);
vertex(57.5, 15);
vertex(92, 50);
vertex(57.5, 85);
vertex(22, 50);
vertex(57.5, 15);
endShape();
Program 2.8 Program 2.8
beginShape(QUADS);
vertex(30, 20);
vertex(30, 75);
vertex(50, 75);
vertex(50, 20);
vertex(65, 20);
vertex(65, 75);
vertex(85, 75);
vertex(85, 20);
endShape();
Program 2.9 Program 2.9
beginShape();
vertex(20, 20);
vertex(40, 20);
vertex(40, 40);
vertex(60, 40);
vertex(60, 60);
vertex(20, 60);
endShape(CLOSE);

Program 2.10 Program 2.10


beginShape(QUAD_STRIP);
vertex(30, 20);
vertex(30, 75);
vertex(50, 20);
vertex(50, 75);
vertex(65, 20);
vertex(65, 75);
vertex(85, 20);
vertex(85, 75);
endShape();

TUGAS
1. Buatlah sebuah objek lingkaran

2. Buatlah objek berikut dengan menggunakan kombinasi dari bentuk


JAWAB

1. void setup (){


size (600, 400);
background (255, 255, 255);
}

void draw (){


//Lingkaran 1
stroke(0,0,0);
fill(255,255,255);
ellipse(260, 165, 80, 80);

//Lingkaran 2
stroke(0,0,0);
fill(255,255,255);
ellipse(340, 165, 80, 80);

//Lingkaran 3
stroke(0,0,0);
fill(255,255,255);
ellipse(300, 235, 80, 80);
}
2. void setup (){
size (600, 400);
background (255, 255, 255);
}

void draw (){


//kepala
stroke(0,0,255);
fill(0,0,255);
rect(95, 10, 80, 60);

//badan
stroke(0,0,255);
fill(0,0,255);
rect(70, 75, 130, 130);

//tangan kanan
stroke(0,0,255);
fill(0,0,255);
rect(25, 75, 40, 90);

//tangan kiri
stroke(0,0,255);
fill(0,0,255);
rect(205, 75, 40, 90);

//kaki kanan
stroke(0,0,255);
fill(0,0,255);
rect(90, 210, 40, 150);

//kaki kiri
stroke(0,0,255);
fill(0,0,255);
rect(140, 210, 40, 150);

//mata kanan
stroke(200,200,255);
fill(200,200,255);
ellipse(120, 30, 20, 20);

//Mata Kiri
stroke(200,200,255);
fill(200,200,255);
ellipse(150, 30, 20, 20);

//Lingkaran 1
stroke(0,0,0);
fill(255,255,255);
ellipse(400, 90, 80, 80);

//Lingkaran 2
stroke(0,0,0);
fill(255,255,255);
ellipse(480, 90, 80, 80);

//Lingkaran 3
stroke(0,0,0);
fill(255,255,255);
ellipse(440, 160, 80, 80);
}

You might also like