laporan dokumentasi
TRANSCRIPT
![Page 1: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/1.jpg)
LAPORAN DOKUMENTASI
PRAKTIKUM KOMPUTER GRAFIK
NAMA : ANGGA SAPUTRA
NIM : 2009230033
JURUSAN : TEKNIK INFORMATIKA
![Page 2: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/2.jpg)
Pertemuan 1
Membuat raster grafik (objek) membentuk huruf H , caranya :
1. Ketik pada Command Window : x = [100,0,100; 100 100 100; 100 0 100] (Enter)2. Ketik image (x)3. Lihat hasil pada window figure
LAPORAN KOMPUTER GRAFIK PERTEMUAN 1 TANGGAL 10 MARET 2011
Menggambar huruf A dengan MATLAB
b=[100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 0 0 0 0 0 0 0 0 0 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 ]
Image (b)
Hasilnya :
![Page 3: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/3.jpg)
u= [100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100
;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
![Page 4: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/4.jpg)
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
![Page 5: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/5.jpg)
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100;
100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100;
100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100;
100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100;
100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 0 100 100 100 100 100 100 100 100;]
Pertemuan 2
Membuat garis dan menghubungkannya
Source :
pDC->MoveTo(100,100);pDC->LineTo(300,300);pDC->LineTo(500,300);pDC->LineTo(400,200);pDC->LineTo(300,150);pDC->LineTo(100,100);
Hasilnya :
![Page 6: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/6.jpg)
Membuat laying –layang
Source :
pDC->MoveTo(100,100);pDC->LineTo(60,200);pDC->LineTo(100,220);pDC->LineTo(100,100);pDC->LineTo(140,200);pDC->LineTo(100,220);
Hasilnya :
Pertemuan 3
Membuat bentuk-bentuk GEOMETRI (bangun-bangun beraturan)
1. Membuat kotak persegi panjangSouce : pDC->Rectangle(200,100,400,200);Hasilnya :
![Page 7: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/7.jpg)
2. Membuat kotak persegi Source : pDC->Rectangle(500,100,600,200);Hasilnya :
3. Membuat kotak persegi panjang tegakSource : pDC->Rectangle(700,100,800,500);Hasilnya :
4. Membuat LingkaranSource : pDC->Ellipse(200,100,400,200);
pDC->Ellipse(450,100,550,200);Hasilnya :
![Page 8: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/8.jpg)
5. Membuat Kotak persegi dengan pojok melengkungSource : pDC->RoundRect(200,100,400,200,40,40);Hasilnya :
6. Membuat lingkaran terpotong dengan garisSource : pDC->Chord(200,100,400,200,300,100,400,150);Hasilnya :
7. Membuat lingkaran terpotong tanpa garisSource : pDC->Arc(50,250,150,350,100,250,150,300);Hasilnya :
![Page 9: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/9.jpg)
8. Membuat lingkaran terpotong dengan garis terpusatSource : pDC->Pie(450,100,550,200,520,120,550,150);Hasilnya :
9. Membuat lapangan bolaSource : pDC->Rectangle(100,100,700,500);
pDC->Arc(600,200,800,400,700,200,700,400);pDC->Arc(0,200,200,400,100,400,100,200);pDC->MoveTo(400,100);pDC->Ellipse(300,200,500,400);pDC->LineTo(400,500);
Hasilnya :
Pertemuan 4
1. Membuat bangun setengah lingkaran dengan warna (border solid)Source :float x1=50, y1=150, a=50;
![Page 10: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/10.jpg)
CPen garisBaru;garisBaru.CreatePen(PS_SOLID,8,RGB(255,0,0));CPen *garis = pDC->SelectObject(&garisBaru);pDC->Chord(x1,y1,x1+6*a,y1+6*a,x1+6*a,y1+3*a,x1,y1+3*a);Hasilnya :
2. Membuat bangun setengah lingkaran dengan warna (border dash)Source :float x1=50, y1=150, a=50;CPen garisBaru;garisBaru.CreatePen(PS_DASH,1,RGB(255,0,0));CPen *garis = pDC->SelectObject(&garisBaru);pDC->Chord(x1,y1,x1+6*a,y1+6*a,x1+6*a,y1+3*a,x1,y1+3*a);Hasilnya :
3. Membuat balonSource : float x1=50, y1=150, a=50;CPen garisBaru;garisBaru.CreatePen(PS_DASH,1,RGB(255,0,0));CPen *garis = pDC->SelectObject(&garisBaru);pDC->Chord(x1,y1,x1+6*a,y1+6*a,x1+6*a,y1+3*a,x1,y1+3*a);pDC ->Rectangle(x1+a,y1+3*a,x1+5*a,y1+6*a);Hasilnya :
4. Membuat balon 2Source :float x1=50, y1=150, a=50;
![Page 11: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/11.jpg)
CPen garisBaru;garisBaru.CreatePen(PS_SOLID,5,RGB(255,0,0));CPen *garis = pDC->SelectObject(&garisBaru);pDC->Chord(x1,y1,x1+6*a,y1+6*a,x1+6*a,y1+3*a,x1,y1+3*a);pDC ->Rectangle(x1+a,y1+3*a,x1+5*a,y1+6*a);
CPen garisBaru1;garisBaru1.CreatePen(PS_SOLID,5,RGB(0,255,0));CPen *garis1 = pDC->SelectObject(&garisBaru1);pDC->Chord(x1+7*a,y1-a,x1+13*a,y1+6*a,x1+13*a,y1+3*a,x1+6*a,y1+3*a);pDC ->Rectangle(x1+8*a,y1+3*a,x1+12*a,y1+6*a);Hasilnya :
5. Membuat balon 3Source :float x1=50, y1=150, a=50;CPen garisBaru;garisBaru.CreatePen(PS_SOLID,5,RGB(255,0,0));CPen *garis = pDC->SelectObject(&garisBaru);pDC->Chord(x1,y1,x1+6*a,y1+6*a,x1+6*a,y1+3*a,x1,y1+3*a);pDC ->Rectangle(x1+a,y1+3*a,x1+5*a,y1+6*a);
CPen garisBaru1;garisBaru1.CreatePen(PS_DOT,1,RGB(0,255,0));CPen *garis1 = pDC->SelectObject(&garisBaru1);pDC->Chord(x1+7*a,y1-a,x1+11*a,y1+3*a,x1+11*a,y1+a,x1+7*a,y1+a);pDC ->Rectangle(x1+7.75*a,y1+a,x1+10.25*a,y1+3*a);Keterangan : warna merah : menentukan jenis garis
Warna hijau : menetukan ukuran garisHasilnya :
![Page 12: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/12.jpg)
6. Membuat balon 4Source :float x1=50, y1=150, a=50;CPen garisBaru;garisBaru.CreatePen(PS_SOLID,5,RGB(255,0,0));CPen *garis = pDC->SelectObject(&garisBaru);pDC->Chord(x1,y1,x1+6*a,y1+6*a,x1+6*a,y1+3*a,x1,y1+3*a);pDC ->Rectangle(x1+a,y1+3*a,x1+5*a,y1+6*a);
CPen garisBaru1;garisBaru1.CreatePen(PS_SOLID,5,RGB(0,255,0));CPen *garis1 = pDC->SelectObject(&garisBaru1);pDC->Chord(x1+7*a,y1-a,x1+11*a,y1+3*a,x1+11*a,y1+a,x1+7*a,y1+a);pDC ->Rectangle(x1+7.75*a,y1+a,x1+10.25*a,y1+3*a);
CPen garisBaru2;garisBaru2.CreatePen(PS_SOLID,5,RGB(0,0,255));CPen *garis2 = pDC->SelectObject(&garisBaru2);pDC->Chord(x1+12*a,y1-2*a,x1+14*a,y1,x1+14*a,y1-a,x1+12*a,y1-a);pDC ->Rectangle(x1+12.25*a,y1-a,x1+13.75*a,y1);Hasilnya :
Pertemuan 5
1. Transformasi 1
![Page 13: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/13.jpg)
Source :int x1=50, x2=200, x3=200, x4=50, y1=50, y2=50, y3=150, y4=150, trX=200, trY=150;
int x11,x12,x13,x14,y11,y12,y13,y14;
x11=x1+trX;x12=x2+trX;x13=x3+trX;x14=x4+trX;
y11=y1+trY;y12=y2+trY;y13=y3+trY;y14=y4+trY;
/*pDC->MoveTo(x1,y1);pDC->LineTo(x2,y2);pDC->LineTo(x3,y3);pDC->LineTo(x4,y4);pDC->LineTo(x1,y1);*/
pDC->Rectangle(x1,y1,x2,y3);
CPen garisBaru;garisBaru.CreatePen(PS_SOLID,1,RGB(255,0,0));CPen *garis=pDC->SelectObject(&garisBaru);
pDC->MoveTo(x11,y11);pDC->LineTo(x12,y12);pDC->LineTo(x13,y13);pDC->LineTo(x14,y14);pDC->LineTo(x11,y11);
Hasilnya :
2. Transformasi 2 (cara 1)
![Page 14: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/14.jpg)
Source :int x1=50,x2=200,x3=150,y1=50,y2=50,y3=150,trX=200,trY=150,sx=2,sy=2;int x11,x12,x13,y11,y12,y13;
x11=sx*x1+trX;x12=sx*x2+trX;x13=sx*x3+trX;
y11=sy*y1+trY;y12=sy*y2+trY;y13=sy*y3+trY;
//pDC->MoveTo(x1,y1);pDC->LineTo(x2,y2);pDC->LineTo(x3,y3);pDC->LineTo(x1,y1);
CPen garisBaru;garisBaru.CreatePen(PS_SOLID,1,RGB(255,0,0));CPen *garis=pDC->SelectObject(&garisBaru);pDC->MoveTo(x11,y11);pDC->LineTo(x12,y12);pDC->LineTo(x13,y13);pDC->LineTo(x11,y11);
Hasilnya :
3. Transformasi 2 (cara 2)Source :
int x1=50,x2=200,x3=150,y1=50,y2=50,y3=150,trX=200,trY=150,sx=2,sy=2;
![Page 15: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/15.jpg)
int x11,x12,x13,y11,y12,y13;
x11=sx*x1+trX;x12=sx*x2+trX;x13=sx*x3+trX;
y11=sy*y1+trY;y12=sy*y2+trY;y13=sy*y3+trY;
//POINT s3[]={x1,y1,x2,y2,x3,y3};pDC->Polygon(s3,3);
CPen garisBaru;garisBaru.CreatePen(PS_SOLID,1,RGB(255,0,0));CPen *garis=pDC->SelectObject(&garisBaru);POINT s13[]={x11,y11,x12,y12,x13,y13};pDC->Polygon(s13,3);
Hasilnya ;
4. Transformasi 2 (cara 3)Source :int x1=50,x2=200,x3=150,y1=50,y2=50,y3=150,trX=200,trY=150,sx=2,sy=2;int x11,x12,x13,y11,y12,y13;
x11=sx*x1+trX;x12=sx*x2+trX;
![Page 16: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/16.jpg)
x13=sx*x3+trX;
y11=sy*y1+trY;y12=sy*y2+trY;y13=sy*y3+trY;//POINT s3[]={x1,y1,x2,y2,x3,y3,x11,y11,x12,y12,x13,y13};int jumPoly[]={3,3};pDC->PolyPolygon(s3,jumPoly,2);
Hasilnya :
Pertemuan 6
1. Membuat kotak berwarnaSource : CBrush kotakMerah(RGB(255,0,0));CBrush *warnaMerah = pDC->SelectObject(&kotakMerah);pDC->Rectangle(100,100,300,200);Hasil :
2. Membuat kotak berwarna (arsir)Source : CBrush kotakArsirHijau(HS_DIAGCROSS,RGB(0,255,0));CBrush *warnaArsirHijau = pDC ->SelectObject(&kotakArsirHijau);pDC->Rectangle(400,100,600,200);Hasilnya :
![Page 17: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/17.jpg)
Pertemuan 7
1. Membuat polygonSOURCE :int x1=50;int y1=50;int delta=50;int x2,x3,x4,x5,x6,y2,y3,y4,y5,y6;
x2=x1+50; y2=y1;x3=x2+100; y3=y2+100;x4=x3; y4=y3+50;x5=x4-50;y5=y4;x6=x5-100; y6=y5-100;
CBrush merah(RGB(255,0,0));CBrush *mrh=pDC->SelectObject(&merah);POINT setTitik[6] = {x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6};pDC->Polygon(setTitik,6);Hasilnya:
2. Membuat polygon (kombinasi)Source :int x1=50;int y1=50;int delta=50;int x2,x3,x4,x5,x6,y2,y3,y4,y5,y6,x7,y7,x8,y8,x9,y9;
x2=x1+delta; y2=y1;x3=x2+2*delta; y3=y2+2*delta;x4=x3; y4=y3+delta;x5=x4-delta; y5=y4;x6=x5-2*delta; y6=y5-2*delta;x7=x6-delta; y7=y5+delta;
CBrush merah(RGB(255,0,0));CBrush *mrh=pDC->SelectObject(&merah);POINT setTitik[9] = {x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x6,y6,x5,y5,x7,y7};int ppgon[]={6,3};pDC->PolyPolygon(setTitik,ppgon,2);
![Page 18: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/18.jpg)
hasilnya :
Pertemuan 8
1. PencerminanSource :int x,y;//membuat garis y=300pDC->MoveTo(50,300);for(x=50,y=300;x<=700;x++){Sleep(5); // Sleep mengatur kecepatan loading, jika tanpa ‘Sleep’ loading cepatpDC->LineTo(x,y); }int x1=100, y1=400,x2=300,y2=600,sbtr=300;int x11,y11,x21,y21;x11=x1;y11=2*sbtr-y1;x21=x2;y21=2*sbtr-y2;pDC->Rectangle(x1,y1,x2,y2); pDC->Rectangle(x11,y11,x21,y21);Hasilnya :
2. Pencerminan 2Source :int x,y;//membuat garis y = 300pDC->MoveTo(50,300);for(x=50,y=300;x<=700;x++)
![Page 19: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/19.jpg)
{Sleep(5); // Sleep mengatur kecepatan loading, jika tanpa ‘Sleep’ loading cepatpDC->LineTo(x,y); }int x1=100, y1=400,x2=300,y2=600,sbtr=300;int x11,y11,x21,y21;x11=x1;y11=2*sbtr-y1;x21=x2;y21=2*sbtr-y2;CPen grsHitam;grsHitam.CreatePen(PS_SOLID,5,RGB(0,0,0));CPen*grs1=pDC->SelectObject(&grsHitam);pDC->Rectangle(x1,y1,x2,y2);CPen grsMerah;grsMerah.CreatePen(PS_SOLID,5,RGB(255,0,0));CPen*grs=pDC->SelectObject(&grsMerah); pDC->Rectangle(x11,y11,x21,y21);
Hasilnya ;
3. Pencerminan 3Source :int x,y;//membuat garis x=300pDC->MoveTo(300,50);for(x=300,y=50;y<=700;y++){
Sleep(3); // Sleep mengatur kecepatan loading, jika tanpa ‘Sleep’ loading cepatpDC->LineTo(x,y); }int x1=50, y1=350,x2=250,y2=550,sbtr=300;
![Page 20: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/20.jpg)
int x11,y11,x21,y21;x11=2*sbtr-x1;y11=y1;x21=2*sbtr-x2;y21=y2;CPen grsHitam;grsHitam.CreatePen(PS_SOLID,5,RGB(0,0,0));CPen*grs1=pDC->SelectObject(&grsHitam);pDC->Rectangle(x1,y1,x2,y2);CPen grsMerah;grsMerah.CreatePen(PS_SOLID,5,RGB(255,0,0));CPen*grs=pDC->SelectObject(&grsMerah);pDC->Rectangle(x11,y11,x21,y21);
Hasilnya :
4. Pencerminan 4Source :int x,y;//membuat garis x=ypDC->MoveTo(50,50);for(x=50,y=50;y<=700;x++,y++){
Sleep(3); // Sleep mengatur kecepatan loading, jika tanpa ‘Sleep’ loading cepatpDC->LineTo(x,y); }int x1=50, y1=350,x2=250,y2=550,sbtr=300;int x11,y11,x21,y21;x11=y1;y11=x1;x21=y2;y21=x2;CPen grsHitam;grsHitam.CreatePen(PS_SOLID,5,RGB(0,0,0));CPen*grs1=pDC->SelectObject(&grsHitam);pDC->Rectangle(x1,y1,x2,y2);
![Page 21: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/21.jpg)
CPen grsMerah;grsMerah.CreatePen(PS_SOLID,5,RGB(255,0,0));CPen*grs=pDC->SelectObject(&grsMerah);pDC->Rectangle(x11,y11,x21,y21);Hasilnya :
Pertemuan 9
1. Transformasi PemutaranSource :int x1,x2,x3,x4,x5,x6,x7;
int y1,y2,y3,y4,y5,y6,y7;
x1=50;y1=y3=y4=y7=150;x2=200; x3=350; x4=x5=300;x6=x7=100; y2=0; y5=y6=300;
POINT panah1[14]={x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7};pDC->Polygon(panah1,7);
int x11,x21,x31,x41,x51,x61,x71;int y11,y21,y31,y41,y51,y61,y71;
x11 = x1*cos(60*3.14/180) - y1*sin(60*3.14/180);y11 = x1*sin(60*3.14/180) + y1*cos(60*3.14/180);x21 = x2*cos(60*3.14/180) - y2*sin(60*3.14/180);y21 = x2*sin(60*3.14/180) + y2*cos(60*3.14/180);x31 = x3*cos(60*3.14/180) - y3*sin(60*3.14/180);y31 = x3*sin(60*3.14/180) + y3*cos(60*3.14/180);x41 = x4*cos(60*3.14/180) - y4*sin(60*3.14/180);y41 = x4*sin(60*3.14/180) + y4*cos(60*3.14/180);x51 = x5*cos(60*3.14/180) - y5*sin(60*3.14/180);
![Page 22: LAPORAN DOKUMENTASI](https://reader031.vdocuments.site/reader031/viewer/2022020712/5476e255b4af9f05178b45cc/html5/thumbnails/22.jpg)
y51 = x5*sin(60*3.14/180) + y5*cos(60*3.14/180);x61 = x6*cos(60*3.14/180) - y6*sin(60*3.14/180);y61 = x6*sin(60*3.14/180) + y6*cos(60*3.14/180);x71 = x7*cos(60*3.14/180) - y7*sin(60*3.14/180);y71 = x7*sin(60*3.14/180) + y7*cos(60*3.14/180);
POINT panah2[14]={x11,y11,x21,y21,x31,y31,x41,y41,x51,y51,x61,y61,x71,y71};pDC->Polygon(panah2,7);
Hasilnya :