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 illusion 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 ancient 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 2014m HTML5 standard officially released. In the ealier time, the only officially standard was the HTML 4.01 which was released in 1999. Obviously, 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 many 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 technoloy 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 Neumann‘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 the traditional DOM operation and 2D animation calculation while GPU take the response of rendering WebGL and 3D things. There are many APIs in the traditional DOM for Javascript calls, 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 various 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.

原文地址:https://www.cnblogs.com/Arthus/p/8455249.html

时间: 2024-10-18 18:38:47

Animation Physics and The Realization Of Animation In Browsers的相关文章

Android Animation学习(一) Property Animation介绍

Android Animation Android framework提供了两种动画系统: property animation (introduced in Android 3.0)和view animation. 除了这两种系统外,也可以利用Drawable animation,也就是播放序列帧图像. 所以,Android中的Animation分三种: 1. Property Animation 2. View Animation 3. Drawable Animation 下面主要说Pro

Android Animation学习(六) View Animation介绍

View Animation View animation系统可以用来执行View上的Tween animation和Frame animation. Tween animation可以在View对象上执行一系列的简单变换,比如位置.尺寸.旋转.透明度等. animation package 包中包含了tween animation所有的类. 一系列的动画命令定义了一个完整的tween animation,可以用代码定义也可以用XML资源文件定义. XML资源文件 XML资源文件的使用可以见:A

iOS Core Animation Advanced Techniques(六): 基于定时器的动画和性能调优

基于定时器的动画 我可以指导你,但是你必须按照我说的做. -- 骇客帝国 在第10章“缓冲”中,我们研究了CAMediaTimingFunction,它是一个通过控制动画缓冲来模拟物理效果例如加速或者减速来增强现实感的东西,那么如果想更加真实地模拟 物理交互或者实时根据用户输入修改动画改怎么办呢?在这一章中,我们将继续探索一种能够允许我们精确地控制一帧一帧展示的基于定时器的动画. 定时帧 动画看起来是用来显示一段连续的运动过程,但实际上当在固定位置上展示像素的时候并不能做到这一点.一般来说这种显

css3中的变形(transform)、过渡(transtion)、动画(animation)

Transform字面上就是变形,改变的意思.在CSS3中transform主要包括以下几种:旋转rotate.扭曲skew.缩放scale和移动translate以及矩阵变形matrix.下面我们一起来看看CSS3中transform的旋转rotate.扭曲skew.缩放scale和移动translate具体如何实现,老样子,我们就从transform的语法开始吧.是构成transtion和animation的基础. 语法: transform : none | <transform-func

HTML 学习笔记 CSS3(Animation)

CSS3动画: 通过CSS3 我们能够创建动画 这可以在许多网页中取代动画图片 Flash动画 以及JavaScript. CSS3 @keyframes 规则如需在 CSS3 中创建动画,您需要学习 @keyframes 规则.@keyframes 规则用于创建动画.在 @keyframes 中规定某项 CSS 样式,就能创建由当前样式逐渐改为新样式的动画效果. 同样的先看一个例子: <html> <head> <meta charset="UTF-8"

CSS动画效果之animation

Y(^o^)Y css动画大乱弹之animation. 概述 什么是animation呢?在回答这个问题之前,先要说明什么叫做@keyframe(关键帧).@keyframe算是一个动画模板.在其中,可以使用百分比,如从0%到100%的任意值,分别在每个百分比中,加上不同的属性,从而让元素达到一种在不断变化的动画效果.这和我们制作flash动画一样,我们只需设计几个关键帧,系统就能生成动画啦! 一个@keyframe例子: 1 /*定义关键帧动画*/ 2 @keyframes myframe {

iOS Core Animation Advanced Techniques-显式动画

上七章节: 图层树 图层的寄宿图 图层几何学 图层视觉效果 图层变换 专用图层 隐式动画 这篇随笔主要介绍有关图层显式动画. 显示动画: 能对一些属性做指定的自定义动画,或者创建非线性动画 属性动画: 属性动画作用于图层的某个单一属性,并指定了它的一个目标值,或一连串将要做动画的值 属性动画分两种: 1.基础 2.关键帧 基础动画:(通过CALayer的实例方法addAnimation: forKey:给图层添加显示动画) CABasicAnimation-->CAPropertyAnimati

多余的MeshCollider和Animation

如果你是在做手游项目,我强烈建立不要做碰撞,有关一切物理的东西unity对手机支持的并不好,如果不信你可以试试效率你就知道.美术兄弟,每次给过来的场景,都会带上MeshCollider 和Animation 空的组件.这俩东西很占效率的,不信你可以用Profiler 看看.如果你让美工们上传场景的时候手动检查一下,把MeshCollider和Animation空的组件都删掉,我可以很负责的告诉你,他们肯定会忘删除或者错删...比如下图这样的组件. <ignore_js_op> 还有场景的材质最

安卓动画知识总结 Animation AnimationSet LayoutAnimation

本文由PurpleSword(jzj1993)原创,转载请注明 原文网址 http://blog.csdn.net/jzj1993 常见动画有几种 控件View的动画(如Dialog窗口中的圆形进度条) 空间Window的动画(如DialogWindow,PopupWindow的动画,Activity切换时整个Window页面的动画) ViewGroup的LayoutAnimation动画,每个子控件按照设定的顺序.延迟播放动画 动画常用anim/*.xml定义 xml中定义动画,可直接使用<t