主要达到视觉效果 , 那就好办, 下载 cnPack , 参考里面的代码. 可以用 浮点数 处理,
我在这里贴点给你参考:
procedure DrawLineF(x1, y1, x2, y2: Single; Color: TColor);
{* 以指定颜色绘制一条直线,使用抗锯齿算法
|<BR>
|<BR> x1, y1: Single 起始点坐标
|<BR> x2, y2: Single 结束点坐标
|<BR> Color: TColor 直线颜色}
procedure TCnBitmap.DrawLineF(X1, Y1, X2, Y2: Single; Color: TColor);
var
n, i: Integer;
px, py, ex, ey, nx, ny, hyp: Integer;
ARGB: TCnColor;
begin
if not ClipLineF(x1, y1, x2, y2, 0, Width - 1, 0, Height - 1) then Exit;
Changing;
ARGB := CnColor(Color);
px := Round(x1 * $8000);
py := Round(y1 * $8000);
ex := Round(x2 * $8000);
ey := Round(y2 * $8000);
nx := ex - px; // 宽度
ny := ey - py; // 高度
if (nx = 0) or (ny = 0) then
hyp := Round(Hypot(nx, ny))
else
case FPenWeight of // 斜边长
pwThin: hyp := Round(Hypot(nx, ny));
pwNormal: hyp := Round(Hypot(nx, ny) * 1.4); // 粗细修正
pwThick: hyp := Round(Hypot(nx, ny) * 1.8);
else hyp := Round(Hypot(nx, ny));
end;
if hyp < 256 then Exit;
n := hyp shr 15;
if n > 0 then
begin
nx := Round(nx / hyp * $8000);
ny := Round(ny / hyp * $8000);
for i := 0 to n - 1 do
begin
DoSetPixelF(px, py, ARGB); // 绘制点
px := px + nx;
py := py + ny;
end;
DoSetPixelF(ex, ey, ARGB); // 绘制端点
end;
Changed;
end;