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: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;
type TForm1 = class(TForm) Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormResize(Sender: TObject); procedure Timer1Timer(Sender: TObject); private public end;
var Form1: TForm1;
Type TSprite = record a, b : TBitmap; end;
const anz = 100;
var Sprite : array[1..anz] of TSprite; HGBit : TBitmap; ShadowBit : TBitmap;
spos : array[1..anz] of TPoint;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); var i, x, y : Integer; begin Timer1.Interval := 10; HGBit := TBitmap.Create; ShadowBit := TBitmap.Create; for i := 1 to anz do begin spos[i].X := Random(ClientWidth); spos[i].Y := Random(ClientHeight); Sprite[i].a := TBitmap.Create; Sprite[i].b := TBitmap.Create; Sprite[i].a.Width := 32; Sprite[i].a.Height := 32; Sprite[i].b.Width := 32; Sprite[i].b.Height := 32; Sprite[i].a.Canvas.Create.Brush.Color := $00; Sprite[i].a.Canvas.FillRect(Rect(0, 0, 32, 32)); for x := 1 to 4 do begin Sprite[i].a.Canvas.Pen.Color := $BF shl x; Sprite[i].a.Canvas.Rectangle(x * 3, x * 3, 32 - x * 3, 32 - x * 3); end; for x := 0 to 32 do begin for y := 0 to 32 do begin if Sprite[i].a.Canvas.Pixels[x, y] = 0 then Sprite[i].b.Canvas.Pixels[x, y] := $FFFFFF else Sprite[i].b.Canvas.Pixels[x, y] := $000000; end; end; end; HGBit.LoadFromFile('d:\winnt\angler.bmp'); end;
procedure TForm1.FormDestroy(Sender: TObject); var i : Integer; begin for i := 1 to anz do begin Sprite[i].a.Free; Sprite[i].b.Free; end; HGBit.Free; ShadowBit.Free; end;
procedure TForm1.FormResize(Sender: TObject); begin ReFresh; ShadowBit.Width := ClientWidth; ShadowBit.Height := ClientHeight; end;
procedure TForm1.Timer1Timer(Sender: TObject); var i : Integer; begin ShadowBit.Canvas.StretchDraw(Rect(0, 0, ClientWidth, ClientHeight), HGBit); for i := 1 to anz do begin Inc(spos[i].X); if spos[i].x > ClientWidth then spos[i].x := 0; Inc(spos[i].Y); if spos[i].y > ClientHeight then spos[i].y := 0; StretchBlt(ShadowBit.Canvas.Handle, spos[i].x, spos[i].y, 32, 32, Sprite[i].b.Canvas.Handle, 0, 0, 32, 32, SRCAND); StretchBlt(ShadowBit.Canvas.Handle, spos[i].x, spos[i].y, 32, 32, Sprite[i].a.Canvas.Handle, 0, 0, 32, 32, SRCPAINT); end; canvas.StretchDraw(Rect(0, 0, ClientWidth, ClientHeight), ShadowBit); end;
end. |