画不带圆头的线 ( 积分: 200 )

  • 主题发起人 主题发起人 myclain
  • 开始时间 开始时间
M

myclain

Unregistered / Unconfirmed
GUEST, unregistred user!
画有宽度的线,在98下有圆头,如何解决?不要告诉我用多边形处理。
 
画有宽度的线,在98下有圆头,如何解决?不要告诉我用多边形处理。
 
都没有遇到过?
 
高手们来看看,帮个忙啊
 
高手们过来看看啊。版主给帮个忙
 
如果你的线较粗,可以在两头画方块
 
线的宽度是从1到100,相当于从很细到很粗。
 
画方框,并填充
 
搜一下,大富翁里有相关的函数!
 
是不是这个效果


  ●/      ●—————>●
  ∧ /     ∧
   | /    |        
  / /   /
/ /   /
/ /->●

__________________________________________


摘自aizb大侠的代码
function GetDirection(FromLaOrLo, ToLaOrLo: TPoint): Double;
Var xDis,yDis:DOUBLE;//*0.00000001*180/3.1415926;
begin
xDis:=ToLaOrLo.x-FromLaOrLo.x;
//x方向的差值;
yDis:=ToLaOrLo.y-FromLaOrLo.y;
//y方向的差值;
if xDis<>0 then
Result:=ArcTan2(yDis,xDis)
else
begin
if ToLaOrLo.y-FromLaOrLo.y<0 then
Result:=pi*3/2
else
Result:=pi/2;
end;
end;
procedure proDrawDirection(Way: Single;cCanvas: TCanvas;R:LongInt;CentPoint:TPoint;DirectionStyle:TDirectionStyle;FromOrTo:Boolean;Color:TColor);
///////////////////////////////////////////////////////////////////////////////
//Way:Single,方向,即角度,弧度.
//cCanvas:TCanvas,画布,需要画箭头的画布.
//R:LongInt,箭头半径,即箭头的顶和脚三点形成的三解形的三个点所以圆的半径.
//CentPoint:TPoint,点,圆中心点.
//DirectionStyle:TDirectionStyle,绘制类型,
// dsFrame 画一个圆;
// dsShape 画箭头.
//FromOrTo:方向,正向or 反向.
//Color:TColor,绘制颜色.
///////////////////////////////////////////////////////////////////////////////
Var aPoint:TAPoint;
OldPenColor,OldBrushColor:TColor;
PenWidth:LongInt;
procedure GetPointList(CentPoint:TPoint;var PointList:Array of TPoint);
begin
PointList[0].x:=CentPoint.x;
PointList[0].y:=CentPoint.y;
PointList[1].x:=Round(CentPoint.x-R*2*COS(Way-pi/10)); //x
PointList[1].y:=Round(CentPoint.y-R*2*SIN(Way-pi/10)); //y
PointList[2].x:=Round(CentPoint.x-R*COS(Way)); //x
PointList[2].y:=Round(CentPoint.y-R*SIN(Way)); //y
PointList[3].x:=Round(CentPoint.x-R*2*COS(Way+pi/10)); //x
PointList[3].y:=Round(CentPoint.y-R*2*SIN(Way+pi/10)); //y
end;
begin
if (CentPoint.x=0) and (CentPoint.y=0) then
begin
CentPoint.x:=R;
CentPoint.y:=R;
end;
PenWidth:=cCanvas.Pen.Width;
OldPenColor:=cCanvas.Pen.Color;
OldBrushColor:=cCanvas.Brush.Color;
try
cCanvas.Pen.Width:=1;
if dsFrame in DirectionStyle then
begin
cCanvas.Pen.Color:=Color;
cCanvas.Brush.Color:=Color;
cCanvas.Ellipse(CentPoint.x-R,CentPoint.Y-R,CentPoint.x+R,CentPoint.y+R);
end;
if dsShape in DirectionStyle then
begin
SetLength(aPoint,4);
if FromOrTo then
GetPointList(CentPoint,aPoint)
else
begin
CentPoint.X:=Round(CentPoint.x+R*COS(Way));
CentPoint.Y:=Round(CentPoint.Y+R*Sin(Way));
GetPointList(CentPoint,aPoint);
end;
cCanvas.Pen.Color:=Color;
cCanvas.Brush.Color:=Color;
cCanvas.Polygon(aPoint);
end;
finally
cCanvas.Pen.Color:=OldPenColor;
cCanvas.Brush.Color:=OldBrushColor;
cCanvas.Pen.Width:=PenWidth;
end;
end;

调用:
proDrawDirection(GetDirection(Point(a.X,a.Y),a),Canvas,PR,a,[dsFrame],True,PenColor);
 
myhby 说得还是用多边形实现啊。
画一条线段,放大的时候,线段的两端就不是方的了
 
我会弄,留下邮箱。
 
clain@163.com ,谢谢
 
后退
顶部