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
|
function blend(c1,c2:integer; factor:single):integer;
var
r1,g1,b1:integer;
r2,g2,b2:integer;
begin
c1:=ColorToRGB(c1);
c2:=ColorToRGB(c2);
r1:=c1 and $FF;
g1:=(c1 shr 8) and $FF;
b1:=(c1 shr 16) and $FF;
r2:=c2 and $FF;
g2:=(c2 shr 8) and $FF;
b2:=(c2 shr 16) and $FF;
r1:=round(r1*factor+r2*(1-factor)) and $ff;
g1:=round(g1*factor+g2*(1-factor)) and $ff;
b1:=round(b1*factor+b2*(1-factor)) and $ff;
Result:=r1+256*g1+65536*b1;
end;
procedure TForm1.FormPaint(Sender: TObject);
const
c1=$608060;
c2=$ffffff;
w =40;
var
x1,y1:integer;
x2,y2:integer;
i:integer;
begin
x1:=Edit1.Left-1;
x2:=x1+Edit1.Width+2;
y1:=Edit1.Top-1;
y2:=y1+Edit1.Height+2;
with Canvas do begin
for i:=0 to w-1 do begin
Pen.Color:=blend(c2,c1,1/(w-i));
MoveTo(x1,y1);
LineTo(x2,y1);
LineTo(x2,y2);
LineTo(x1,y2);
LineTo(x1,y1);
dec(x1); dec(y1);
inc(x2); inc(y2);
end;
end;
end; |
Partager