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

📄 juliaview.cpp

📁 《分形算法与程序设计VC版》一书<5_02>:内含基于逃逸时间算法的Julia集源代码。双击Debug下的Julia.exe文件
💻 CPP
字号:
// JuliaView.cpp : implementation of the CJuliaView class
//

#include "stdafx.h"
#include "Julia.h"

#include "JuliaDoc.h"
#include "JuliaView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CJuliaView

IMPLEMENT_DYNCREATE(CJuliaView, CView)

BEGIN_MESSAGE_MAP(CJuliaView, CView)
	//{{AFX_MSG_MAP(CJuliaView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CJuliaView construction/destruction

CJuliaView::CJuliaView()
{
	// TODO: add construction code here

	
	K=100;
	m=500;
	Mx=800;
	My=600;
	xs = -1.5; xl = 1.5; ys = -1.5; yl = 1.5;
	p = 0.32; q = 0.043;
}

CJuliaView::~CJuliaView()
{
}

BOOL CJuliaView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CJuliaView drawing

void CJuliaView::OnDraw(CDC* pDC)
{
	CJuliaDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
    AfxGetMainWnd()->SetWindowText("Julia集(分形频道:fractal.cn)2004");
	xb = (xl - xs) / Mx;
    yb = (yl - ys) / My;
	for(nx=0;nx<=Mx;nx++)
         {
          for(ny=0;ny<=My;ny++)
			  
          {  x0=xs+nx*xb;
             y0=ys+ny*yb;
             k=0;
         loop1:
             xk=x0*x0-y0*y0+p;
             yk=2*x0*y0+q;
             k=k+1;
             r=xk*xk+yk*yk;
             x0=xk,y0=yk;
             if(r>m){
             H=k;
			 goto loop2;}
			 if(k==K){
             H=int(r*10);goto loop2;}
             if(r<=m && k<K) goto loop1;
         loop2:
             pDC->SetPixel(nx,ny,H*1000);
		  }		 
         		   
      }
}

/////////////////////////////////////////////////////////////////////////////
// CJuliaView diagnostics

#ifdef _DEBUG
void CJuliaView::AssertValid() const
{
	CView::AssertValid();
}

void CJuliaView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CJuliaDoc* CJuliaView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJuliaDoc)));
	return (CJuliaDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CJuliaView message handlers

⌨️ 快捷键说明

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