資源簡介
在visual C++ 下實現MFC類的畫圓弧算法,對話框輸入圓心,半徑,起始角度,終止角度,顏色等參數,即可畫出圓弧

代碼片段和文件信息
//?Acr.cpp:?implementation?of?the?Acr?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“HW4.h“
#include?“Acr.h“
#include?“math.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
Acr::Acr()
{
}
Acr::~Acr()
{
}
void?Acr::Arc1(int?x1?int?y1?int?x2?int?y2?int?r?CDC?*pDC)
{
?int?xydj;
?x=x1;
?y=y1;
?j=abs(x2-x1)+abs(y2-y1);
?d=x1*x1+y1*y1-r*r;
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?while(j>0){
?if(d>=0){
?d=d-2*x+1;
?x--;
?}else{
?d=d+2*y+1;
?y++;
?}
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?j--;
??}
}
void?Acr::Arc2(int?x1?int?y1?int?x2?int?y2?int?r?CDC?*pDC)
{
int?xydj;
?x=x1;
?y=y1;
?j=abs(x2-x1)+abs(y2-y1);
?d=x1*x1+y1*y1-r*r;
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?while(j>0){
?if(d>=0){
?d=d-2*y+1;
?y--;
?}else{
?d=d-2*x+1;
?x--;
?}
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?j--;
??}
}
void?Acr::Arc3(int?x1?int?y1?int?x2?int?y2?int?r?CDC?*pDC)
{
int?xydj;
?x=x1;
?y=y1;
?j=abs(x2-x1)+abs(y2-y1);
?d=x1*x1+y1*y1-r*r;
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?while(j>0){
?if(d>=0){
?d=d+2*x+1;
?x++;
?}else{
?d=d-2*y+1;
?y--;
?}
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?j--;
??}
}
void?Acr::Arc4(int?x1?int?y1?int?x2?int?y2?int?r?CDC?*pDC)
{
int?xydj;
?x=x1;
?y=y1;
?j=abs(x2-x1)+abs(y2-y1);
?d=x1*x1+y1*y1-r*r;
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?while(j>0){
?if(d>=0){
?d=d+2*y+1;
?y++;
?}else{
?d=d+2*x+1;
?x++;
?}
?pDC->SetPixel(x+xcy+ycRGB(redgreenblue));
?j--;
??}
}
void?Acr::MArc(CDC?*pDC)
{?int?x1y1x2y2deltion;
???x1=int(r*cos(start*3.14/180));
???y1=int(r*sin(start*3.14/180));
???x2=int(r*cos(end*3.14/180));
???y2=int(r*sin(end*3.14/180));
?
???if(x1>=0?&&?y1>=0){
???if(x2>=0?&&?y2>0)?deltion=1;
???if(x2>=0?&&?y2==0)?deltion=4;
???if(x2<0?&&?y2>=0)?deltion=2;
???if(x2<=0?&&?y2<0)?deltion=3;
???if(x2>0?&&?y2<0)?deltion=4;
???}
???if(x1<0?&&?y1>=0){
???if(x2<0?&&?y2>=0)?deltion=5;
???if(x2<=0?&&?y2<0)?deltion=6;
???if(x2>0?&&?y2<=0)?deltion=7;
???}
????if(x1<=0?&&?y1<0){
???if(x2<=0?&&?y2<0)?deltion=8;
???if(x2>0?&&?y2<=0)?deltion=9;
???}
if(x1>0?&&?y1<0){
???if(x2>0?&&?y2<=0)?deltion=10;
???if(x2>=0?&&?y2>=0)?deltion=11;
???}
switch(deltion){
case?1:Arc1(x1y1x2y2rpDC);
break;
case?2:Arc1(x1y10rrpDC);
???Arc2(0rx2y2rpDC);
break;
????case?3:Arc1(x1y10rrpDC);
???Arc2(0r-r0rpDC);
???Arc3(-r0x2y2rpDC);
break;
case?4:Arc1(x1y10rrpDC);
???Arc2(0r-r0rpDC);
???Arc3(-r00-rrpDC);
???Arc4(0-rx2y2
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3485??2013-10-31?17:10??HW4\Acr.cpp
?????文件????????821??2013-10-30?10:44??HW4\Acr.h
?????文件???????1284??2013-11-01?10:03??HW4\ArcDlg.cpp
?????文件???????1286??2013-10-30?10:21??HW4\ArcDlg.h
?????文件??????12051??2013-11-01?10:00??HW4\Debug\Acr.obj
?????文件???????9825??2013-11-01?10:03??HW4\Debug\ArcDlg.obj
?????文件????2207796??2013-11-01?10:17??HW4\Debug\HW4.exe
?????文件????2569376??2013-11-01?10:17??HW4\Debug\HW4.ilk
?????文件??????21423??2013-10-31?16:24??HW4\Debug\HW4.obj
?????文件????5519452??2013-10-31?16:24??HW4\Debug\HW4.pch
?????文件????4178944??2013-11-01?10:17??HW4\Debug\HW4.pdb
?????文件??????15564??2013-10-31?16:24??HW4\Debug\HW4.res
?????文件??????13197??2013-10-31?16:24??HW4\Debug\HW4Doc.obj
?????文件??????22782??2013-11-01?10:17??HW4\Debug\HW4View.obj
?????文件??????18532??2013-10-31?16:24??HW4\Debug\MainFrm.obj
?????文件?????105395??2013-10-31?16:24??HW4\Debug\StdAfx.obj
?????文件?????214016??2013-11-13?15:42??HW4\Debug\vc60.idb
?????文件?????372736??2013-11-01?10:17??HW4\Debug\vc60.pdb
?????文件??????45284??2013-10-30?10:21??HW4\HW4.APS
?????文件???????3348??2013-10-30?10:44??HW4\HW4.clw
?????文件???????4155??2013-10-30?10:02??HW4\HW4.cpp
?????文件???????4705??2013-10-31?16:26??HW4\HW4.dsp
?????文件????????514??2013-10-30?10:02??HW4\HW4.dsw
?????文件???????1323??2013-10-30?10:02??HW4\HW4.h
?????文件?????115712??2013-11-21?16:39??HW4\HW4.ncb
?????文件??????48640??2013-11-21?16:39??HW4\HW4.opt
?????文件????????240??2013-11-13?15:42??HW4\HW4.plg
?????文件??????13272??2013-10-30?10:21??HW4\HW4.rc
?????文件???????1682??2013-10-30?10:02??HW4\HW4Doc.cpp
?????文件???????1442??2013-10-30?10:02??HW4\HW4Doc.h
............此處省略18個文件信息
評論
共有 條評論