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

📄 drawcircle_softrockey.cpp

📁 此为本书的配套光盘.本书不但由浅入深地讲解了软件保护技术
💻 CPP
字号:

#include "stdafx.h"
#include "DrawCircle.h"

#include "DrawCircleDoc.h"
#include "DrawCircleView.h"
#include "DrawParamDlg.h"
#include "DrawMethodDlg.h"

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

void CDrawCircleView::DrawCircleMidPoint_SoftRockey(CDC *pDC, int iCenterX, int iCenterY, int r)
{
	int x=0;
	int y=r;
	int p=1-r;
	int seed=0;

	short p1,p2,p3,p4;

	CirclePlotPoints(pDC,iCenterX,iCenterY,x,y);

	m_lpCircleBuf[0].x = x;
	m_lpCircleBuf[0].y = y;
	m_nPointCount=1;

	TRACE("Soft Emulate\n");

	while(x<y)
	{
		p1 = p;
		p2 = x;
		p3 = y;
		p4 = seed;

		RunSoftRockey((WORD&)p1,(WORD&)p2,(WORD&)p3,(WORD&)p4);

		if(p<0)
		{
			p = p1;			
		}		
		else
		{
			p = p2;
			y--;
		}
		x++;
		TRACE("%d,(%d,%d);",p,x,y);
		CirclePlotPoints(pDC,iCenterX,iCenterY,x,y);

		m_lpCircleBuf[m_nPointCount].x = x;
		m_lpCircleBuf[m_nPointCount].y = y;
		m_nPointCount++;
	}
	TRACE("\n");
}

BOOL CDrawCircleView::RunSoftRockey(WORD& A, WORD& B, WORD& C, WORD& D)
{
	// P ----> A
	// X ----> B
	// Y ----> C
	// S ----> D
	
	//WORD E,F,G,H=0xffff;

	B=B+1;		//X++
	B=B*2;		//2*X
	B=B+1;		//2*X+1
	A=A+B;		//P=P+2*X+1
	
	C=C-1;		//Y--
	C=C*2;		//2*Y
	B=A-C;		// P= P+2X+1 - 2Y
	return TRUE;
}

⌨️ 快捷键说明

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