反走样线的画线函数,供收藏(0分)

  • 主题发起人 吕雪松
  • 开始时间

吕雪松

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure AALine(x1,y1,x2,y2 : single;
color : tcolor;
canvas : tcanvas);
function CrossFadeColor(FromColor,ToColor : TColor;
Rate : Single) : TColor;

var r,g,b : byte;

begin

r:=Round(GetRValue(FromColor)*Rate+GetRValue(ToColor)*(1-Rate));

g:=Round(GetGValue(FromColor)*Rate+GetGValue(ToColor)*(1-Rate));

b:=Round(GetBValue(FromColor)*Rate+GetBValue(ToColor)*(1-Rate));
Result:=RGB(r,g,b);

end;


procedure hpixel(x : single;
y : integer);

var FadeRate : single;

begin

FadeRate:=x-trunc(x);

with canvasdo

begin

pixels[trunc(x),y]:=CrossFadeColor(Color,Pixels[Trunc(x),y],1-FadeRate);

pixels[trunc(x)+1,y]:=CrossFadeColor(Color,Pixels[Trunc(x)+1,y],FadeRate);

end;


end;



procedure vpixel(x : integer;
y : single);

var FadeRate : single;
begin

FadeRate:=y-trunc(y);

with canvasdo

begin

pixels[x,trunc(y)]:=CrossFadeColor(Color,Pixels[x,Trunc(y)],1-FadeRate);

pixels[x,trunc(y)+1]:=CrossFadeColor(Color,Pixels[x,Trunc(y)+1],FadeRate);

end;


end;



var i : integer;

ly,lx,currentx,currenty,deltax,deltay,l,skipl : single;

begin

if (x1<>x2) or (y1<>y2) then

begin

currentx:=x1;

currenty:=y1;

lx:=abs(x2-x1);

ly:=abs(y2-y1);


if lx>ly then

begin

l:=trunc(lx);

deltay:=(y2-y1)/l;

if x1>x2 then

begin

deltax:=-1;

skipl:=(currentx-trunc(currentx));
end else

begin

deltax:=1;

skipl:=1-(currentx-trunc(currentx));

end;


end else

begin

l:=trunc(ly);

deltax:=(x2-x1)/l;

if y1>y2 then

begin

deltay:=-1;

skipl:=(currenty-trunc(currenty));

end else

begin

deltay:=1;

skipl:=1-(currenty-trunc(currenty));

end;

end;


currentx:=currentx+deltax*skipl;
currenty:=currenty+deltay*skipl;{}

for i:=1 to trunc(l)do

begin

if lx>ly then
vpixel(trunc(currentx),currenty) else
hpixel(currentx,trunc(currenty));
currentx:=currentx+deltax;
currenty:=currenty+deltay;
end;

end;

end;

 

卷起千堆雪tyn

Unregistered / Unconfirmed
GUEST, unregistred user!
[blue]收藏之,^_^[/blue]
 
W

whitelion

Unregistered / Unconfirmed
GUEST, unregistred user!
J

Jiao_he

Unregistered / Unconfirmed
GUEST, unregistred user!
收藏中……
 
Z

zhiyue

Unregistered / Unconfirmed
GUEST, unregistred user!
不好意思,请解释一下什么是反走样线,在GIS中用在何处,不管如何先收藏,谁让不懂呢!
 
S

SINGLBOY

Unregistered / Unconfirmed
GUEST, unregistred user!

吕雪松

Unregistered / Unconfirmed
GUEST, unregistred user!
你画一条斜率非常小或非常大的直线看看,锯齿非常明显。
 

影子⌒⊙⌒

Unregistered / Unconfirmed
GUEST, unregistred user!
行动后全部通过,非常感谢,请问大侠有无样条曲线的函数?
EMAIL :123ZJX@KM169。NET
 

苦虫

Unregistered / Unconfirmed
GUEST, unregistred user!
暂时没用
先收着再说
谢谢,吕大虾
 
H

Huzzz

Unregistered / Unconfirmed
GUEST, unregistred user!
能否改进一下,我需要用 异或 方式画线。
 
Y

YB_unique

Unregistered / Unconfirmed
GUEST, unregistred user!
//请问大侠有无样条曲线的函数?
你自己Drawline试试,就明白了!

TO Huzzz
DirectX8.0提供多重采样渲染,实现全方位反走样,JEDI源码里有!
 
H

Huzzz

Unregistered / Unconfirmed
GUEST, unregistred user!
YB_unique, 我不希望用DirectX8.0。另 请问JEDI是什么?谢谢
 
Y

YB_unique

Unregistered / Unconfirmed
GUEST, unregistred user!
TO Huzzz:关于JEDI,请去——http://www.delphi-jedi.org
不希望用DirectX8.0的话,可以去http://home.t-online.de/home/herbert.haas/看看!绝对精彩!
 

悲酥清风

Unregistered / Unconfirmed
GUEST, unregistred user!
H

Huzzz

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢 YB_unique,那个SmoothPack 看起来很不错,不过不是我要的。另外它的LABLE
好像不支持中文字体,SmoothImage则是一个矢量EMF图形控件,画图速度很慢,我并
不觉得非常好(安装时D6还报错死掉了),不过还是要谢谢你。
 
顶部