Плазменная заливка формы

Если вам надоели обычные монотонные формы, то эта статья - спасенье для вас!!! Всё, что вам нужно сделать для того, чтобы ваше окно выглядело так же эффектно, как и показанное на рисунке - это только написать несколько строк кода:
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); private { Private declarations } plasma: array [0..768, 0..768] of byte; procedure makeplasma; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormPaint(Sender: TObject); var x, y: integer; begin makeplasma; for x := 0 to 255 do begin for y := 0 to 255 do begin Form1.Canvas.Pixels[x, y] := rgb(plasma[x, y], plasma[x + 256, y + 256], plasma[x + 512, y + 512]); end; Form1.update; end; end; procedure TForm1.makeplasma; procedure halfway(x1,y1,x2,y2: integer); procedure adjust(xa,ya,x,y,xb,yb: integer); var d: integer; v: double; begin if plasma[x,y]<>0 then exit; d:=Abs(xa-xb)+Abs(ya-yb); v:=(plasma[xa,ya]+plasma[xb,yb])/2+(random-0.5)*d*2; if v<1 then v:=1; if v>=193 then v:=192; plasma[x,y]:=Trunc(v); end; var x, y: integer; v: double; begin if (x2-x1<2) and (y2-y1<2) then exit; x:=(x1+x2) div 2; y:=(y1+y2) div 2; adjust(x1,y1,x,y1,x2,y1); adjust(x2,y1,x2,y,x2,y2); adjust(x1,y2,x,y2,x2,y2); adjust(x1,y1,x1,y,x1,y2); if plasma[x,y]=0 then begin v:=(plasma[x1,y1]+plasma[x2,y1]+plasma[x2,y2]+plasma[x1,y2])/4; plasma[x,y]:=Trunc(v); end; halfway(x1,y1,x,y); halfway(x,y1,x2,y); halfway(x,y,x2,y2); halfway(x1,y,x,y2); end; var x, y: integer ; begin randomize; plasma[0,768]:=random(192); plasma[768,768]:=random(192); plasma[768,0]:=random(192); plasma[0,0]:=random(192); halfway(0,0,768,768); end; end. |
Далее: Полупрозрачная форма в Win2000 »»