- 4.51.2.4.60. -
Table of Contents
4. Standard Units
4.51. ObjGfx40 - ObjectGraphics 4.0 Unit
4.51.2. ObjGfx40 Unit Object Types
4.51.2.4. ogSurface object
4.51.2.4.60. ogTriangle()
4.51.2.4.60. ogTriangle()
Targets: MS-DOS, Win32 console
ObjGfx40 Unit
Draws a triangle.
Declaration:
procedure ogTriangle(x1, y1, x2, y2, x3, y3:int32; colour:uInt32);
Remarks:
Draws a triangle. Will draw an antialiased triangle if antialiasing
is set to TRUE.
See also:
Sample code:
{ogTriangle.pas}
uses
ObjGfx40, CRT;
var
x1, y1, x2, y2, x3, y3:int32;
x1Dir, y1Dir, x2Dir, y2Dir, x3Dir, y3Dir, rDir, gDir, bDir:int32;
r, g, b:uInt8;
begin
randomize;
if not screen^.ogCreate(800, 600, OG_PIXFMT_32BPP) then
begin
writeln('Error setting video mode');
halt
end;
x1 := random(screen^.ogGetMaxX-1)+1;
y1 := random(screen^.ogGetMaxY-1)+1;
x2 := random(screen^.ogGetMaxX-1)+1;
y2 := random(screen^.ogGetMaxY-1)+1;
x3 := random(screen^.ogGetMaxX-1)+1;
y3 := random(screen^.ogGetMaxY-1)+1;
x1dir := -1;
y1dir := 1;
x2dir := 1;
y2dir := -1;
x3dir := -1;
y3dir := 1;
r := random(254)+1;
g := random(254)+1;
b := random(254)+1;
rDir := 1;
gDir := -1;
bDir := 1;
with screen^ do
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);
inc(x1, x1Dir);
inc(y1, y1Dir);
inc(x2, x2Dir);
inc(y2, y2Dir);
inc(x3, x3Dir);
inc(y3, y3Dir);
if (x1 = 0) or (x1 = ogGetMaxX) then x1Dir := -x1Dir;
if (y1 = 0) or (y1 = ogGetMaxY) then y1Dir := -y1Dir;
if (x2 = 0) or (x2 = ogGetMaxX) then x2Dir := -x2Dir;
if (y2 = 0) or (y2 = ogGetMaxY) then y2Dir := -y2Dir;
if (x3 = 0) or (x3 = ogGetMaxX) then x3Dir := -x3Dir;
if (y3 = 0) or (y3 = ogGetMaxY) then y3Dir := -y3Dir;
ogTriangle(x1, y1, x2, y2, x3, y3, ogRGB(r, g, b));
until keyPressed;
while keyPressed do readkey;
end.
- 4.51.2.4.60. -