pascal

How to fill the graphic window?


uses GraphABC; 
 
var 
  x, y: integer; 
 
  procedure kv(x, y: integer; color: system.Drawing.Color); 
  begin 
    Rectangle(x, y, x + 20, y - 50); 
    FloodFill(x + 10, y - 10, color); 
  end; 
  
  procedure radpiramid;
  begin 
    x := 80; 
  
    while x < 640 do 
    begin 
      SetPenColor(clBlack); 
      kv(x - 40, 50, clGreen); 
      y := 100; 
      for var i := 1 to 3 do 
      kv(x - 20 * i, y, clOrange); 
        y := 150; 
      for var i := 1 to 5 do 
        kv(x + 40 - 20 * (i + 1), y, clRed); 
      x := x + 105; 
    end
  end;
   
begin     
  while y <= windowHeight do
  begin
    radpiramid;
  end;

end. 

How to extend a series of pyramids to the entire window? I enter the values of x and y in the last block, but this does not affect anything.


Solution

  • Inside the radpiramid procedure and kv procedure you using a fixed value of y.

    procedure kv(x, y: integer; color: system.Drawing.Color); 
    ...
      Rectangle(x, y, x + 20, y - 50);   <----------------
    ...
    
    procedure radpiramid;
    ...
        kv(x - 40, 50, clGreen); 
        y := 100;   <-------------------- 
        for var i := 1 to 3 do 
        kv(x - 20 * i, y, clOrange); 
          y := 150; <-----------------------
        for var i := 1 to 5 do 
          kv(x + 40 - 20 * (i + 1), y, clRed); 
    ...
    

    You must increase this value of y to get pyramids to appear at different heights of the window.