qq_27635591 2017-06-02 06:55 采纳率: 100%
浏览 2858
已采纳

GDI+渐变画刷画圆,我画出来的是椭圆

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));

    为什么我画出来的是椭圆,脑袋快炸了
  • 写回答

2条回答 默认 最新

  • 战在春秋 2017-06-02 08:27
    关注

    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); //后两个参数需要相等
    

    结果如下:

    图片说明

    用心回答每个问题,如果有帮助,请采纳答案好吗,谢谢~~~

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码