如何填充图形窗口?

huangapple go评论54阅读模式
英文:

How to fill the graphic window?

问题

如何将一系列金字塔扩展到整个窗口?我在最后的块中输入了xy的值,但这对任何事情都没有影响。

英文:
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.

答案1

得分: 0

radpiramidkv过程中,您正在使用固定值的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); 
...

必须增加y的值以使金字塔在窗口的不同高度出现。
英文:

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.

huangapple
  • 本文由 发表于 2023年2月14日 02:16:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75439764.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定