You could write some kind of benchmark test. Lessay:
stage.frameRate = 600;
var itmz:Array = new Array();
for(var i:int = 0; i < 1000; i++){
var item:Shape = new Shape;
[...Draw...]
item.cacheAsBitmap = false;
itmz.push(item);
addChild(item);
}
var timer:Number= getTimer();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void{
trace(getTimer() - timer);
timer = getTimer();
for(var i:int = 0, l:int = itmz.length; i < l; i++){
itmz[i].x = Math.random() * 800;
itmz[i].y = Math.random() * 800;
}
}
More or less like this could be used to test the speed. Then compare the numbers, the best if you have enough shapes to notice a rather strong lag (so you have less than 2 frames per second) and then compare the time between onEnterFrames - the smaller the better. Repeate for different shapes and not down the results.
Edit: On a debate level, I'd say it depends on what you are trying to achieve. if, for example, you were trying to replace every curve with a couple of straight lines (eg: circle turns into 28-sided polygon) then my guess is that Curves are faster. But, replacing a rounded-corner square with square-content square should turn up faster, though I believe it's not going to be a much noticeable change. Unless all the points are continuously morphing a chance is that bitmap caching would remove all differences between them.
Interesting question. The difference beteen a line and a curved line is that there is a virtual point in addition in the second case (the point control that make the curve's depth...notice that I simplify...) but anyway what is really GPU's greedy resource is the tracing because of the float numbers values and especially the anti aliasing. The fewer digits after the decimal point the more beautiful and precise the curves will be. For performance, the most common technique is to automatically adjust the level of detail based on the size of the shape or its curve level. Reguards
发布评论
评论(2)
您可以编写某种基准测试。 Lessay:
或多或少可以用来测试速度。然后比较数字,最好是如果您有足够的形状来注意到相当强的滞后(因此每秒少于 2 帧),然后比较 onEnterFrames 之间的时间 - 越小越好。对不同的形状重复此操作,不要降低结果。
编辑:在辩论层面上,我想说这取决于你想要实现的目标。例如,如果您尝试用几条直线替换每条曲线(例如:圆形变成 28 边形),那么我的猜测是曲线更快。但是,用正方形内容的正方形替换圆角正方形应该会更快,尽管我相信这不会是一个明显的变化。除非所有点都不断变形,否则位图缓存可能会消除它们之间的所有差异。
You could write some kind of benchmark test. Lessay:
More or less like this could be used to test the speed. Then compare the numbers, the best if you have enough shapes to notice a rather strong lag (so you have less than 2 frames per second) and then compare the time between onEnterFrames - the smaller the better. Repeate for different shapes and not down the results.
Edit: On a debate level, I'd say it depends on what you are trying to achieve. if, for example, you were trying to replace every curve with a couple of straight lines (eg: circle turns into 28-sided polygon) then my guess is that Curves are faster. But, replacing a rounded-corner square with square-content square should turn up faster, though I believe it's not going to be a much noticeable change. Unless all the points are continuously morphing a chance is that bitmap caching would remove all differences between them.
有趣的问题。直线和曲线的区别在于,在第二种情况下,还有一个虚拟点(控制曲线深度的点……注意我简化了……)但无论如何,GPU 的贪婪资源到底是什么?是由于浮点数值,尤其是抗锯齿而进行的跟踪。
小数点后的位数越少,曲线就越漂亮、越精确。对于性能而言,最常见的技术是根据形状的大小或其曲线级别自动调整细节级别。
问候
Interesting question. The difference beteen a line and a curved line is that there is a virtual point in addition in the second case (the point control that make the curve's depth...notice that I simplify...) but anyway what is really GPU's greedy resource is the tracing because of the float numbers values and especially the anti aliasing.
The fewer digits after the decimal point the more beautiful and precise the curves will be. For performance, the most common technique is to automatically adjust the level of detail based on the size of the shape or its curve level.
Reguards