【发布时间】:2011-11-03 23:04:19
【问题描述】:
我想使用以下代码在 winform 上绘制某种图形:
private void button1_Click(object sender, EventArgs e)
{
Pen myPen = new System.Drawing.Pen(Color.Red);
Graphics handler = this.CreateGraphics();
double[] nextPt = new double[2];
double[] maurerPt = new double[2];
for (int index = 1; index < 361; index++)
{
nextPt = calcRose(index * d);
//this line is incorrect but Drawline only accept Point which is int
//and valued are in fractions thats why I use double
handler.DrawLine(maurerPt[0], maurerPt[1], nextPt[0], nextPt[1];
nextPt.CopyTo(maurerPt,2);
}
myPen.Dispose();
handler.Dispose();
}
问题是我想创建某种称为“maruer rose”的数学图 并且由于我的行值是分数,所以我不能使用 Point 它只接受 int 值
如何使用双精度或浮点值输入画线?
问候。
【问题讨论】:
-
Graphics.DrawLine() 有一个接受 PointF 的重载。顺便说一句,只在 Paint 事件中绘制。