Previous: 4.51.2.4.19. ogFillPolygon() To the Table of Contents Next: 4.51.2.4.21. ogFillTriangle()
4.51.2.4.19. ogFillPolygon() Table of Contents 4.51.2.4.21. ogFillTriangle()

- 4.51.2.4.20. -
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.20. ogFillRect()


4.51.2.4.20. ogFillRect()

Targets: MS-DOS, Win32 console


ObjGfx40 Unit

Draws a filled rectangle.

Declaration:
  procedure ogFillRect(x1, y1, x2, y2:int32; colour:uInt32);
Remarks:

Draws a filled rectangle. Equivilant to the bar() function of the Graph unit.

See also: Sample code:
{ogFillRect.pas}

uses
  ObjGfx40, CRT;

var 
  x1, y1, x2, y2:int32;
  x1Dir, y1Dir, x2Dir, y2Dir, 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;

  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;

      ogFillRect(x1, y1, x2, y2, ogRGB(r, g, b));
    until keyPressed;
  
  while keyPressed do readkey;
end.



Previous: 4.51.2.4.19. ogFillPolygon() To the Table of Contents Next: 4.51.2.4.21. ogFillTriangle()
4.51.2.4.19. ogFillPolygon() Table of Contents 4.51.2.4.21. ogFillTriangle()

- 4.51.2.4.20. -