混沌特性的演示

上传人:mg****85 文档编号:33723477 上传时间:2018-02-17 格式:DOC 页数:13 大小:242.50KB
返回 下载 相关 举报
混沌特性的演示_第1页
第1页 / 共13页
混沌特性的演示_第2页
第2页 / 共13页
混沌特性的演示_第3页
第3页 / 共13页
混沌特性的演示_第4页
第4页 / 共13页
混沌特性的演示_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《混沌特性的演示》由会员分享,可在线阅读,更多相关《混沌特性的演示(13页珍藏版)》请在金锄头文库上搜索。

1、用 VC6.0 建一个对话框窗体,命名为 Chaos在 ChaosDlg.cpp 文件下:BOOL CChaosDlg:OnInitDialog()CDialog:OnInitDialog();MoveWindow(0,0,1024,768,true);/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu

2、(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big iconSetIcon(m_hIcon, FALSE); / Set small icon/角度的分界线tan_1=tan(60*pi/180.0);tan_2=tan(120*pi/180.0);tan_3=t

3、an(240*pi/180.0);tan_4=tan(300*pi/180.0);return TRUE; / return TRUE unless you set the focus to a controlvoid CChaosDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;2dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to

4、 your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CChaosDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.Get

5、SafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/

6、*将作图区域底色设为白色*/CRect rec;rec.left=0;rec.top=0;rec.right=767;rec.bottom=767;CDC *dc;3dc=this-GetDC();CBrush hbr;hbr.CreateSolidBrush(RGB(255,255,255);dc-FillRect(/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CChaosDlg:OnQueryDragIcon()return

7、 (HCURSOR) m_hIcon;void CChaosDlg:OnOK() / TODO: Add extra validation hereUpdateData(TRUE);CDC *dc;dc=this-GetDC();double x0,y0,x1,y1,dx,dy;int col,row,color;/绘图范围是-2,2/dx=dy=4.0/767.0;for(col=0;colSetPixel(col,767-row,colorlistcolor);dc-MoveTo(20-1,20-1);dc-LineTo(747+1,20-1);dc-LineTo(747+1,747+1)

8、;dc-LineTo(20-1,747+1);dc-LineTo(20-1,20-1);/4/画出图形 /for(col=20;colm_edit1);y1=itearate_fim(x0,y0,this-m_edit1);color=judge_color_point(x1,y1);dc-SetPixel(col,767-row,colorlistcolor);x0=x1;y0=y1;UpdateData(FALSE);int CChaosDlg:judge_color_point(double x, double y)int z1;double division;if(x0&y0)divi

9、sion=y/x;if(division=0)division=y/x;if(division0&y0)z1=2;if(x=0&y=0;i-)for(j = 767;j =0;j-)clr = dc.GetPixel(i, j);r = GetRValue(clr);g = GetGValue(clr);b = GetBValue(clr);if(r != 255 | g != 255 | b != 255)flag = 1;x2 = i;break;if(flag)break;flag = 0;for(j = 0;j =0;j-)for(i = x2;i =x1;i-)clr = dc.Ge

10、tPixel(i, j);r = GetRValue(clr);g = GetGValue(clr);b = GetBValue(clr);if(r != 255 | g != 255 | b != 255)flag = 1;y2 = j;break;if(flag)break;/保存图片CRect rect;rect.SetRect(x1,y1,x2,y2);/ CClientDC dc(this); CDC memDC;/ CRect rect;memDC.CreateCompatibleDC(9CBitmap bm;int Width = 768;int Height = 768;bm.

11、CreateCompatibleBitmap(CBitmap* pOld = memDC.SelectObject(memDC.BitBlt(0, 0, Width, Height, memDC.SelectObject(pOld);BITMAP btm;bm.GetBitmap(DWORD size = btm.bmWidthBytes * btm.bmHeight;LPSTR lpData = (LPSTR)GlobalAllocPtr(GPTR, size);BITMAPFILEHEADER bfh;/BITMAPINFOHEADER bih;bih.biBitCount = btm.b

12、mBitsPixel;bih.biClrImportant = 0;bih.biClrUsed = 0;bih.biCompression = 0;bih.biHeight = btm.bmHeight;bih.biPlanes = 1;bih.biSize = sizeof(BITMAPINFOHEADER);bih.biSizeImage = size;bih.biWidth = btm.bmWidth;bih.biXPelsPerMeter = 0;bih.biYPelsPerMeter = 0;GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPI

13、NFO*)/bm.GetBitmapBits(size,lpData);/此函数在处理 5-5-5 模式的 16 位色下会出现颜色混乱bfh.bfReserved1 = bfh.bfReserved2 = 0;bfh.bfType = (WORD)(MGetDC();CBrush hbr;hbr.CreateSolidBrush(RGB(255,255,255);dc-FillRect(/double x0=-0.5,y0=0.5,x1,y1,dx,dy;dx=dy=4.0/767.0;int col0,row0,col1,row1;col0=(int)(x0+2)/dx);row0=767-

14、(int)(y0+2)/dy);for(int i=0;iSetPixel(col0,767-row0,RGB(255,0,0);x0=x1;y0=y1;/x 轴/col0=(int)(-2+2)/dx);11row0=767-(int)(0+2)/dy);col1=(int)(2+2)/dx);row1=767-(int)(0+2)/dy);dc-MoveTo(col0,row0);dc-LineTo(col1,row1);/y 轴/col0=(int)(0+2)/dx);row0=767-(int)(-2+2)/dy);col1=(int)(0+2)/dx);row1=767-(int)(2+2)/dy);dc-MoveTo(col0,row0);dc-LineTo(col1,row1);Col.h 文件下:double tan_1,tan_2,tan_3,tan_4;COLORREF colorlist6=RGB(210,189,93),RGB(169,144,30),RGB(56,50,22),RGB(127,123,15),RGB(199,194,49),RGB(237,228,133)1213所做图形:迭代 0 次 迭代 1 次迭代 2 次 迭代 3 次迭代 4 次

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号