求心形曲线方程。就是长长得和心脏的那种闭合曲线 函数原型如下public void DrawHeart(Graphics gp,int ClientWidth, int ClientHight){ //两个整形参数为绘图区域的宽和高}网上有一些资料,但是偶数学不是很好...唉..... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 x(t)=a(2cost-cos2t) y(t)=a(2sint-sin2t) 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; } } http://www.codeproject.com/KB/recipes/BezirCurves.aspx 根据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); }不过心形是倒过来的..... C#调用其他按键事件问题! 枚举与类的区别 求助 一个密码加密采用什么编码的问题 一个小问题! 关于一段捕捉屏幕的代码,简单问题求教 VS2005中如何输出XML注释文档? 简单的关于转化为字符串的问题 新建WinForm交流群组,欢迎加入. 1201233 急.....,高分求C#实现的多线程例子 c# 设置自定义坐标系 有关静态构造函数
y(t)=a(2sint-sin2t)
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;
}
}
根据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);
}不过心形是倒过来的.....