Animation Physics and The Realization Of Animation In Browsers,

Source: Internet
Author: User

Animation Physics and The Realization Of Animation In Browsers,

Animation Physics

Background

With the development of computer science technology, people are facing more and more information everyday. the traditional static way to display information can't always make our brains excited in the age of information explosion. in this artcile, I will show your the science behind the general animation.

Persistence of vision

Persistence of vision refers to the optical semantic sion that occurs when visual perception of an object does not cease for some time after rays of light proceeding from it have ceased to enter the eye. according this phenomenon, people build animation. in large ent China, people draw a bird and a birdcage on different side of a pan. when you twist the pan, you will see the bird in the birdcage. it's the early application of persistence of vision.

Television broadcasting system and frame

According to the persistence of vision, people can watch animation if we play a series of images in a very short time. But how short the time is? TV in the era of the use of analog signals, television broadcasting system mainly PAL, NTSC, SECAM three, they were using different frame rates. NTSC requires 25 frames in a second while PAL and SECAM require 25 frames in a second. in lastest monitor can play 240 frame a secord, it bring a better experience of watching animation.

3D

3D movie technology has improved sharply in the passing years. The following images will show you why we can see 3d movies.

 

 

Whatever the technology we use, the key why we can see 3d movied is our brain. Our brain can merge 2 images into one!

Acoustics

The early movies are black and white and silent, but the sound is clearly indispensable. The sound also has its 3D world! Our brain can also composite the sound you hear from left ear and right ear. I believe the acoustics is a very big topic so that I 'd like to further this topic in the other articles.

Animation In Browsers

Background

October 2014 m HTML5 standard officially released. in the ealier time, the only officially standard was the HTML 4.01 which was released in 1999. obviusly, the HTML4 has been out of data for a long time. at the begining of the 21st century is a period of rapid development of the internet. in order to meet the increasingly complex requirements of the interaction, Java Applet, ActiveX, Flash, Microsoft Silverlight, SVG and the other front-end technology bloom in that era. then we went through a battle of browser. in that time, developers have to write one style 4 times (-o,-webkit,-moz,-ms ). of course, there are still when ways to avoid writting 4 times. sass, Less and some other solutions came to the world. almost at this time, the internet for mobile rose. because Android and IOS's native browser both use the webkit core, it is more convenient to coding HTML5 for mobile.

The diversity of technology must lead to the increase in learning. Apple killed flash when it delivered the IPhone4. HTML5 standrad came to the word eventually.

HTML5 defines simple animation, excessive, browser storage, multi-threaded, websocket and some other features which only appeared in the native system in the past. however the battle of browsers never ends. the barriers always exists in the latest technology field. after few years of PhoneGap, a wind of React Native blows up. web Audio is still a draft, it's still hard to apply 3D TV technology in browser. the good news is that we have more and more than Loy for our creation.

GPU & CPU

In the early browser, the task is single-threaded. all the work for graphic, network and calculation is done in one thread. in the absence of WebGL and CSS3 era, engineers never think about the GPU in front-end programming. with the development of HTML5, graphics technology has been rapid improved. hardware acceleration went into thr front-end engineers' eye sight.

Before diving in the browser, let's figure out the difference between CPU and GPU. according to John von norann's computer system, the computer consists of operator, controller, memory, input device and output device. CPU is known as the operator of the computer while GPU slowly went the public eye in the current years. modern CPU using multi-core design, each core has a large enough cache, you can handle a variety of complex operations. GPU has more cores compared to each, but each core cache is smaller relative to the CPU. GPU is more suitable for 3D rendering calculations.

In the browser, CPU does the traditional DOM operation and 2D animation calculation while GPU take the response of rendering WebGL and 3D things. there are accessing APIs in the traditional DOM for Javascript cals, Dom's data structure can be repeatedly read and modified, which is more dependent on the cache. in WebGl, the content of the Canvas can not be read once it is rendered, and the programmer usually creates other data structures to store the data model, and each rendering is relatively independent. the real scence of browser's rendering, CPU and GPU are usually used together.

CSS animiation

In CSS3, there are 2 new properties, transition and animation. we can only use CSS3 to build some simple animation. but more importantly, we can get a glimpse of some of the basic elements of animation. duration, delay, time-function, and property are necessary elements. compared to Javascript animation, CSS3 animation rendering process is the browser automatically, the code level of the control ability is more weak. in a browser that supports matrix transformations, transform's animated browser optimizes itself and the browser automatically use GPU to do the hardware acceleration.

Dom animation

DOM animation relative to the Canvas animation, which are elements can be directly interactive, more consumption of CPU resources. in the process of rendering the browser interface, redraw and rearrangement has been happening, and will produce greater performance consumption. the redraw occurs when the style attribute of the element changes, and the rearrangement occurs when the element's position property or the DOM tree changes. in the DOM tree, the rearrangement of the parent node causes the rearrangement of the child nodes, and the absolute positioning elements that get rid of the document flow are relatively more suitable for DOM animations.

Canvas animation

Canvas has 3D and 2D rendering modes. different from the DOM element, Canvas inside the graphics can not be drawn after the need to clear the drawing board to redraw. if you need to store any information, you need to use Javascript to create some other objects to save. because the redraw of the entire Canvas will bring a lot of performance consumption, the common optimization method is part of the redraw Canvas and multiple canvas to achieve animation.

SVG animation

SVG is an extensible markup language used to describe vector graphics. in early browsers, SVG existed as a plugin, and modern browsers built support for SVG. SVG also has some of the features of the DOM and Canvas elements. first, all SVG elements can be assigned an ID and then operated directly via the Javascript API. by changing the element properties, you can change its appearance. compared to DOM elements, SVG elements can show more richer images, and almost all vector graphics can be represented by varous Bessel curves. bessel curves can be converted directly to each other, a lot of irregular graphics transition animation is based on SVG.

Timeline

Animation is based on the art of time, no matter what technology you use to achieve animation, time is a very important element. in the browser, there are two kinds of basic units of time, natural time and frame number of two units. the two units can be converted to each other, but will be subject to the calculation of the thread resources. animals in natural time are animations such as CSS animations, SVG animations, and Javascript in APIs such as setTimeout, setInterval, and so on. and requestAnimationFrame is based on the number of computer frames to achieve animation. relatively speaking requestAnimationFrame is more suitable for drawing animation, better performance. setTimeout and setInterval Although the same function can be implemented on a surface with different APIs, the browser is not the same in the threading mechanism of the browser. the difference here is especially true when the browser resources are tight.

Summary

Thanks to our brains, we can see and hear the 3d world. It is also our brains that give us the feeling of the world.

With the knowledge of browser, we can focus more on the detail of animation. It meams both better experience and more smooth communication with the engineers.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.