X
xiuguo
Unregistered / Unconfirmed
GUEST, unregistred user!
我想模拟管道流动的画面,我的思路是在一个image控件上以currentposx为基点,划出一个
矩形,然后从currentposx+一个小矩形的宽度 开始画第二个。在一次话完之后,下一次从
currentposx+一个小矩形的宽度 div 4开始画....
可是为什么老是在image上面出现白色的板呢!谢谢!
变量声明:
drawimg:Timage;
arrowwidth,currentposx,arrowheight,i,inumber:integer;
procedure TForm4.FormCreate(Sender: TObject);
begin
currentposx:=0;
drawimg:=Timage.create(form4);
drawimg.parent:=form4;
drawimg.setbounds(50,50,30,400);
drawimg.Canvas.Brush.color:=clblue;
drawimg.Transparent:=true;
arrowwidth:=drawimg.width;
arrowheight:=drawimg.width*3 div 2;
inumber:=drawimg.height div (drawimg.width * 3 div 2);
end;
procedure TForm4.Timer1Timer(Sender: TObject);
begin
i:=0;
drawimg.Picture:=nil;
drawimg.Canvas.Brush.color:=clblue;
drawimg.Transparent:=true;
While i<inumber do
Begin
drawimg.canvas.Rectangle(0,currentposx, arrowwidth, currentposx+arrowheight div 2);
currentposx:=(currentposx+arrowheight+ drawimg.height) mod drawimg.height;
i:=i+1;
End;
currentposx:=(currentposx + arrowheight div 4 + drawimg.height) mod drawimg.height; //这样就好了!
end;
矩形,然后从currentposx+一个小矩形的宽度 开始画第二个。在一次话完之后,下一次从
currentposx+一个小矩形的宽度 div 4开始画....
可是为什么老是在image上面出现白色的板呢!谢谢!
变量声明:
drawimg:Timage;
arrowwidth,currentposx,arrowheight,i,inumber:integer;
procedure TForm4.FormCreate(Sender: TObject);
begin
currentposx:=0;
drawimg:=Timage.create(form4);
drawimg.parent:=form4;
drawimg.setbounds(50,50,30,400);
drawimg.Canvas.Brush.color:=clblue;
drawimg.Transparent:=true;
arrowwidth:=drawimg.width;
arrowheight:=drawimg.width*3 div 2;
inumber:=drawimg.height div (drawimg.width * 3 div 2);
end;
procedure TForm4.Timer1Timer(Sender: TObject);
begin
i:=0;
drawimg.Picture:=nil;
drawimg.Canvas.Brush.color:=clblue;
drawimg.Transparent:=true;
While i<inumber do
Begin
drawimg.canvas.Rectangle(0,currentposx, arrowwidth, currentposx+arrowheight div 2);
currentposx:=(currentposx+arrowheight+ drawimg.height) mod drawimg.height;
i:=i+1;
End;
currentposx:=(currentposx + arrowheight div 4 + drawimg.height) mod drawimg.height; //这样就好了!
end;