




已阅读5页,还剩41页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
混沌上机实验报告学院:信息学院课程名称:混沌学生姓名:许亮亮学号:1106440513 实验一一、上机题目: 在VC中自制调色板二、上机目的与要求1. 熟悉一种编程语言环境及相关图形功能,能够灵活使用画笔,画刷等绘图工具。2. 利用相关编程语言的图形功能,制作20色以上调色板。3.理解平面与屏幕的对应关系,掌握吸引子的构造原理与色带的制作方法,为下一个实验做准备工作。三、思路及步骤1. 在MFC中,创建一个对话框窗口。在主窗体中添加一个textbox控件,作为调色板的产生区域。在其属性中的样式里,将“凹陷”和“边框”选上。2.为了使调色板的长宽可变,在text区域的右部添加两个编辑框,分别控制产生色块的行列数量。在ClassWizard里为其添加成员变量,变量名分别为m_length和m_width,并设置变量值区域,长在1和7之间,宽在1和5之间。另外,添加一个控制时间间隔的编辑框,命名为m_elapse,以毫秒为单位。类型均为int。3.添加两个按钮,“绘图”和“退出”。界面效果如下。4. 为绘图按钮添加消息映射函数。在text的区域绘制一个矩形,坐标为(15,615),(20,425),用白色画刷填充。产生的每个色块为边长为80单位的正方形,行列数量由输入的m_length和m_width决定。每产生一个,调用Sleep(m_elpase)函数,等待m_elpase个间隔后再产生下一个。此调色板的颜色全部由随机数控制,即用random()函数产生RGB三种颜色。部分代码如下:四、所作图形7*5的调色板5*4的调色板,时间间隔较大,颜色差别也较大,并过渡了一个色调可以看到,时间间隔为500ms时,每两个色块的颜色相同五,实验部分代码/ 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/ TODO: Add extra initialization herereturn TRUE; / return TRUE unless you set the focus to a controlvoid CTiaosebanDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to 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 CTiaosebanDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();CRect rect(0,0,1000,1200);CDC *dc=this-GetDC();CBrush brush;brush.CreateSolidBrush(RGB(3,25,4);dc-FillRect(&rect,&brush);CRect rec;int startx,starty,width,left,right,top,bottom;startx=10;starty=10;width=64;left=startx;top=starty;right=left+60;bottom=top+60;for(int j=0;j5;j+)for(int i=0;iFillRect(&rec,&hbr1); HCURSOR CTiaosebanDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CTiaosebanDlg:OnButton1() / TODO: Add your control notification handler code herem=m+50;CRect rect(0,0,1000,1200);CDC *dc=this-GetDC();CBrush brush;brush.CreateSolidBrush(RGB(3+m,25+m,4+m);dc-FillRect(&rect,&brush);CRect rec;int startx,starty,width,left,right,top,bottom;startx=10;starty=10;width=64;left=startx;top=starty;right=left+60;bottom=top+60;for(int j=0;j5;j+)for(int i=0;iFillRect(&rec,&hbr1); 实验二一、上机题目: 实现混沌特性显示二、上机目的与要求1.理解混沌特性的显示实验的意义与目的,为编程实现功能做准备工作。2.掌握ICON图标的标准式的计算机变换,并利用计算机程序实现混沌特性的直观表达。三、思路及步骤该实验以一个内部具有三对称动力特性的映射为例,验证其混沌特性,该映射一般形式如下:F(z)=+zz+Re(zn)+iz+zn-1 步骤: 1.根据混沌特性物理实验原理,先定义n种颜色的背景调色板,在一个正方形中,以正方形的中心为圆心,每过360/n赋一种颜色。编写对应的程序代码,实验屏幕的分割。 2.应用ICON图标的计算公式,写出对应的迭代函数的计算机表达式,写出主函数,进行程序联调,分别作出一次,2次,3次,8次的迭代结果,保存。四、实验部分代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication2 public partial class Form1 : Form public int i, j; public Bitmap map = new Bitmap(768, 768); public Color color = new Color(); Colorful colorful = new Colorful(); public double pi=3.1415926; public void Init() color = Color.FromArgb(10, 10, 10); for (i = 0; i = 767; i+) for (j = 0; j = 0 & arc = pi / 3.0 & arc = 2.0 * pi / 3.0 & arc = pi & arc = 4.0 * pi / 3.0 & arc = 5.0 * pi / 3.0 & arc 0 & y 0) division = y / x; arc1 = Math.Atan(division); z1=judge_arc_clolor(arc1); if(x0) division=y/x; arc1 = Math.Atan(division); arc1=arc1+pi; z1=judge_arc_clolor(arc1); if(x0&y0&y 0) z1 = 2;if (x = 0 & y = 0) z1 = 5; return z1; double fre(double x, double y) double z; z = 2.5 * x * (1 - x * x - y * y) + 0.9 * (x * x - y * y); return z; double fim(double x, double y) double z; z = -1.8 * x * y + 2.5 * y * (1 - x * x - y * y); return z;double itearate_fre(double x, double y, int n) int i; double z; double xnew, ynew; for (i = 0; i n; i+) xnew = fre(x, y); ynew = fim(x, y); x = xnew; y = ynew; z = x; return z; double itearate_fim(double x, double y, int n) int i; double z; double xnew, ynew; for (i = 0; i n; i+) xnew = fre(x, y); ynew = fim(x, y); x = xnew; y = ynew; z = y; return z; public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) Init(); pictureBox1.Image = map; private void button2_Click(object sender, EventArgs e) /成像? double x0, y0, x1, y1, dx, dy; int col, row, color; int i, j, k,m_num; dx = dy = 4.0 / 767.0; m_num=Int32.Parse(textBox7.Text); for(col=0;col=767;col+) for (row = 0; row = 767; row+) x0 = (double)col * dx - 2; y0 = (double)row * dy - 2; /Color.FromArgb(colorful.GetR(judge_point_color(x0,y0), colorful.GetG(judge_point_color(x0, y0), colorful.GetB(judge_point_color(x0, y0); map.SetPixel(col,row,Color.FromArgb(colorful.GetR(judge_point_color(x0, y0), colorful.GetG(judge_point_color(x0, y0), colorful.GetB(judge_point_color(x0, y0); for (col = 20; col 747; col+) for (row = 20; row GetDC();CBrush hbr;hbr.CreateSolidBrush(RGB(0,0,0);dc-FillRect(&rec,&hbr);/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CIconDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CIconDlg:OnOnButtonCreate() / TODO: Add your control notification handler code hereUpdateData(TRUE);CDC *dc;dc=this-GetDC();int long num;double x0,y0,x1,y1;int mcount,mcolor,colx,rowy;x0=-0.19820101;y0=0.19830725; /定义起始点 scale=m_scale;x1=x0;y1=y0;CRect rec;rec.left=0;rec.top=0;rec.right=768;rec.bottom=768;CBrush hbr;hbr.CreateSolidBrush(RGB(255,255,255);dc-FillRect(&rec,&hbr);for(num=0;num=0 & colx768 & rowy=0 ) if(numSetPixel(colx,rowy,RGB(144,97,229);/dc-SetPixel(colx,rowy,colorlist128-mcolor);dc-TextOut(10+650+2+100,85-10-15,*);dc-TextOut(10+650+2+100,85-15,* 作 图 结 束 *);dc-TextOut(10+650+2+100,85+10-15,*);dc-TextOut(10+650+2+90,85+10-15,*);dc-TextOut(10+650+2+100,85+20-15,*);/+100/UpdateData(FALSE);void CIconDlg:OnSave() int x1,x2,y1,y2;int i,j,flag;BYTE r,g,b;COLORREF clr;CClientDC dc(this);flag = 0;for(i = 0;i 768;i+)for(j = 0;j =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 768;j+)for(i = x1;i =0;j-)for(i = x2;i =x1;i-)clr = dc.GetPixel(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;/保存图片CRectrect;rect.SetRect(x1,y1,x2,y2);/CClientDCdc(this); CDC memDC;/CRectrect;memDC.CreateCompatibleDC(&dc);CBitmap bm;int Width = 768;int Height = 768;bm.CreateCompatibleBitmap(&dc, Width, Height);CBitmap* pOld = memDC.SelectObject(&bm);memDC.BitBlt(0, 0, Width, Height, &dc, 0, 0, SRCCOPY);memDC.SelectObject(pOld);BITMAP btm;bm.GetBitmap(&btm);DWORD size = btm.bmWidthBytes * btm.bmHeight;LPSTR lpData = (LPSTR)GlobalAllocPtr(GPTR, size);BITMAPFILEHEADER bfh;/BITMAPINFOHEADER bih;bih.biBitCount = btm.bmBitsPixel;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,(BITMAPINFO*)&bih,DIB_RGB_COLORS);/bm.GetBitmapBits(size,lpData);/此函数在处理5-5-5模式的16位色下会出现颜色混乱bfh.bfReserved1 = bfh.bfReserved2 = 0;bfh.bfType = (WORD)(M 8)|B);bfh.bfSize = 54 + size;bfh.bfOffBits = 54;CFileDialog dlg(false,_T(BMP),_T(*.bmp),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T(*.bmp|*.bmp|*.*|*.*|);if (dlg.DoModal()!=IDOK)return;CFile bf;CString ss=dlg.GetPathName();if(bf.Open(ss, CFile:modeCreate | CFile:modeWrite)bf.WriteHuge(&bfh, sizeof(BITMAPFILEHEADER);bf.WriteHuge(&bih, sizeof(BITMAPINFOHEADER);bf.WriteHuge(lpData, size);bf.Close();AfxMessageBox(保存成功);GlobalFreePtr(lpData);Variable.h:double scale;/=1.25决定了图形的显示范围double ynew;double xnew;COLORREF colorlist256=/定义颜色;int pixel_array 768768=0;int add(int x,int y) int count=0; pixel_arrayxy+; count=pixel_arrayxy; return count;int color(int counter)for(int i=0;i=i*5&counter(i+1)*5) return i;return 0;double fcol(double x)/,double scaledouble dx=(double)2*scale)/767;return(x+scale)/dx);double frow(double y)/,double scaledouble dy=(double)2*scale)/767;return(y+scale)/dy);void fxynew(double x,double y,double a,double b,double r,double w,double y1,int sd) double zzbar,za,zb,zreal,zimag; double zn,p; zzbar=x*x+y*y; zreal=x; zimag=y; for(int i=1;iGetDC();CBrush hbr;hbr.CreateSolidBrush(RGB(0,0,0);dc-FillRect(&rec,&hbr);/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSO
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司新年企划活动方案
- 公司百人旅游活动方案
- 公司组织小活动方案
- 公司百家讲坛活动方案
- 公司游泳买票活动方案
- 公司组织抓鹅活动方案
- 公司组织集体洗脚活动方案
- 公司盛大年会策划方案
- 公司活动现场策划方案
- 公司活动策划方案
- 电子政务内网机房运维管理制度
- 2025年北京高考化学试卷试题真题及答案详解(精校打印版)
- 陕西省专业技术人员继续教育2025公需课《党的二十届三中全会精神解读与高质量发展》20学时题库及答案
- 福利院财务管理制度
- 2025至2030中国汽车轮毂行业发展分析及发展前景与投资报告
- 郴州市2025年中考第二次模考历史试卷
- 2025年供应链管理考试题及答案
- 2024-2025学年人教版数学五年级下学期期末试卷(含答案)
- 食用薄荷介绍课件
- 学习通《科研诚信与学术规范》课后及考试答案
- 煤矿培训:自救器课件
评论
0/150
提交评论