@vincentntang : twitter
Some clients
Work
Fundamentals
Showcase Examples
Web makes communication standards easier
The ones that do it best have
great UX design and Animations
mastery requires knowledge in:
SVG, Canvas, WebGL (and CSS)
Software solves problems
...opens oppurtunities for bigger, meaningful projects (dev/agency).
SVG is an XML based vector image format for 2-dimension graphics with support for interactivity and animation. SVG specification was developed by W3C in 1999
- Wikipedia
Can be rendered in any size and resolution
Comprised of vectors drawn with strokes and fill
graphics
Pros:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" width="450px" height="100px" viewBox="0 0 450 100">
<rect x="10" y="5" fill="white" stroke="black" width="90" height="90"/>
<circle fill="white" stroke="black" cx="170" cy="50" r="45"/>
<polygon fill="white" stroke="black" points="279,5 294,35 328,40 303,62 309,94
279,79 248,94 254,62 230,39 263,35 "/>
<line fill="none" stroke="black" x1="410" y1="95" x2="440" y2="6"/>
<line fill="none" stroke="black" x1="360" y1="6" x2="360" y2="95"/>
</svg>
// Returns the bezier points for a smile. Scale is 0-1.
function smilePoints(scale) {
const factor = scale * 2 - 1; // i.e sad = -1, happy = +1
const p1 = { x: -20, y: -10 * factor };
const c1 = { x: -20, y: 10 * factor };
const p2 = { x: 20, y: -10 * factor };
const c2 = { x: 20, y: 10 * factor };
return [p1, c1, c2, p2];
}
function writeSmilePoints(points) {
console.log(points);
const p = p => `${p.x},${p.y}`; // write a point as a coord
return `M${p(points[0])} C${p(points[1])} ${p(points[2])} ${p(
points[3]
)}`;
}
function scaleSmile(scale) {
// Get the geometry of the new smile.
const points = writeSmilePoints(smilePoints(scale));
const svg = document.getElementById("svg");
// Create the geometry animation, which will look summat like this:
// <animate attributeName="d" attributeType="XML"
// to="M-20,10 C-20,-10 20,-10 20,10" dur="3s" repeatCount="indefinite"
// fill="freeze" />
const smilePath = document.getElementById("smilepath");
const animate = document.createElementNS(svg.namespaceURI, "animate");
animate.setAttribute("attributeName", "d");
animate.setAttribute("attributeType", "XML");
animate.setAttribute("to", points);
animate.setAttribute("dur", "0.3s");
animate.setAttribute("repeatCount", "1");
animate.setAttribute("fill", "freeze");
smilePath.appendChild(animate);
animate.beginElement();
}
function onChange() {
// Get the slider value, scale it from percentage to 0-1.
const val = this.value;
const scale = parseInt(val, 10) / 100;
scaleSmile(scale);
}
<svg id="svg" viewbox="0 0 120 120">
<g id="face" transform="translate(60 60)">
<!-- Yellow Background-->
<circle
id="facecircle"
cx="0"
cy="0"
r="50"
stroke="#000000"
stroke-width="2"
fill="#FAD257"
/>
<!-- Left Eye, Right Eye-->
<circle cx="-20" cy="-10" r="5" fill="#000000" />
<circle cx="20" cy="-10" r="5" fill="#000000" />
<!-- Smile -->
<g id="smile" transform="translate(0, 25)">
<path
id="smilepath"
fill="none"
stroke="#000000"
stroke-width="3"
stroke-linecap="round"
d="M-20,-10 C-20,10 20,10 20,-10"
/>
</g>
</g>
</svg>
Hand Code
From Adobe Illustrator, Sketch, etc
SMIL
tanuki-nose {
fill: #e24329;
transition: all 0.8s;
}
.tanuki-nose:hover {
fill: #f1a699;
transition: all 0.1s;
}
svg {
animation: grow 5s infinite;
}
@keyframes grow {
50% {
transform: scale(1.5);
}
}
1. Starting State
2. Ending State
3. Use a library
- Adobe AfterEffects + Plugin (Lottie, BodyMoving)
SVG tool for one-time CSS Animations
6 kB
~200 kB minified per graphic
~32 kB minified
One-time CSS Keyframe
300kB to 10mb
Can set loop amount
pen by sarah drasner
SVG Assets to download
https://www.flaticon.com/
What is it?
- 2011 HTML5 spec, for drawing graphics on a screen
Javascript API that enables creation and display of 3D content inside browser using GPU (Graphical processing unit)
A javascript API that enables creation and display of 3D content inside browser using the graphical processing unit (GPU)
var gl = canvas.getContext("webgl2");
Opensource Javascript library that abstracts complexity of webGL for 3D content, making things easier to manage
1. Scene
2. Camera
3. Renderer
4. Mesh
6. Material
5. Geometry
7. Lights
<Example Code>
//FoV, aspect, near, far
var camera = new THREE.PerspectiveCamera(
75,
window.innerWidth/window.innerHeight,
0.1,
1000
);
camera.position.z = 100;
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var geometry = new THREE.BoxGeometry(20, 20, 20);
var material = new THREE.MeshLambertMaterial({color: 0xfd59d7});
var cube = new THREE.Mesh(geometry, material);
scene.add(cube);
var light = new THREE.PointLight(0xFFFF00);
light.position.set(10, 0, 25);
scene.add(light);
var scene = new THREE.Scene();
By Dennis Gaebel.
// Sets up the scene.
function init() {
// Code from previous steps goes here...
// Load in the mesh and add it to the scene.
var loader = new THREE.JSONLoader();
loader.load( "models/treehouse_logo.js", function(geometry){
var material = new THREE.MeshLambertMaterial({color: 0x55B663});
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
});
// More code goes here next...
}
matterport
http://ellcreative.com/
Simple UX and animation effects
CSS, simple JS, and images, etc
Parallax
CSS Positioning and Javascript
52 kB
WebGL
Shader + lighting support
3D + camera
Three.js
Pixi.js
Canvas
OTHER
SVG
It depends.
check for edge cases first.
SVGs
Native WebGL2
Canvas
CSS
SVG Resources
Some Common Libraries
Tooling
Real World SVG Examples
More Real World SVG
WebGL Resources
Libraries / Tooling
Deeper Dive in 3D without libraries
Real World WebGL Examples
Anything found from these agencies
Real World Canvas Examples
(real world examples are hard to find)
Addional Resources Comparing Technologies
Examples that don't need webGL, SVG, or Canvas
Splitting.js
Anime.js 3.0 (really nice docs)