//虚线样式
var
g:TGPGraphics;
p:TGPPen;
begin
g:=TGPGraphics.Create(Canvas.Handle);
g.Clear(aclWhite);
p:=TGPPen.Create(aclRed,5);
g.DrawLine(p,30,50,200,50);{实线}
p.SetDashStyle(DashStyleDashDot);{设置虚线样式}
g.DrawLine(p,30,60,200,60);{绘制任何形状都是可以的}
g.Free;
p.Free;
end;
//自定义虚线样式
var
g:TGPGraphics;
p:TGPPen;
const
dash:array[0..3] of Single = (5,2,7,3);//虚线样式数组, 数组维数大小任意,参数1,3为可见线长度,参数2,4为不可见线长度
begin
g:=TGPGraphics.Create(Canvas.Handle);
g.Clear(aclWhite);
p:=TGPPen.Create(aclRed,5);
g.DrawLine(p,30,50,200,50);
p.SetDashPattern(@Dash,Length(dash));{设置虚线}
g.DrawLine(p,30,60,200,60);
g.Free;
p.Free;
end;
虚线样式表:
Delphi | 微软 | 说明 |
---|---|---|
DashStyleCustom | Custom | 指定用户定义的自定义划线段样式。 |
DashStyleDash | Dash | 指定由划线段组成的直线。 |
DashStyleDashDot | DashDot | 指定由重复的划线点图案构成的直线。 |
DashStyleDashDotDot | DashDotDot | 指定由重复的划线点点图案构成的直线。 |
DashStyleDot | Dot | 指定由点构成的直线。 |
DashStyleSolid | Solid | 指定实线。 |