Posted 09 July 2015 - 07:57 AM
I have noticed animations in various operating systems such as OneOS and NinOS, and I was just wondering exactly how these are accomplished? Is it just a buffer being redrawn in a different location?
Minor hint(as I don't know how they handle this either): Performance is one of the key drawbacks when it comes to animations in CC, as the rendering does consume quite a fuck of time. So in order to create animations that are smooth, you want to have as few calls to write as possible. There are several APIs for accomplishing that(only writing things that have changed) out there. The surface api is one of the most commonly used, when not using a custom routine for that.
It claims to use the least amount of drawing calls possible, although I don't know if thats correct or confirmed. I'm pretty sure there are still some things you could do to reduce it even further. I don't know the techniques used by the api
Such OSes are usually written with OOP in mind to help reduce the code and complexity of it. When an animation happens certain objects that need to be animated just get their position, color, dimensions changed gradually over time, most of the time with the help of "timer" events, rather than using sleep() directly, as the OS has to be operable while performing animations.
os.loadAPI("GIF")
local myAnimation = GIF.buildGIF(paintutils.loadImage("someImage"), paintutils.loadImage("someOtherImage"), etc)
-- Set how long each frame should display for (default is a tenth of a second):
myAnimation[1].delay = 1
myAnimation[2].delay = 0.5
-- etc
-- Do the animation:
GIF.animateGIF(myAnimation)