绘制旋转七彩动画_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

阅读更多
换一批

源码分享 GDIPlus绘制旋转七彩动画

11-27

[img=http://img.bbs.csdn.net/upload/201611/27/1480219259_332975.gif][/img]rnrn[b]实现方法:[/b]rn使用GDIPlus,FillPie方法,把各个色块当饼形图画出。rnrn[code=c]void CRotateAnimation::DrawPie(HDC hDC)rnrn Gdiplus::Graphics* pGraphics=new Gdiplus::Graphics(hDC);rn pGraphics->SetSmoothingMode(SmoothingModeHighQuality);rn Gdiplus::Color clr(150,0,0,0);rn Gdiplus::SolidBrush* pBrush=new Gdiplus::SolidBrush(clr);rn //--------------------------------------------------------rn //计算外圈、内圈位置rn Gdiplus::Rect rcOut(m_Rect);rn Gdiplus::Rect rcIn(rcOut);rn rcIn.Inflate(-m_ItemSize,-m_ItemSize);rn //--------------------------------------------------------rn //先画出外圈小方块rn float fStartAngle = -90;//起始绘制角度rn float fSweepAngle = 360 / m_AnimationCount;//每小块的角度rn for(int i=0;iSetColor(clr);rn pGraphics->FillPie(pBrush,rcOut, fStartAngle, fSweepAngle - m_MarginAngle);rn fStartAngle = fStartAngle + fSweepAngle;rn rn //--------------------------------------------------------rn //画出内圈小方块;rn fStartAngle = -90;rn for(int i=0;iSetColor(clr);rn pGraphics->FillPie(pBrush,rcIn, fStartAngle, fSweepAngle - m_MarginAngle);rn fStartAngle = fStartAngle + fSweepAngle;rn rn //--------------------------------------------------------rn //画出中间圆心,用控件底色填充rn rcIn.Inflate(-m_ItemSize,-m_ItemSize);rn clr.SetFromCOLORREF(m_ColorBack);rn pBrush->SetColor(clr);rn pGraphics->FillEllipse(pBrush,rcIn);rn //--------------------------------------------------------rn delete pBrush;rn delete pGraphics;rn[/code]rnrn[b]源码下载[/b]rn[url=http://blog.csdn.net/cometnet/article/details/53363596]http://blog.csdn.net/cometnet/article/details/53363596[/url]

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