1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;
type TForm1 = class(TForm) Timer1: TTimer; Image1: TImage; procedure Timer1Timer(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private Bit : TBitmap; public end;
var Form1: TForm1;
implementation
{$R *.dfm}
var pos : Array[1..50] of TPoint; procedure TForm1.Timer1Timer(Sender: TObject); var x, y, i : Integer; begin for x := 0 to Bit.Width div Image1.Width do begin for y := 0 to Bit.Height div Image1.Height do begin Bit.Canvas.Draw(x * Image1.Width, y * Image1.Height, Image1.Picture.Bitmap); end; end; for i := 1 to 50 do begin Inc(pos[ i ].x, 1 + i mod 2); Inc(pos[ i ].y, 2 - i mod 2); if pos[ i ].x > ClientWidth then pos[ i ].x := -100; if pos[ i ].y > ClientHeight then pos[ i ].y := -100; Bit.Canvas.Draw(0, 0, nil); Bit.Canvas.Brush.Color := i * $FFFFFF div 20; Bit.Canvas.Rectangle(pos[ i ].x, pos[ i ].y, pos[ i ].x + 100, pos[ i ].y + 100); end; Canvas.Draw(0, 0, Bit); end;
procedure TForm1.FormCreate(Sender: TObject); var i : Integer; begin Timer1.Interval := 1; Bit := TBitmap.Create; Bit.Width := ClientWidth; Bit.Height := ClientHeight; for i := 1 to 50 do begin pos[ i ].X := Random(ClientWidth); pos[ i ].Y := Random(ClientHeight); end; end;
procedure TForm1.FormDestroy(Sender: TObject); begin Bit.Free; end;
end. |