Presentation is loading. Please wait.

Presentation is loading. Please wait.

GRAFIKA KOMPUTER.  Pixel (Dot)  Posisi (x,y), Warna  Garis (Line)  Posisi (x1,y1,x2,y2), Warna, Thickness, Pattern  Lingkaran (Circle)  Pusat(x,y),

Similar presentations


Presentation on theme: "GRAFIKA KOMPUTER.  Pixel (Dot)  Posisi (x,y), Warna  Garis (Line)  Posisi (x1,y1,x2,y2), Warna, Thickness, Pattern  Lingkaran (Circle)  Pusat(x,y),"— Presentation transcript:

1 GRAFIKA KOMPUTER

2  Pixel (Dot)  Posisi (x,y), Warna  Garis (Line)  Posisi (x1,y1,x2,y2), Warna, Thickness, Pattern  Lingkaran (Circle)  Pusat(x,y), Radius, Warna, Thickness, Pattern  Ellipse  Pusat(x,y), Radius Horisonal/Vertikal, Warna, Thickness, Pattern  Kurva  Teratur/Tidak teratur (Bezier)  Character  Type, Slanted, Thickness, Color, dll

3 3  Pustaka Grafis (Library) BGI  putpixel (x,y,color) OPENGL  GL_Drawdot(x,y,color)  Low Level Programming - Interupt  H/W, S/W - DMA (Direct Memory Access) Modus Text : B800:0000h Modus Grafis: A000:0000h

4 4 void setpixel_DMA (x,y,color) { char *Segmen = 0xA0000000; (Segmen+(800*y+x)) = color; } procedure setpixel_DMA(x,y,color); begin mem[A000:(800*y+x)] := color; end;

5 5 Y2Y2 Y1Y1 X2X2 X1X1

6 6  Algoritma pembuatan garis lurus vertikal dan horisontal relatif mudah, tetapi bila garis tersebut miring, maka algoritma menjadi sulit.  Misal : Line (1,3,8,5)

7 7

8 8 Jika 0  m  1  y k+1 = y k + m x k+1 = x k + 1 Jika m>1  x k+1 = x k + 1/m y k+1 = y k + 1

9 9 Plot (Xo,Yo) Repeat If Pk<0 then Plot (X k+1,Y k ) Otherwise Plot (X k+1,Y k+1 ) Until X=end

10 10  Contoh : Line (20,10,30,18)  X = 10,  Y = 8 Po = 2  Y -  X = 6 2.  Y = 16 2  Y - 2  X = -4 KPkPk (X k+1,Y k+1 )KPkPk 06(21,11)56(26,15) 12(22,12)62(27,16) 2-2(23,12)7-2(28,16) 314(24,13)814(29,17) 410(25,14)910(30,18)

11 11  Defined as the set of points that are all at given distance r from a center position (Xc,Yc), expressed :  Calculate the position of points  stepping along x axis from (Xc-r) to (Xc+r) with :

12 12  Considerable computation at each step  Spacing between plotted pixel is not uniform.  Example : xy(x,y)xy xy 010(0,10)49,1(4,9)86(8,6) 19,9(1,10)58,6(5,9)94,5(9,5) 29,8(2,10)68(6,8)100(10,0) 39,5(3,10)77,1(7,7)

13 13  Using polar coordinate approach :  Symmetric in octant  calculating only sector from x=0 to x=y Equally Spaced points

14 14  (X o,Y o )=(0,r); Plot (X o,Y o )  P 0 = 1 – r  Repeat If P k <0 then X=X+1 Plot (X,Y) P k+1 = P k +2X+1 Otherwise X=X+1; Y=Y-1 Plot (X,Y) P k+1 = P k +2X– 2Y+1  Until X  Y

15 15  Example : k(X,Y)2X2YPkPk -(0,10)020-9 0(1,10)220-6 1(2,10)420 2(3,10)6206 3(4,9)818-3 4(5,9)10188 5(6,8)12165 6(7,7)14 6

16 16  Set of points such as the sum of the distance from two pixed position (foci) is the same for all points. F1 F2 d1 d2 P(x,y) d1+d2 = constant

17 17  Polar : Reg.I Reg.II ryry rxrx

18 18 Region I :  (x o,y o )=(0,r y ); Plot (x o,y o )  P 0 = r y 2 – r x 2 r y +1/4r x 2  P x = 0; P y =2r x 2 y  While P x <P y x=x+1 P x = P x + 2r y 2 If P  0 y=y-1 P y = P y – 2r x 2 P k+1 = P k +r y 2 +P x -P y Otherwise P k+1 = P k +r y 2 +P x Plot(x,y) Region II : Plot (x o,y o ) P 0 = r y 2 (x+½ ) 2 +r x 2 (y-1)– r x 2 r y 2 While y>0 y=y-1 P y = P y - 2r x 2 If P  0 x=x+1 P x = P x + 2r y 2 P k+1 = P k +r x 2 +P x -P y Otherwise P k+1 = P k +r x 2- P y Plot(x,y)

19 19  Example : r x =8, r y =6  Untuk Region I : k(x,y)PxPx PyPy PkPk 0(0,6)0768-332 1(1,6)72768-224 2(2,6)144768-44 3(3,6)216768208 4(4,5)288640-108 5(5,5)360640288 6(6,4)432512244 7(7,3)504384400

20 20 k(x,y)PxPx PyPy PkPk -----151 0(8,2)576256233 1(8,1)576128169 2(8,0)5760233 Untuk Region II :


Download ppt "GRAFIKA KOMPUTER.  Pixel (Dot)  Posisi (x,y), Warna  Garis (Line)  Posisi (x1,y1,x2,y2), Warna, Thickness, Pattern  Lingkaran (Circle)  Pusat(x,y),"

Similar presentations


Ads by Google