If It Moves They Will Watch It
Transcript of If It Moves They Will Watch It
-
8/8/2019 If It Moves They Will Watch It
1/52
if it.moves
they.will (_) ->_.watch it
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
2/52
> who
[ {"name": "Sebastian Deutsch", "twitter": "sippndipp"},{"name": "Stephan Seidt", "twitter": "evilhackerdude"}
]
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
3/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
4/52
Drawing & Animation
Canvas
SVG
CSS3
Other low-level techniques we wont cover
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
5/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
6/52
Demo
Samstag, 25. September 2010
http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/canvas-vs-svg-vs-matrix3d/http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/canvas-vs-svg-vs-matrix3d/ -
8/8/2019 If It Moves They Will Watch It
7/52
Quick Recap
c = document.getElementById 'c'.getContext '2d'
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
8/52
... then you go apeshit.
fillRectstrokeRectclearRect
beginPathclosePathstrokefill
moveTolineToarcquadraticCurveTobezierCurveTo
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
9/52Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
10/52
Canvas Animations
Manual redrawing
Main draw loop Clear canvas
Change position
Draw objects
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
11/52Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
12/52
Canvas Interaction
Manual, too Get x/y from click event
Custom collision detection
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
13/52
Libs
ProcessingJS
three.js
Samstag, 25. September 2010
http://github.com/mrdoob/three.js/http://github.com/mrdoob/three.js/http://processingjs.org/http://processingjs.org/ -
8/8/2019 If It Moves They Will Watch It
14/52
Pros
100% flexibility Very fast for some things
Read image data to jpeg/png
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
15/52
Cons
Resolution dependent Not accessible
Text rendering... not trivial
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
16/52
Demos
http://9elements.com/io/projects/html5/canvas/
http://networkmap.projects.9elements.de/
http://9elements.com/projects/bbc_final/
Samstag, 25. September 2010
http://9elements.com/projects/bbc_final/http://networkmap.projects.9elements.de/http://9elements.com/projects/bbc_final/http://9elements.com/projects/bbc_final/http://networkmap.projects.9elements.de/http://networkmap.projects.9elements.de/http://9elements.com/io/projects/html5/canvas/http://9elements.com/io/projects/html5/canvas/http://9elements.com/io/projects/html5/canvas/http://9elements.com/io/projects/html5/canvas/ -
8/8/2019 If It Moves They Will Watch It
17/52
scalable vector graphicsSamstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
18/52
Demo
Samstag, 25. September 2010
http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/canvas-vs-svg-vs-matrix3d/http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/canvas-vs-svg-vs-matrix3d/ -
8/8/2019 If It Moves They Will Watch It
19/52
svg Recap
XML
2D vector graphics
Filters, animations, sounds (WTF!), etc
DOM based
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
20/52
Drawing a red dot
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
21/52
Animation.. um, XML?!
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
22/52Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
23/52
BUT
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
24/52
SVG, JS-style
Raphal
Declarative JS > XML
Has a cool animate function
VML fallback for IE
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
25/52
Interaction
Easy! Use browsers native capabilities
Just addEventListener
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
26/52
Pros
SVG is resolution independent Event handling is a piece of cake
Since its XML it could be accessible
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
27/52
Cons
No pixel manipulation Usually slower than canvas
Needs Raphal for backwards comp.
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
28/52
Demos
http://hackfwd.com/dilution
http://9elements.com/projects/mozilla/
Samstag, 25. September 2010
http://9elements.com/projects/mozilla/http://9elements.com/projects/mozilla/http://hackfwd.com/dilutionhttp://hackfwd.com/dilution -
8/8/2019 If It Moves They Will Watch It
29/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
30/52
Demo
Samstag, 25. September 2010
http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/canvas-vs-svg-vs-matrix3d/http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/canvas-vs-svg-vs-matrix3d/ -
8/8/2019 If It Moves They Will Watch It
31/52
CSS3 recap
Effects? webkitTransition!
Animation?
webkitTransition
webkitAnimation
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
32/52
webkitTransition = '-webkit-transform 1s ease-out 0s'
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
33/52
webkitTransition = '-webkit-transform 1s ease-out 0s'
Animated
property
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
34/52
webkitTransition = '-webkit-transform 1s ease-out 0s'
Animated
property
Duration
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
35/52
webkitTransition = '-webkit-transform 1s ease-out 0s'
Animated
property
DurationTiming
Function
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
36/52
webkitTransition = '-webkit-transform 1s ease-out 0s'
Animated
property
DurationTiming
Function
Initial
Delay
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
37/52
Timing = Sugar
Special timing functions
Demo
Samstag, 25. September 2010
http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/css-transitions/http://9elements.com/html5demos/ifitmovestheywillwatchit/jsconf-demos/css-transitions/ -
8/8/2019 If It Moves They Will Watch It
38/52
webkitTransform
translate3d(x, y, z)
scale3d(x, y, z)
rotateX(a), rotateY(a), rotateZ(a)
matrix3d(...)
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
39/52
What makes CSS3animations uber-useful?
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
40/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
41/52
On iOS devices theyrehardware accelerated!
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
42/52
Interaction isof course native.
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
43/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
44/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
45/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
46/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
47/52
Theres no best
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
48/52
But heres some advice:
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
49/52
Target Device
Does it support your technique?
How do different techniques compare?
Efficiency (FPS)
Responsiveness (Events)
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
50/52
A vague rule of thumb
if mobile?'css3'else
lasers()
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
51/52
Samstag, 25. September 2010
-
8/8/2019 If It Moves They Will Watch It
52/52
ThanksQuestions?