想在以上非线性的闭合区域内填充颜色,需要怎么弄?
void DrawRadicalSlider::OnPaint()
{
CPen pen;
CPen *my_old_pen;
//CBrush brush, *p_old_brush;
CPaintDC dc(this);
CPoint center;
CRect rect;
int out_radius = 200;// 设置外圈圆弧半径
int inter_radius = 150; // 设置内圈圆弧半径
CDC *pdc = GetDC();
pen.CreatePen(PS_SOLID,2,RGB(0,0,0));
my_old_pen = dc.SelectObject(&pen);
//brush.CreateSolidBrush(RGB(0,0,0));
//p_old_brush = dc.SelectObject(&brush);
//dc.MoveTo(0,0);
//dc.LineTo(0,100);
//dc.LineTo(100,100);
//dc.LineTo(100,0);
//dc.LineTo(0,0);
GetClientRect(rect); // 获取窗口矩形
center = rect.CenterPoint(); // 获取窗口中心位置坐标
float rad = 120 * pi / 180;
dc.Arc(center.x - out_radius, center.y - out_radius,
center.x + out_radius, center.y + out_radius,
center.x, center.y - out_radius,
(center.x - sin(rad) * out_radius), (center.y - cos(rad) * out_radius));
dc.Arc(center.x - inter_radius, center.y - inter_radius,
center.x + inter_radius, center.y + inter_radius,
center.x, center.y - inter_radius,
(center.x - sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius));
dc.MoveTo(center.x, center.y - inter_radius);
dc.LineTo(center.x, center.y - out_radius);
dc.MoveTo((center.x - sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius));
dc.LineTo((center.x - sin(rad) * out_radius), (center.y - cos(rad) * out_radius));
center.x = center.x + 5; // 圆心向右偏移5
dc.Arc(center.x - out_radius, center.y - out_radius,
center.x + out_radius, center.y + out_radius,
(center.x + sin(rad) * out_radius), (center.y - cos(rad) * out_radius),
center.x, center.y - out_radius);
dc.Arc(center.x - inter_radius, center.y - inter_radius,
center.x + inter_radius, center.y + inter_radius,
(center.x + sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius),
center.x, center.y - inter_radius);
dc.MoveTo(center.x, center.y - inter_radius);
dc.LineTo(center.x, center.y - out_radius);
dc.MoveTo((center.x + sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius));
dc.LineTo((center.x + sin(rad) * out_radius), (center.y - cos(rad) * out_radius));
center.x = center.x - 2.5;
center.y = center.y + 5; // 圆心向下偏移5
dc.Arc(center.x - out_radius, center.y - out_radius,
center.x + out_radius, center.y + out_radius,
(center.x - sin(rad) * out_radius), (center.y - cos(rad) * out_radius),
(center.x + sin(rad) * out_radius), (center.y - cos(rad) * out_radius));
dc.Arc(center.x - inter_radius, center.y - inter_radius,
center.x + inter_radius, center.y + inter_radius,
(center.x - sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius),
(center.x + sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius));
dc.MoveTo((center.x - sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius));
dc.LineTo((center.x - sin(rad) * out_radius), (center.y - cos(rad) * out_radius));
dc.MoveTo((center.x + sin(rad) * inter_radius), (center.y - cos(rad) * inter_radius));
dc.LineTo((center.x + sin(rad) * out_radius), (center.y - cos(rad) * out_radius));
//dc.SelectObject(p_old_brush);
DeleteObject(dc);
}