0

为了解决在 WinForms 中绘制多个形状时闪烁的问题,我决定使用GraphicsPathdo 绘制所有形状,然后使用Graphics. 它完美地工作;即使绘制了大量形状,绘图也不会闪烁。

 panel.Paint += (sender, args) => {
      var graphicsPath = new GraphicsPath(FillMode.Winding);

      for (int i = 0; i < 10; i++)
      {
          graphicsPath.AddEllipse(0, i * 5, 20, 20);
      }

      args.Graphics.FillPath(new SolidBrush(Color.Red),  graphicsPath);

但是,在这种情况下,所有椭圆都是相同的颜色。在重绘形状时使用绘制每个椭圆graphics.FillPath()也会导致闪烁(Paint 事件上的实例)。

有没有办法用不同的颜色绘制每个形状,同时继续像上面那样进行批量绘制?

4

0 回答 0