Recent Posts
Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi
(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita
Selasa, 17 November 2009
Making Pen
procedure TXBitmap.setPenwidth(w : byte);
//make pen image
var i,j : byte;
h,v,r,r2 : single;
mask : DWORD;
begin
if w = FXpenwidth then exit;
if w > 32 then w := 32;
FXpenwidth := w;
FXpenBias := (w-1) shr 1;
//------- make pen image --------------------
for i := 0 to 31 do FXpen[i] := 0;//erase pen
r := w/2;
r2 := r * r;
for j := 0 to (w-1) shr 1 do // j is vertical movement over half height
begin
v := r - (0.5 + j);
for i := 0 to (w-1) shr 1 do // i is horizontal movement over half width
begin
h := r - (0.5 + i);
if h*h + v*v <= r2 then // pythagoras lemma
begin
mask := 1 shl i;
mask := mask or (1 shl (w-i-1)); // horizontal copy bit
FXpen[j] := FXpen[j] or mask; // set bits
FXpen[w-j-1] := FXpen[w-j-1] or mask; // vertical copy bits
end;//if
end;//for i
end;//for j
end;
//make pen image
var i,j : byte;
h,v,r,r2 : single;
mask : DWORD;
begin
if w = FXpenwidth then exit;
if w > 32 then w := 32;
FXpenwidth := w;
FXpenBias := (w-1) shr 1;
//------- make pen image --------------------
for i := 0 to 31 do FXpen[i] := 0;//erase pen
r := w/2;
r2 := r * r;
for j := 0 to (w-1) shr 1 do // j is vertical movement over half height
begin
v := r - (0.5 + j);
for i := 0 to (w-1) shr 1 do // i is horizontal movement over half width
begin
h := r - (0.5 + i);
if h*h + v*v <= r2 then // pythagoras lemma
begin
mask := 1 shl i;
mask := mask or (1 shl (w-i-1)); // horizontal copy bit
FXpen[j] := FXpen[j] or mask; // set bits
FXpen[w-j-1] := FXpen[w-j-1] or mask; // vertical copy bits
end;//if
end;//for i
end;//for j
end;
0 komentar:
Posting Komentar