4.51.2.4.58. ogSetTransparentColor() | Table of Contents | 4.51.2.4.60. ogTriangle() |
procedure ogSpline(numPoints: uInt32; var points: array of ogPoint2d; segments, colour:uInt32);Remarks:
Draws a smooth curve through the number of points (numPoints) defined in the Points array.
Segments is the number of line segments to use inbetween each point. The higher the number, the smoother the spline looks, but the longer it takes to render.
Will render with antialiased lines if antialiasing is active in the surface.
See also: Sample code:{ogSpline.pas} uses ObjGfx40, CRT; const MAX_NODES = 6; var i:uInt32; points: array [ 0..MAX_NODES-1 ] of ogPoint2d; dX, dY: array [ 0..MAX_NODES-1 ] of int32; var buf:^ogSurface; begin randomize; new(buf,ogInit); if not screen^.ogCreate(640, 480, OG_PIXFMT_32BPP) then begin writeln('Error setting video mode'); halt end; buf^.ogClone(screen^); with buf^ do for i:=0 to MAX_NODES-1 do begin points[i].X := random(ogGetMaxX); points[i].Y := random(ogGetMaxY); dX[i] := random(4)+1; dY[i] := random(4)+1; end; repeat buf^.ogClear(buf^.ogRGB(0, 0, 0)); for i:=0 to MAX_NODES-1 do begin points[i].x := points[i].x+dX[i]; if (points[i].x >= buf^.ogGetMaxX) or (points[i].x <= 0) then dX[i] := -dX[i]; points[i].y := points[i].Y+DY[i]; if (points[i].y >= buf^.ogGetMaxY) or (points[i].y <= 0) then dY[i] := -dY[i]; buf^.ogFillCircle(points[i].x, points[i].y, 5, buf^.ogRGB(0, 128, 128)); end; {Draw a spline in blue} buf^.ogSpline(MAX_NODES, points, 20, buf^.ogRGB(128, 128, 255)); {draw a BSpline in red} buf^.ogBSpline(MAX_NODES, points, 20, buf^.ogRGB(255, 128, 128)); screen^.ogCopy(buf^); until keyPressed; while keyPressed do readKey; dispose(buf, ogDone); end.
4.51.2.4.58. ogSetTransparentColor() | Table of Contents | 4.51.2.4.60. ogTriangle() |