函数原型如下public void DrawHeart(Graphics gp,int ClientWidth, int ClientHight)
{
      //两个整形参数为绘图区域的宽和高
}网上有一些资料,但是偶数学不是很好...唉.....

解决方案 »

  1.   

    x(t)=a(2cost-cos2t)   
    y(t)=a(2sint-sin2t) 
      

  2.   


            public void DrawHeart(Graphics gp, int ClientWidth, int ClientHight)
            {
                //a是心形线r=a(1+sin()) (a>0)的参数
                int a = Math.Min(ClientHight, ClientWidth) / 4;
                int x, y, newx, newy;
                int angle = 360;
                x = a;
                y = 0;
                newx = 0;
                newy = 0;
                while (angle > 0)
                {
                    angle--;
                    newx = (int)(a * (1 + Math.Sin(Math.PI * angle / 180)) * Math.Cos(Math.PI * angle / 180));
                    newy = (int)(a * (1 + Math.Sin(Math.PI * angle / 180)) * Math.Sin(Math.PI * angle / 180));
                    //x + a*2 和 y + a是调整心形线的中心
                    gp.DrawLine(new Pen(Color.Red, 2), new Point(x + a * 2, y + a), new Point(newx + a * 2, newy + a));
                    x = newx;
                    y = newy;
                }
            }
      

  3.   

    http://www.codeproject.com/KB/recipes/BezirCurves.aspx
      

  4.   


    根据1楼的参数方程有如下protected void DrawHeart(Graphics graph, int ClientWidth, int ClientHight)
            {
                int iLine = Math.Max(ClientWidth, ClientHight);
                PointF[] hHeartPt = new PointF[iLine];            int a = iLine/9;            for (int i = 0; i <iLine ; i++)
                {
                    double t = i * 2 * Math.PI / (ClientHight - 1);
                    hHeartPt[i].X = ClientWidth/2+a * (float)(2 * Math.Cos(t) - Math.Cos(2 * t));
                    hHeartPt[i].Y = ClientHight/2+a * (float)(2 * Math.Sin(t) - Math.Sin(2 * t));
                }
                graph.DrawLines(Pens.Red, hHeartPt);
            }不过心形是倒过来的.....