Graphics2D绘图性能 [英] Graphics2D Drawing Performance

查看:550
本文介绍了Graphics2D绘图性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Swing组件中的Java Graphics2D 对象手动绘制东西,并且我达到大约2000个正方形,我订购对象绘制得非常慢。

I am trying some things out with manually drawing "things" with a Java Graphics2D object within a Swing component and as I reach about >2000 squares that I order the object to draw it gets really slow.

我不知道这是否普遍。 2000个对象是否真的渲染了? Graphics2D 对象的性能不是很高吗?我应该停在现在的位置,而不是在尝试更复杂的东西之前切换到JOGL而且为时已晚?

I have no clue whether or not this is "common". Are 2000 objects to render really "a lot"? Is the Graphics2D object just not very performant? Should I just stop where I am now and rather switch to JOGL before I try out more complex stuff and it is too late?

推荐答案

我编写了一个Java Spirograph GUI,可以在20毫秒或更短的时间内绘制成千上万个线段。

I wrote a Java Spirograph GUI that draws tens of thousands of line segments in 20 milliseconds or less.

确保您在应用程序的其他位置进行计算。你的绘图代码应该只做一件事:绘制。

Make sure you are doing your calculations elsewhere in your application. Your drawing code should do one thing and one thing only: draw.

然而,图形和图形2D的速度存在实际限制。这个Spirograph花了172毫秒来绘制超过250,000个线段。

However, there is a practical limit to the speed of Graphics and Graphics2D. This Spirograph took 172 milliseconds to draw over 250,000 line segments.

这篇关于Graphics2D绘图性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆