GraphicsPath path;
path.AddEllipse((int)(bb[i].x), (int)(bb[i].y), (int)(bb[i].x + 180), (int)(bb[i].y + 180));
// 构造路径渐变画刷
PathGradientBrush PGBrush(&path);
// 设置中心点色彩
PGBrush.SetCenterColor(Color(255, 255, 255, 255));
// 设置每个端点的色彩
Color colors[] = { Color(255, 0, 0, 0) };
int count = 1;
PGBrush.SetSurroundColors(colors, &count);
// 设置中心点
PGBrush.SetCenterPoint(Point(bb[i].x+90,bb[i].y+90));
// 填充目标路径
graphics.FillRectangle(&PGBrush, (int)(bb[i].x), (int)(bb[i].y), (int)(bb[i].x + 180), (int)(bb[i].y + 180));
为什么我画出来的是椭圆,脑袋快炸了
bb[i].x 与 bb[i].y 不相等时,bb[i].x + 180 与 bb[i].y + 180 也不相等 , 出来椭圆。
我用下面的代码测试:
GraphicsPath path;
path.AddEllipse(50, 60, 140, 140); //后两个参数需要相等。
// 构造路径渐变画刷
PathGradientBrush PGBrush(&path);
// 设置中心点色彩
PGBrush.SetCenterColor(Color(255, 255, 255, 255));
// 设置每个端点的色彩
Color colors[] = { Color(255, 0, 0, 0) };
int count = 1;
PGBrush.SetSurroundColors(colors, &count);
// 设置中心点
PGBrush.SetCenterPoint(Point(50 + 90, 60 + 90));
// 填充目标路径
graphics.FillRectangle(&PGBrush, 50, 60, 140,140); //后两个参数需要相等
结果如下:
用心回答每个问题,如果有帮助,请采纳答案好吗,谢谢~~~