为了账号安全,请及时绑定邮箱和手机立即绑定

C# 绘制螺旋填充

C# 绘制螺旋填充

C#
人到中年有点甜 2021-06-10 14:04:39
我有一个关于螺旋绘图的问题。以下来源来自链接。http://www.java2s.com/Code/CSharp/2D-Graphics/Spiral.htm螺旋为您提供空间。我希望螺旋填满屏幕。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);}图片
查看完整描述

1 回答

?
30秒到达战场

TA贡献1828条经验 获得超6个赞

出于纯粹病态的好奇心,我创建了一个新的 winforms 应用程序并粘贴了您的代码

这是我的结果

//img1.sycdn.imooc.com//60d6fcf20001788e08120489.jpg

如果这不是您想要的结果,请更新您的问题以使其更具体,包括图片、所需的结果以及为什么它不起作用


查看完整回答
反对 回复 2021-06-26
  • 1 回答
  • 0 关注
  • 232 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信