:已知两个点和角度,怎么画弧线,有没有这样的函数
求助:已知两个点和角度,如何画弧线,有没有这样的函数.
已知两个点和角度,如何画弧线,有没有这样的函数.
------解决方案--------------------
.NET Framework 类库
Graphics.DrawArc 方法
绘制一段弧线,它表示由一对坐标、宽度和高度指定的椭圆部分。
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse(这是 Paint 事件处理程序的参数)。代码执行下列操作:
创建黑色钢笔。
创建限定椭圆的矩形。
定义起始角(45 度)和扫过的角度(270 度)。
将椭圆弧线绘制到屏幕。
结果是部分椭圆,缺少 x 轴两侧 + 45 度和 - 45 度之间的部分。
public void DrawArcRectangle(PaintEventArgs e)
{
// Create pen.
Pen blackPen= new Pen(Color.Black, 3);
// Create rectangle to bound ellipse.
Rectangle rect = new Rectangle(0, 0, 100, 200);
// Create start and sweep angles on ellipse.
float startAngle = 45.0F;
float sweepAngle = 270.0F;
// Draw arc to screen.
e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle);
}
------解决方案--------------------
VB.NET代码:
Public Sub DrawArcRectangle(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create rectangle to bound ellipse.
Dim rect As New Rectangle(0, 0, 100, 200)
' Create start and sweep angles on ellipse.
Dim startAngle As Single = 45.0F
Dim sweepAngle As Single = 270.0F
' Draw arc to screen.
e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle)
End Sub
已知两个点和角度,如何画弧线,有没有这样的函数.
------解决方案--------------------
.NET Framework 类库
Graphics.DrawArc 方法
绘制一段弧线,它表示由一对坐标、宽度和高度指定的椭圆部分。
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse(这是 Paint 事件处理程序的参数)。代码执行下列操作:
创建黑色钢笔。
创建限定椭圆的矩形。
定义起始角(45 度)和扫过的角度(270 度)。
将椭圆弧线绘制到屏幕。
结果是部分椭圆,缺少 x 轴两侧 + 45 度和 - 45 度之间的部分。
public void DrawArcRectangle(PaintEventArgs e)
{
// Create pen.
Pen blackPen= new Pen(Color.Black, 3);
// Create rectangle to bound ellipse.
Rectangle rect = new Rectangle(0, 0, 100, 200);
// Create start and sweep angles on ellipse.
float startAngle = 45.0F;
float sweepAngle = 270.0F;
// Draw arc to screen.
e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle);
}
------解决方案--------------------
VB.NET代码:
Public Sub DrawArcRectangle(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create rectangle to bound ellipse.
Dim rect As New Rectangle(0, 0, 100, 200)
' Create start and sweep angles on ellipse.
Dim startAngle As Single = 45.0F
Dim sweepAngle As Single = 270.0F
' Draw arc to screen.
e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle)
End Sub