Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced Frontend Development

Advanced Frontend Development

Slides for a local meetup in Bristol to talk about some mid to advanced level web frontend development.

Avatar for Edan Kwan

Edan Kwan

April 23, 2015

Other Decks in Technology

Transcript

  1. ANIMATION function loop() { // clamp at maximum 60fps in

    browser requestAnimationFrame(loop); render(); } function render() { // draw something }
  2. Reference: https://www.desmos.com/calculator/dvjcecgagy LERP function lerp(from, to, ratio) { return from

    + (to - from) * ratio; } Example: https://jsfiddle.net/5r6u5jt4/light/
  3. TWEEN ENGINES • Tweenmax • Tween.js • EKTweener.js TweenMax.to(elem, duration,

    {property: value, ease: easingFunction}); TweenMax.fromTo(elem, duration, {property: fromValue}, {property: toValue});
  4. WHAT'S WEBGL? • OpenGL ES 2.0 • Lower level API

    • Experimental(still) WebGL !== 3D !==Three.JS
  5. VERTEX SHADER • gl.POINTS • gl.LINES • gl.LINE_STRIP • gl.LINE_LOOP

    • gl.TRIANGLES • gl.TRIANGLE_STRIP • gl.TRIANGLE_FAN var vertices = [x0, y0, x1, y1, x2, y2...] gl.drawArrays(gl.triangles, .. // OR DrawElements with Indices gl.drawElements(gl.triangles, .. JS with WebGL API GLSL attribute vec2 aPosition; void main(void) { gl_Position = vec4(aPosition, 0.0, 1.0); }
  6. FRAGMENT SHADER var texture = gl.createTexture(); texture.image = image; gl.bindTexture(gl.TEXTURE_2D,

    texture); uniform sampler2D uTexture; varying vec2 vTexCoord; void main() { gl_FragColor = texture2D(uTexture, vTexCoord); } GLSL JS with WebGL API
  7. BASIC GLSL DATA TYPES • float • bool • int

    • vec2 • vec3 • vec4 • ivec2... • bvec2... • mat2 • mat3 • mat4