Building Photoshop in JavaScript & WebGL

Felix Palmer | @pheeelicks | www.pheelicks.com

Building Photoshop in JavaScript & WebGL


Felix Palmer | @pheeelicks | www.pheelicks.com

Slides: felixpalmer.github.io/photo.gl/presentation.html

Code: github.com/felixpalmer/photo.gl

Overview



Slides: felixpalmer.github.io/photo.gl/presentation.html

WebGL basics

Getting a WebGL context

var canvas = document.createElement( 'canvas' );
canvas.width = container.offsetWidth;
canvas.height = container.offsetHeight;
container.appendChild( canvas );
var gl = canvas.getContext( 'webgl' );

Define a quad

quad.vertices = new Float32Array( [
  -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, // 1st triangle
  -1.0, 1.0, 1.0, -1.0, 1.0, 1.0 // 2nd triangle
] );

Shaders

Vertex shader

attribute vec2 aCoordinate;
varying vec2 vCoordinate;
void main() {
  vCoordinate = aCoordinate;
  gl_Position = vec4( aCoordinate, 0, 1 );
}

Fragment shader

varying vec2 vCoordinate;
void main() {
  gl_FragColor = vec4( vCoordinate, 0.0, 1.0 );
}

Pipeline

WebGL basics - recap

DEMO

Image manipulation

Scaling, translating & rotating

Textures

Simple colour tricks

Blending

Warping

Pixel effects

Conclusion

Any Questions?


Felix Palmer | @pheeelicks | www.pheelicks.com

Slides: felixpalmer.github.io/photo.gl/presentation.html

Code: github.com/felixpalmer/photo.gl

@pheeelicks