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

📄 保留函数.txt

📁 自己写的一个分形程序
💻 TXT
字号:
	CMenu* menu=AfxGetMainWnd()->GetMenu()->GetSubMenu(1);
	menu->InsertMenu(0, MF_BYPOSITION, 44767, "dsafasd");


void CalcFractal(PixelInfo *pixelinfo, double left, double top, double scale, int wid, int hei, int lvl)
{
	PixelInfo *info;
	datetype a, b, olda, oldb;
	int x, y, t;
	int countxy;
	datetype a1, b1;
	for (x = 0 ;x < wid; x++)
		for (y = 0 ; y<hei;y++)
		{
			countxy=x+(hei-y-1)*wid;
			info=pixelinfo+countxy;
			if(!info->out)
			{
				a=info->a;
				b=info->b;
				a1*=(a1=a);
				b1*=(b1=b);
				olda=x*scale + left;
				oldb=y*scale + top;
				for (t = 0; t<lvl;t++)
				{
					b = 2*a*b + oldb;
					a = a1 - b1 + olda;
					a1*=(a1=a);
					b1*=(b1=b);
					if (a1 + b1 > 4)
					{
						info->out=true;
						info->lvl+=t;
						break;
					}
				}
				if(t==lvl)
				{
					info->a=a;
					info->b=b;
					info->lvl+=lvl;
				}
			}
		}
}
void CFractalExView::DrawFractal2()
{
	CRectFloat& myRect=GetDocument()->myRect;

	datetype mag=2.0/(myRect.bottom-myRect.top);
	lvl=(int)(log(mag)*100)+100;
	if(lvl<100)
		lvl=100;
	strlvl.Format("%d_X_%g", lvl, mag);
	GetDocument()->SetTitle(strlvl);

	CRect rect;
	GetClientRect(&rect);
	scale=(myRect.bottom-myRect.top)/hei2;
	memdib.Fill(255,255,255);
	widhei=(datetype)hei2/wid2;

	memset(pixelinfo, 0, sizeof(PixelInfo)*wid2*hei2);

	datetype a, b, olda, oldb;
	int x, y, t, countxy;
	datetype a1, b1;
	for (x = 0 ;x < wid2; x++)
		for (y = 0 ; y<hei2;y++)
		{
			countxy=x+(hei2-y-1)*wid2;
			a= olda=a1=x*scale + myRect.left;
			a1*=a;
			b =oldb= b1=  y*scale + myRect.top;
			b1*=b;
			for (t = 0; t<lvl;t++)
			{
				b = 4*(a1-b1)*b*a + oldb;
				a = (a1-6*b1)*a1 +b1*b1+ olda;
				a1*=(a1=a);
				b1*=(b1=b);
				if (a1 + b1 > 4)
				{
					if(t<20)
						memdib.m_Bits[countxy]=RGB(0, t*10+60, 0);
					else
						memdib.m_Bits[countxy]=colorcir[(t-20)%60*20];
					break;
				}
			}
		}
}

void CFractalExView::DrawFractal1()
{
	CRectFloat& myRect=GetDocument()->myRect;

	datetype mag=2.0/(myRect.bottom-myRect.top);
	lvl=(int)(log(mag)*100)+100;
	if(lvl<100)
		lvl=100;
	strlvl.Format("%d_X_%g", lvl, mag);
	GetDocument()->SetTitle(strlvl);

	CRect rect;
	GetClientRect(&rect);
	scale=(myRect.bottom-myRect.top)/hei2;
	memdib.Fill(255,255,255);
	widhei=(datetype)hei2/wid2;

	memset(pixelinfo, 0, sizeof(PixelInfo)*wid2*hei2);

	PixelInfo *info;
	datetype a, b, olda, oldb;
	int x, y, t, countxy;
	datetype a1, b1;
	for (x = 0 ;x < wid2; x++)
		for (y = 0 ; y<hei2;y++)
		{
			countxy=x+(hei2-y-1)*wid2;
			info=pixelinfo+countxy;
			a= olda=a1=x*scale + myRect.left;
			a1*=a;
			b =oldb= b1=  y*scale + myRect.top;
			b1*=b;
			for (t = 0; t<lvl;t++)
			{
				b = 2*a*b+0.4;
				a = a1-b1-0.7;
				a1*=(a1=a);
				b1*=(b1=b);
				if (a1 + b1 > 4)
				{
					info->out=true;
					info->lvl=t;
					break;
				}
			}
			if(t==lvl)
			{
				info->a=a;
				info->b=b;
				info->lvl=lvl;
			}
		}
		Render();
}

⌨️ 快捷键说明

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