【发布时间】:2018-05-23 05:35:15
【问题描述】:
我有一个关于螺旋绘图的问题。
以下来源引用自链接。
http://www.java2s.com/Code/CSharp/2D-Graphics/Spiral.htm
螺旋为您提供空间。
我想让 Spiral 填满屏幕。
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor, ClientSize.Width,ClientSize.Height);
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
const int iNumRevs = 3;
int iNumPoints = iNumRevs * 2 * (cx + cy);
PointF[] aptf = new PointF[iNumPoints];
float fAngle, fScale;
for (int i = 0; i < iNumPoints; i++)
{
fAngle = (float)(i * 2 * Math.PI / (iNumPoints / iNumRevs));
fScale = 1 - (float)i / iNumPoints;
aptf[i].X = (float)(cx / 2 * (1 + fScale * Math.Cos(fAngle)));
aptf[i].Y = (float)(cy / 2 * (1 + fScale * Math.Sin(fAngle)));
}
grfx.DrawLines(new Pen(clr), aptf);
}
【问题讨论】:
-
FillPath呢? -
嗨,约翰。我不知道你的意思
-
有一个图形方法
FillPath(类似于在Photoshop中填充路径的工作方式)。我不确定你定义路径有多容易,但是一旦你有了路径,这可能会帮助你进行实际绘图。 -
谢谢约翰。但我想要做的是绘制螺旋来填充屏幕。
-
首先要做的是检查你是否可以画任何东西。从简单的开始,如果你不能画一条线,你就不能画螺旋线。如果您可以画一条线,请检查这些点是否有意义。他们在屏幕上吗,等等