画饼图要有几个辅助函数:
这个函数的功能是把正圆上的角度推算成饼图椭圆上的角度。
int CDlgPie::TransformAngel(CRect rect, int angel)
{
int nRectWidth = rect.Width();
int nRectHeight = rect.Height();
double x = nRectWidth * cos(angel * PI / 180);
double y = nRectHeight * sin(angel * PI / 180);
float result = (float)(atan2(y, x) * 180 / PI);
if (result < 0)
{
result += 360;
}
int iResult = (int)(result+0.5);
return iResult;
}
这个函数是用高中的椭圆公式推出来的,但是我数学比较垃圾,不知道应该怎么简化它了。









































既然是立体的,就的有阴影的效果。

{
// 取得原颜色的RGB值
long lRed = GetRValue(lOriginColor);
long lGreen = GetGValue(lOriginColor);
long lBlue = GetBValue(lOriginColor);
//
//
// 对RGB颜色取半
long lResultRed = lRed / 2;
long lResultGreen = lGreen / 2;
long lResultBlue = lBlue / 2;
long lResultColor = RGB(lResultRed, lResultGreen, lResultBlue);
//
return lResultColor;
}
//
//
// 对RGB颜色取半
long lResultRed = lRed / 2;
long lResultGreen = lGreen / 2;
long lResultBlue = lBlue / 2;
long lResultColor = RGB(lResultRed, lResultGreen, lResultBlue);
//
return lResultColor;
}