您的位置:首页 - .NET
C# WinForm分型画树叶小程序
看了一片文章(http://keleyi.com/a/bjac/nurox416.htm),是使用分型画树叶,代码是Java的,因为Java很久没弄了,改用C#实现,下载地址:
画树叶小程序下载

C#树叶

核心代码:

public void PaintKeleyiLeaf(Graphics g)
{
Random k_r = new Random();
int i;
double x = 0, y = 0, r, u = 0;
for (i = 0; i <= 100000; i++)
{
r = (int)(k_r.NextDouble() * 100);
if (r < 1)
{
x = 0;
y = .16 * y;
}
if (r >= 1 && r < 86)
{
u = .85 * x + .04 * y;
y = -0.04 * x + 0.85 * y + 1.6;
x = u;
}
if (r >= 86 && r < 97)
{
u = .2 * x - .26 * y;
y = .23 * x + .22 * y + 1.6;
x = u;
}
if (r >= 97)
{
u = -.15 * x + .28 * y;
y = 0.26 * x + .24 * y + .44;
x = u;
}

g.DrawString(".", keleyifont, Brushes.Green, (int)(40 * x + 120), (int)(420 - 40 * y));
}

g.DrawString("keleyi.com", keleyifont, Brushes.Red, 50, 100);
}

其中keleyifont请参考:http://keleyi.com/a/bjac/d88s8cyv.htm
本站导航
相关文章
柯乐义 Copyright© keleyi.com