- 4.51.2.4.43. -
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.43. ogRect()
4.51.2.4.43. ogRect()
Targets: MS-DOS, Win32 console
ObjGfx40 Unit
Draws a rectangle.
Declaration:
procedure ogRect(x1, y1, x2, y2:int32; colour:uInt32);
Remarks:
Draws a rectangle using (x1,y1) as the upper left corner and (x2,y2)
as the lower right corner.
See also:
Sample code:
{ogRect.pas}
uses
ObjGfx40, CRT;
var
x1, y1, x2, y2:int32;
x1Dir, y1Dir, x2Dir, y2Dir:int32;
r, g, b:uInt8;
rDir, gDir, bDir:int32;
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;
x1Dir := -1;
y1Dir := 1;
x2Dir := 1;
y2Dir := -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);
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;
ogRect(x1, y1, x2, y2, ogRGB(r,g,b));
until keyPressed;
while keyPressed do readkey;
end.
- 4.51.2.4.43. -