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

报告相同问题?

悬赏问题

  • ¥15 CSS实现渐隐虚线框
  • ¥15 有没有帮写代码做实验仿真的
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真