4.51.2.4.18. ogFillGouraudPolygon() | Table of Contents | 4.51.2.4.20. ogFillRect() |
procedure ogFillPolygon(numPoints:uInt32; var polyPoints: array of ogPoint2d; colour:uInt32);Remarks:
PolyPoints is an array of ogPoint that contains the coordinates of each intersection in the polygon. NumPoints specifies the number of coordinates in PolyPoints. A coordinate consists of two integers, an X and a Y value.
The anti-alias setting will affect whether the edges of the polygon are anti-aliased.
Unlike the FillPoly function in the Graph unit, this function is fully
re-entrant and capable of drawing complex polygons.
The scan converter accuracy problem and extra line bug present in ObjGfx 3.0 has been fixed.
See also:{ogFillPolygon.pas} uses ObjGfx40, CRT; const MAX_POINTS=10; var points: array [ 0..MAX_POINTS-1 ] of ogPoint2d; pointsDir:array [ 0..MAX_POINTS-1 ] of ogPoint2d; count:int32; r, g, b:uInt8; rDir, gDir, bDir:int32; buf:^ogSurface; begin randomize; new(buf,ogInit); if not Screen^.ogCreate(640,400,OG_PIXFMT_32BPP) then begin writeln('Error setting video mode'); halt end; buf^.ogClone(Screen^); r:=random(254)+1; g:=random(254)+1; b:=random(254)+1; rdir:=1; gdir:=-1; bdir:=1; for count:=0 to MAX_POINTS-1 do with points[count] do begin x := random(screen^.ogGetMaxX-1)+1; y := random(screen^.ogGetMaxY-1)+1; end; for count:=0 to MAX_POINTS-1 do with pointsDir[count] do begin if (random(100) > 50) then x := -1 else x := 1; if (random(100) > 50) then y := -1 else y := 1; end; repeat if (r = 0) or (r = 255) then rDir := -rDir else if (random(100) > 97) then rDir := -rDir; if (g = 0) or (g = 255) then gDir := -gDir else if (random(100) > 97) then gDir := -gDir; if (b = 0) or (b = 255) then bDir := -bDir else if (random(100) > 97) then bDir := -bDir; inc(r, rDir); inc(g, gDir); inc(b, bDir); for count:=0 to MAX_POINTS-1 do begin inc(points[count].x, pointsDir[count].x); if ((points[count].x = 0) or (points[count].x = screen^.ogGetMaxX)) then pointsDir[count].x := -pointsDir[count].x; inc(points[count].y, pointsDir[count].y); if ((points[count].y = 0) or (points[count].y = screen^.ogGetMaxY)) then pointsDir[count].y := -pointsDir[count].y; end; buf^.ogFillPolygon(MAX_POINTS, points, buf^.ogRGB(r, g, b)); screen^.ogCopy(buf^); buf^.ogClear(buf^.ogRGB(0, 0, 0)); until keyPressed; while keyPressed do readKey; dispose(buf, ogDone); end.
4.51.2.4.18. ogFillGouraudPolygon() | Table of Contents | 4.51.2.4.20. ogFillRect() |