⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class5.cs

📁 这是《C#图形程序设计》这本书的源代码
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace 递归图形
{
	/// <summary>
	/// Class5 的摘要说明。
	/// </summary>
	public class Class5
	{
		public Class5()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public void draw(Graphics g1,Pen p1,Brush b1,int l)
		{
			int level;
			double x1,x4,y1,y4;
			x1=1;
			y1=1;
			x4=400;
			y4=300;
			level=l;
			this.SB(g1,p1,b1,level,x1,y1,x4,y4);
		}
		public void SB(Graphics g1,Pen p1,Brush b1,int level,double x1,double y1,double x4,double y4)
		{
			double x2,x3,y2,y3;
			g1.FillRectangle(b1,(float)(x1),(float)(y1),(float)(x4-x1),(float)(y4-y1));
			if(level<1)
			{
				goto quit;
			}
			x2=(2*x1+x4)/3;
			x3=(x1+2*x4)/3;
			y3=(y1+2*y4)/3;
			y2=(2*y1+y4)/3;
			SolidBrush b3=new SolidBrush(Color.Blue);
			g1.FillRectangle(b3,(float)(x2),(float)(y2),(float)(x3-x2),(float)(y3-y2));
			SB(g1,p1,b1,level-1,x1,y1,x2,y2);
			SB(g1,p1,b1,level-1,x2,y1,x3,y2);
			SB(g1,p1,b1,level-1,x3,y1,x4,y2);
			SB(g1,p1,b1,level-1,x1,y2,x2,y3);
			SB(g1,p1,b1,level-1,x3,y2,x4,y3);
			SB(g1,p1,b1,level-1,x1,y3,x2,y4);
			SB(g1,p1,b1,level-1,x2,y3,x3,y4);
			SB(g1,p1,b1,level-1,x3,y3,x4,y4);
			quit: ;
		}
	}
}

⌨️ 快捷键说明

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