interactive web with fabric.js @ meet.js

31
Fabric.js Interactive Web With by @kangax Saturday, October 19, 13

Upload: juriy-zaytsev

Post on 01-Sep-2014

2.638 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Interactive web with Fabric.js @ meet.js

Fabric.jsInteractive Web With

by @kangax

Saturday, October 19, 13

Page 2: Interactive web with Fabric.js @ meet.js

Saturday, October 19, 13

Page 3: Interactive web with Fabric.js @ meet.js

WildDuck

swim() quack() fly()

RubberDuck

swim() quack() toy: true

Duck

swim() quack()

ScroogeMcDuck

swim() quack() moneyDive()

Saturday, October 19, 13

Page 4: Interactive web with Fabric.js @ meet.js

printio.ru

Saturday, October 19, 13

Page 5: Interactive web with Fabric.js @ meet.js

HTML5 Canvasinterface CanvasPathMethods { ... void closePath(...); void moveTo(...); void lineTo(...); void quadraticCurveTo(...); void bezierCurveTo(...); void arcTo(...); void rect(...); void arc(...); void ellipse(...); ... };

Saturday, October 19, 13

Page 6: Interactive web with Fabric.js @ meet.js

Fabric.jsHTML5 Canvas Library

Interactive object modelon top of <canvas> element

Saturday, October 19, 13

Page 7: Interactive web with Fabric.js @ meet.js

Fabric vs canvasvar canvasEl = document.getElementById(‘c’);var ctx = canvasEl.getContext(‘2d’);ctx.fillStyle = ‘red’;ctx.fillRect(10, 10, 100, 100);

var canvas = new fabric.Canvas(‘c’);var rect = new fabric.Rect({ left: 10, top: 10, fill: ‘red’, width: 100, height: 100});canvas.add(rect);

Saturday, October 19, 13

Page 8: Interactive web with Fabric.js @ meet.js

Fabric vs canvasvar canvasEl = document.getElementById(‘c’);var ctx = canvasEl.getContext(‘2d’);ctx.fillStyle = ‘red’;ctx.save();ctx.translate(10, 10);ctx.rotate(Math.PI / 180 * 45);ctx.fillRect(-10, -10, 100, 100);ctx.restore();

var canvas = new fabric.Canvas(‘c’);var rect = new fabric.Rect({ left: 10, top: 10, fill: ‘red’, width: 100, height: 100, angle: 45});canvas.add(rect);

Saturday, October 19, 13

Page 9: Interactive web with Fabric.js @ meet.js

Fabric vs canvasctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);

ctx.fillRect(20, 50, 20, 20);

rect.set({ left: 20, top: 50});canvas.renderAll();

Saturday, October 19, 13

Page 10: Interactive web with Fabric.js @ meet.js

Fabric vs canvasctx.beginPath();ctx.moveTo(20, 10);ctx.lineTo(80, 10);ctx.quadraticCurveTo(90, 10, 90, 20);ctx.lineTo(90, 80);ctx.quadraticCurveTo(90, 90, 80, 90);ctx.lineTo(20, 90);ctx.quadraticCurveTo(10, 90, 10, 80);ctx.lineTo(10, 20);ctx.quadraticCurveTo(10, 10, 20, 10);ctx.fill();

var rect = new fabric.Rect({ left: 10, top: 10, width: 80, height: 80, rx: 10, ry: 10});

Saturday, October 19, 13

Page 11: Interactive web with Fabric.js @ meet.js

OOP fabric.Textfabric.Image

fabric.PathGroup

Saturday, October 19, 13

Page 12: Interactive web with Fabric.js @ meet.js

OOP fabric.Textfabric.Image

fabric.PathGroup

render()render()

render()

Saturday, October 19, 13

Page 13: Interactive web with Fabric.js @ meet.js

OOP fabric.Textfabric.Image

fabric.PathGroup

render()toSVG()toJSON()

render()toSVG()toJSON()

render()toSVG()toJSON()

Saturday, October 19, 13

Page 14: Interactive web with Fabric.js @ meet.js

OOPfabric.Object

fabric.Linefabric.Circlefabric.Trianglefabric.Ellipsefabric.Rectfabric.Polylinefabric.Polygonfabric.Groupfabric.Textfabric.Imagefabric.Path

fabric.Canvas

has

is

fabric.PathGroup

fabric.Colorfabric.Gradientfabric.Patternfabric.Shadow

has

fabric.Observablefabric.Collectionmixin

is

Saturday, October 19, 13

Page 15: Interactive web with Fabric.js @ meet.js

Features Demo

Saturday, October 19, 13

Page 16: Interactive web with Fabric.js @ meet.js

GoalsSimple, Intuitive

fabric.Image.fromURL('...', function(img) { img.scale(0.5).set({ left: 250, top: 250, angle: -15, clipTo: function (ctx) { ... } }); canvas.add(img).setActiveObject(img);});

Saturday, October 19, 13

Page 17: Interactive web with Fabric.js @ meet.js

GoalsSimple, IntuitiveModular

~50 small classes/modules

Custom build: 77-204KB

Flexible architecture: image filters, brushes

Saturday, October 19, 13

Page 18: Interactive web with Fabric.js @ meet.js

GoalsSimple, IntuitiveModularEncapsulated

Everything is under 1 object — fabric

Plays well with other libraries

No non-standard host object additions

Saturday, October 19, 13

Page 19: Interactive web with Fabric.js @ meet.js

GoalsSimple, IntuitiveModularEncapsulatedTests, tests, tests

fabricjs.com/test

2000+

Saturday, October 19, 13

Page 20: Interactive web with Fabric.js @ meet.js

GoalsSimple, IntuitiveModularEncapsulatedTests, tests, testsCross-browser

Firefox 2+Safari 3+Opera 9.64+Chrome (all)IE9, IE10, IE11

Native

Excanvas

IE6,7,8

Saturday, October 19, 13

Page 21: Interactive web with Fabric.js @ meet.js

GoalsSimple, IntuitiveModularEncapsulatedTests, tests, testsCross-browser

Fabric.js

Server-side rendering

Node.js

node-canvas

cairo

Saturday, October 19, 13

Page 22: Interactive web with Fabric.js @ meet.js

Key featuresBuilt-in Interaction

SVG parsing

Free Drawing

Image Filters

Animation

Events

Saturday, October 19, 13

Page 23: Interactive web with Fabric.js @ meet.js

On a RoadmapInteractive Text

WebGL renderer

Multiple layers for performance

Curved text

Canvaszooming

Saturday, October 19, 13

Page 24: Interactive web with Fabric.js @ meet.js

Other libraries

Saturday, October 19, 13

Page 25: Interactive web with Fabric.js @ meet.js

Other libraries

Closest functionality

Recent additions

Mostly unpopularor inactive

SVG parsingbut no object model

Not JS

Sophisticatedcurves handling

Saturday, October 19, 13

Page 28: Interactive web with Fabric.js @ meet.js

Open Source Power

400+ fabric questions on StackOverflow

1200+ threads on GoogleGroup

900+ tickets on Github (800+ closed)

50+ contributors on Github

1500+ commits (only 999 commits by me)

2300+ stars on Github

Saturday, October 19, 13

Page 29: Interactive web with Fabric.js @ meet.js

Help welcome

New demos

Translating tutorials

fabricjs.com design

Fixing bugs Finding SVG failures

Improvings docs

Spreading the love

Saturday, October 19, 13

Page 30: Interactive web with Fabric.js @ meet.js

Keep in touch

fabricjs.com

github.com/kangax/fabric.js

twitter.com/fabricjs

Saturday, October 19, 13

Page 31: Interactive web with Fabric.js @ meet.js

Thanks!

@kangax

Questions?

Saturday, October 19, 13