class2.cs

来自「这是《C#图形程序设计》这本书的源代码」· CS 代码 · 共 47 行

CS
47
字号
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;


namespace 递归图形
{
	/// <summary>
	/// Class2 的摘要说明。
	/// </summary>
	public class Class2
	{
		public Class2()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public void circles(Graphics g1,Pen pen1,double x,double y,double r,int n)
		{
			double[] ccos=new double[100];
			double[] csin=new double[100];
			int i;
			float theta;
			float f=0.3f;
			float c=2f;
			theta=2*3.14f/8f;
			double n1,fr;
			n1=n-1;
			fr=f*r;
			if(n1>1)
			{
				for(i=1;i<=8;i++)
				{
					ccos[i]=c*Math.Cos(i*theta);
					csin[i]=c*Math.Sin(i*theta);
					g1.DrawEllipse(pen1,(float)(x+r*ccos[i]-fr),(float)(y+r*csin[i]-fr),(float)(2*fr),(float)(2*fr));
					this.circles(g1,pen1,x+r*ccos[i],y+r*csin[i],fr,(int)(n1));
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?