-
大小: 46KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-06-09
- 语言: C/C++
- 标签:
资源简介
这是用VC2005的MFC做的,绘制五角星和sin曲线
代码片段和文件信息
// FiveStar.cpp: implementation of the CFiveStar class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “mfc5s.h“
#include “FiveStar.h“
#include
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFiveStar::CFiveStar()
{
}
CFiveStar::~CFiveStar()
{
}
// 计算这五个点的位置
void CFiveStar::CalculatePt(float x float y float r)
{
// 计算外圈点坐标
float angle = 90;
for (int i=0; i<5; i++)
{
pt5[i].x = (int)(-r * cosf(angle * 3.14159265f / 180) + x);
pt5[i].y = (int)(-r * sinf(angle * 3.14159265f / 180) + y);
angle += 360 / 5;
}
// 计算内圈点坐标
float r2 = r * sinf(18 * 3.14159265f / 180) / cosf(36 * 3.14159265f / 180);
angle = 90 - 36;
for (i=5; i<10; i++)
{
pt5[i].x = (int)(-r2 * cosf(angle * 3.14159265f / 180) + x);
pt5[i].y = (int)(-r2 * sinf(angle * 3.14159265f / 180) + y);
angle += 360 / 5;
}
}
//static int index[5] = {135241};
static int index2[11] = {172839410561};
// 重新排列这五个点
void CFiveStar::RearrangePt()
{
for (int i=0; i<11; i++)
{
pt6[i].x = pt5[ index2[i]-1 ].x;
pt6[i].y = pt5[ index2[i]-1 ].y;
}
}
// 对五角星进行绘制
void CFiveStar::OnDraw(CDC *pDC)
{
pDC->Polyline(pt6 11);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 118833 2011-09-23 00:17 mfc5s\Debug\mfc5s.exe
I.A.... 1516 2011-09-23 00:00 mfc5s\FiveStar.cpp
I.A.... 731 2011-09-22 23:59 mfc5s\FiveStar.h
I.A.... 2506 2011-09-22 23:30 mfc5s\MainFrm.cpp
I.A.... 1581 2011-09-22 23:30 mfc5s\MainFrm.h
I.A.... 28444 2011-09-22 23:33 mfc5s\mfc5s.aps
I.A.... 2175 2011-09-23 00:30 mfc5s\mfc5s.clw
I.A.... 4191 2011-09-22 23:30 mfc5s\mfc5s.cpp
I.A.... 4794 2011-09-23 00:30 mfc5s\mfc5s.dsp
I.A.... 533 2011-09-22 23:30 mfc5s\mfc5s.dsw
I.A.... 1345 2011-09-22 23:30 mfc5s\mfc5s.h
I.A.... 49664 2011-09-23 00:30 mfc5s\mfc5s.opt
I.A.... 1313 2011-09-23 00:17 mfc5s\mfc5s.plg
I.A.... 10536 2011-09-22 23:30 mfc5s\mfc5s.rc
I.A.... 1722 2011-09-22 23:30 mfc5s\mfc5sDoc.cpp
I.A.... 1464 2011-09-22 23:30 mfc5s\mfc5sDoc.h
I.A.... 2700 2011-09-23 00:15 mfc5s\mfc5sView.cpp
I.A.... 1960 2011-09-23 00:15 mfc5s\mfc5sView.h
I.A.... 4287 2011-09-22 23:30 mfc5s\ReadMe.txt
I.A.... 1078 2011-09-22 23:30 mfc5s\res\mfc5s.ico
I.A.... 397 2011-09-22 23:30 mfc5s\res\mfc5s.rc2
I.A.... 1078 2011-09-22 23:30 mfc5s\res\mfc5sDoc.ico
I.A.... 1078 2011-09-22 23:30 mfc5s\res\Toolbar.bmp
I.A.... 492 2011-09-22 23:30 mfc5s\Resource.h
I.A.... 1119 2011-09-23 00:17 mfc5s\SinCurve.cpp
I.A.... 680 2011-09-23 00:13 mfc5s\SinCurve.h
I.A.... 207 2011-09-22 23:30 mfc5s\StdAfx.cpp
I.A.... 1054 2011-09-22 23:30 mfc5s\StdAfx.h
I..D... 0 2011-09-23 00:17 mfc5s\Debug
I..D... 0 2011-09-22 23:30 mfc5s\res
............此处省略4个文件信息
评论
共有 条评论