邓学彬(泪闯天涯)的专栏

功能界面相辅相成,重视软件界面设计,努力提高用户体验,致力提升软件价值

绘制旋转七彩动画_VC源码_易语言源码

实现方法:

使用GDIPlus,FillPie方法,把各个色块当饼形图画出。

void CRotateAnimation::DrawPie(HDC hDC)
{
	Gdiplus::Graphics* pGraphics=new Gdiplus::Graphics(hDC);
	pGraphics->SetSmoothingMode(SmoothingModeHighQuality);
	Gdiplus::Color clr(150,0,0,0);
	Gdiplus::SolidBrush* pBrush=new Gdiplus::SolidBrush(clr);
	//--------------------------------------------------------
	//计算外圈、内圈位置
	Gdiplus::Rect rcOut(m_Rect);
	Gdiplus::Rect rcIn(rcOut);
	rcIn.Inflate(-m_ItemSize,-m_ItemSize);
	//--------------------------------------------------------
	//先画出外圈小方块
	float fStartAngle = -90;//起始绘制角度
	float fSweepAngle = 360 / m_AnimationCount;//每小块的角度
	for(int i=0;i<m_AnimationCount;i++)
	{
		clr.SetFromCOLORREF(m_pAnimationArray[i].clrOut);
		pBrush->SetColor(clr);
		pGraphics->FillPie(pBrush,rcOut, fStartAngle, fSweepAngle - m_MarginAngle);
		fStartAngle = fStartAngle + fSweepAngle;
	}
	//--------------------------------------------------------
	//画出内圈小方块;
	fStartAngle = -90;
	for(int i=0;i<m_AnimationCount;i++)
	{
		clr.SetFromCOLORREF(m_pAnimationArray[i].clrIn);
		pBrush->SetColor(clr);
		pGraphics->FillPie(pBrush,rcIn, fStartAngle, fSweepAngle - m_MarginAngle);
		fStartAngle = fStartAngle + fSweepAngle;
	}
	//--------------------------------------------------------
	//画出中间圆心,用控件底色填充
	rcIn.Inflate(-m_ItemSize,-m_ItemSize);
	clr.SetFromCOLORREF(m_ColorBack);
	pBrush->SetColor(clr);
	pGraphics->FillEllipse(pBrush,rcIn);
	//--------------------------------------------------------
	delete pBrush;
	delete pGraphics;
}

源码下载

CSDN下载(VC/VS2005源码)

http://download.csdn.net/detail/cometnet/9694770

易语言论坛下载(易语言版源码)

http://bbs.eyuyan.com/thread.php?fid=124

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭