Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有绘制曲线动画的简单动画。我使用的每个 OnDraw:
lines.add(...); for(int i = 1; i < lines.Count; i++) ds.DrawLine(lines[i - 1], lines[i], Colors.Green, 2);`
行数超过10000。我该如何优化呢?
如果您每次只添加线条而之前的线条保持不变,请考虑缓存您之前的绘图结果。与其将所有线条直接绘制到 CanvasControl 上,不如将它们绘制到 CanvasRenderTarget 中,然后将该渲染目标绘制到 CanvasControl 上。现在,您只需每次都将新的线条添加到渲染目标,将它们绘制在您之前绘制的所有重复使用的线条的顶部。