琴终 2015-02-18 14:08 采纳率: 0%
浏览 4761

不知道是不是笛卡尔心形函数C语言的编程,,

private void Form4_Load(object sender, EventArgs e)
{
this.BackColor = Color.Black;
this.Size = new Size(400, 400);
Panel panel = new Panel();
panel.Size = new Size(350, 350);
panel.Paint += new PaintEventHandler(panel_Paint);
panel.Location = new Point((this.ClientRectangle.Width - panel.Width) / 2, (this.ClientRectangle.Height - panel.Height) / 2);
this.Controls.Add(panel);
}

    void panel_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        double x, y, r;
        int w = e.ClipRectangle.Width;
        int h = e.ClipRectangle.Height;
        for (int i = 0; i <= 90; i++)
        {
            for (int j = 0; j <= 90; j++)
            {
                //转换为直角坐标系,设置偏移量,使图像居中
                r = Math.PI / 45 * i * (1 - Math.Sin(Math.PI / 45 * j)) * 19;
                x = r * Math.Cos(Math.PI / 45 * j) * Math.Sin(Math.PI / 45 * i) + w / 2;
                y = -r * Math.Sin(Math.PI / 45 * j) + h / 4;
                using (Brush brush = new SolidBrush(Color.Red))
                {
                    e.Graphics.FillEllipse(brush, (float)x, (float)y, 2f, 2f);
                    e.Graphics.FillEllipse(brush, (float)x, (float)y, 1f, 1f);
                }
            }
        }
    }
  • 写回答

1条回答 默认 最新

  • devmiao 2015-02-18 14:14
    关注

    运行下就知道了,这是C#不是C。

    评论

报告相同问题?

悬赏问题

  • ¥15 优质github账号直接兑换rmb,感兴趣伙伴可以私信
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)