开发者

Performance: animating straight polygons vs. curved shapes [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

开发者_开发技巧

Closed 4 years ago.

Improve this question

I'm exploring Flash as an option for implementing an animation-heavy application, and I've got a conceptual question.

My question is: in Adobe Flash, is animating curved shapes significantly more processor-intensive than animating straight polygons? Or are their performances about equal? (Let's say that any shape is pretty simple, with between 3 and 10 vertices/anchor-points per shape, and that there are between 20 and 1000 shapes. Animation would include stretching, squashing, rotating, and translating of shapes.)

Being able to use both without significant slowdown would be great, but it's okay if using only straight polygons is much faster. But I need to know which is usually true before I plan some things.

(I've tried looking on the Internet whether people have already asked this, but the closest thing I can find is raster graphics vs. vector graphics, which is not what I'm talking about: both of my choices use vector graphics.)

Thank you for your time!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜