1 / 20

PRIMITIVE OUTPUT Hilman Fauzi TSP, ST

GRAFIKA KOMPUTER. PRIMITIVE OUTPUT Hilman Fauzi TSP, ST. 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

amiel
Télécharger la présentation

PRIMITIVE OUTPUT Hilman Fauzi TSP, ST

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GRAFIKA KOMPUTER PRIMITIVE OUTPUTHilmanFauzi TSP, ST

  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/Tidakteratur (Bezier) Character  Type, Slanted, Thickness, Color, dll Primitive grafis

  3. Titik (Pixel/Dot) • 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. Titik (Pixel/Dot) 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. Y2 Y1 X1 X2 GARIS (LINE)

  6. Algoritma Pembuatan Garis • 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. Algoritma Pembuatan Garis

  8. DDA (Digital Differential Analyser) Algorithm • Jika 0m1  yk+1 = yk+ m xk+1 = xk + 1 • Jika m>1  xk+1 = xk + 1/m yk+1 = yk + 1

  9. Bresenham’s Algorithm Plot (Xo,Yo) Repeat If Pk<0 then Plot (Xk+1,Yk) Otherwise Plot (Xk+1,Yk+1) Until X=end

  10. Bresenham’s Algorithm • Contoh : Line (20,10,30,18) X = 10, Y = 8 Po = 2Y - X = 6 2.Y = 16 2Y - 2X = -4

  11. CIRCLE • 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. CIRCLE - Problem • Considerable computation at each step • Spacing between plotted pixel is not uniform. • Example :

  13. CIRCLE – cont. • Using polar coordinate approach : • Symmetric in octant  calculating only sector from x=0 to x=y Equally Spaced points

  14. Midpoint Circle Algorithm • (Xo,Yo)=(0,r); Plot (Xo,Yo) • P0 = 1 – r • Repeat If Pk<0 then X=X+1 Plot (X,Y) Pk+1 = Pk+2X+1 Otherwise X=X+1; Y=Y-1 Plot (X,Y) Pk+1 = Pk+2X– 2Y+1 • Until X  Y

  15. Midpoint Circle Algorithm – cont. • Example :

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

  17. Ellipse - cont • Polar : Reg.I ry rx Reg.II

  18. Midpoint Ellipse Algorithm Region I : • (xo,yo)=(0,ry); Plot (xo,yo) • P0 = ry2 – rx2ry+1/4rx2 • Px = 0; Py=2rx2y • While Px<Py x=x+1 Px = Px + 2ry2 If P  0 y=y-1 Py = Py – 2rx2 Pk+1 = Pk+ry2+Px-Py Otherwise Pk+1 = Pk+ry2+Px Plot(x,y) Region II : • Plot (xo,yo) • P0 = ry2 (x+½ )2+rx2(y-1)– rx2ry2 • While y>0 y=y-1 Py = Py - 2rx2 If P  0 x=x+1 Px = Px + 2ry2 Pk+1 = Pk+rx2+Px-Py Otherwise Pk+1 = Pk+rx2-Py Plot(x,y)

  19. Midpoint Ellipse Algorithm • Example : rx=8, ry=6 • Untuk Region I :

  20. Midpoint Ellipse Algorithm • Untuk Region II :

More Related