Interactive web with Fabric.js @ meet.js

Juriy Zaytsev
Juriy ZaytsevFront-end developer at Bitsonnet
Interactive

Web With

Fabric.js
by @kangax

Saturday, October 19, 13
Saturday, October 19, 13
Duck
swim()
quack()
WildDuck
swim()
quack()
fly()

ScroogeMcDuck

swim()
quack()
moneyDive()
RubberDuck
swim()
quack()
toy: true

Saturday, October 19, 13
printio.ru

Saturday, October 19, 13
HTML5 Canvas
interface CanvasPathMethods {
...
void closePath(...);
void moveTo(...);
void lineTo(...);
void quadraticCurveTo(...);
void bezierCurveTo(...);
void arcTo(...);
void rect(...);
void arc(...);
void ellipse(...);
...
};
Saturday, October 19, 13
Fabric.js
HTML5 Canvas Library
Interactive object model
on top of <canvas> element

Saturday, October 19, 13
Fabric vs canvas
var 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
Fabric vs canvas
var 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
Fabric vs canvas
ctx.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
Fabric vs canvas
ctx.beginPath();
ctx.moveTo(20, 10);
ctx.lineTo(80, 10);
ctx.quadraticCurveTo(90,
ctx.lineTo(90, 80);
ctx.quadraticCurveTo(90,
ctx.lineTo(20, 90);
ctx.quadraticCurveTo(10,
ctx.lineTo(10, 20);
ctx.quadraticCurveTo(10,
ctx.fill();

10, 90, 20);
90, 80, 90);
90, 10, 80);
10, 20, 10);

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

OOP

fabric.Text

fabric.PathGroup

Saturday, October 19, 13
fabric.Image
render()

OOP

fabric.Text
render()

fabric.PathGroup
render()

Saturday, October 19, 13
fabric.Image
render()
toSVG()
toJSON()

OOP

fabric.Text
render()
toSVG()
toJSON()

fabric.PathGroup
render()
toSVG()
toJSON()

Saturday, October 19, 13
OOP

fabric.Canvas

fabric.Object
has
fabric.Line
fabric.Circle
fabric.Triangle
fabric.Ellipse
fabric.Rect
fabric.Polyline
fabric.Polygon
fabric.Group
fabric.Text
fabric.Image
fabric.Path

is

has

mixin
is
Saturday, October 19, 13

fabric.PathGroup

fabric.Color
fabric.Gradient
fabric.Pattern
fabric.Shadow

fabric.Observable
fabric.Collection
Features Demo

Saturday, October 19, 13
Goals
Simple, 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
Goals
Simple, Intuitive
Modular
~50 small classes/modules
Custom build: 77-204KB
Flexible architecture: image filters, brushes

Saturday, October 19, 13
Goals
Simple, Intuitive
Modular
Encapsulated
Plays well with other libraries
Everything is under 1 object — fabric
No non-standard host object additions
Saturday, October 19, 13
Goals
Simple, Intuitive
Modular
Encapsulated
Tests, tests, tests

Saturday, October 19, 13

fabricjs.com/test
2000+
Goals
Simple, Intuitive
Modular
Encapsulated
Tests, tests, tests
Cross-browser
Saturday, October 19, 13

Native
Firefox 2+
Safari 3+
Opera 9.64+
Chrome (all)
IE9, IE10, IE11
Excanvas
IE6,7,8
Goals
Simple, Intuitive
Fabric.js
Node.js
Modular
node-canvas
Encapsulated
cairo
Tests, tests, tests
Cross-browser
Server-side rendering
Saturday, October 19, 13
Key features
Built-in Interaction
SVG parsing
Free Drawing
Image Filters
Animation
Events

Saturday, October 19, 13
On a Roadmap
Curved text

Multiple layers
for performance
Saturday, October 19, 13

Interactive Text

Canvas
zooming
WebGL renderer
Other libraries

Saturday, October 19, 13
Other libraries
SVG parsing
but no object model
Closest
functionality
Sophisticated
curves handling
Not JS
Recent additions

Mostly unpopular
or inactive

Saturday, October 19, 13
Built with Fabric
Infographics designer

Saturday, October 19, 13

Soccer formation board
Built with Fabric
Tutoring Whiteboard

Saturday, October 19, 13

Arcade Volleyball
Open Source Power
50+ contributors on Github
900+ tickets on Github (800+ closed)
1500+ commits (only 999 commits by me)
2300+ stars on Github
1200+ threads on GoogleGroup
400+ fabric questions on StackOverflow
Saturday, October 19, 13
Help welcome
Translating tutorials
New demos
Fixing bugs

fabricjs.com design
Finding SVG failures

Improvings docs
Spreading the love
Saturday, October 19, 13
Keep in touch
fabricjs.com

github.com/kangax/fabric.js
twitter.com/fabricjs
Saturday, October 19, 13
Thanks!
Questions?

@kangax

Saturday, October 19, 13
1 of 31

Recommended

Fabric.js @ Falsy Values by
Fabric.js @ Falsy ValuesFabric.js @ Falsy Values
Fabric.js @ Falsy ValuesJuriy Zaytsev
13.3K views42 slides
Fabric.js — Building a Canvas Library by
Fabric.js — Building a Canvas LibraryFabric.js — Building a Canvas Library
Fabric.js — Building a Canvas LibraryJuriy Zaytsev
20K views42 slides
Fabricjs ppt by
Fabricjs pptFabricjs ppt
Fabricjs pptCubet Techno Labs
657 views21 slides
JQuery selectors by
JQuery selectors JQuery selectors
JQuery selectors chandrashekher786
1.1K views14 slides
An Overview of HTML, CSS & Java Script by
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptFahim Abdullah
11.4K views56 slides
Computer shortcuts by
Computer shortcutsComputer shortcuts
Computer shortcutsChangazi
3.1K views2 slides

More Related Content

What's hot

JSON Schema Design by
JSON Schema DesignJSON Schema Design
JSON Schema DesignOctavian Nadolu
164 views31 slides
Ajax presentation by
Ajax presentationAjax presentation
Ajax presentationengcs2008
749 views23 slides
CSS Flexbox (flexible box layout) by
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)Woodridge Software
1.4K views17 slides
jpa-hibernate-presentation by
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentationJohn Slick
1.2K views25 slides
jQuery by
jQueryjQuery
jQueryMohammed Arif
2.2K views13 slides
Introduction to oop using java by
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java omeed
219 views12 slides

What's hot(20)

Ajax presentation by engcs2008
Ajax presentationAjax presentation
Ajax presentation
engcs2008749 views
jpa-hibernate-presentation by John Slick
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
John Slick1.2K views
Introduction to oop using java by omeed
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
omeed219 views
Introduction to CSS Grid Layout by Rachel Andrew
Introduction to CSS Grid LayoutIntroduction to CSS Grid Layout
Introduction to CSS Grid Layout
Rachel Andrew3.6K views
Understanding flex box CSS Day 2016 by Davide Di Pumpo
Understanding flex box CSS Day 2016Understanding flex box CSS Day 2016
Understanding flex box CSS Day 2016
Davide Di Pumpo2K views
HTML5 - Forms by tina1357
HTML5 - FormsHTML5 - Forms
HTML5 - Forms
tina13571.5K views
microsoft word shortcut keys by VIRATSAINI
microsoft word shortcut keysmicrosoft word shortcut keys
microsoft word shortcut keys
VIRATSAINI421 views
Matplotlib 기초 이해하기_20160730 by Yong Joon Moon
Matplotlib 기초 이해하기_20160730Matplotlib 기초 이해하기_20160730
Matplotlib 기초 이해하기_20160730
Yong Joon Moon12K views
Internet programming lab manual by inteldualcore
Internet programming lab manualInternet programming lab manual
Internet programming lab manual
inteldualcore8.2K views
Bootstrap grid system by Amr Salman
Bootstrap grid systemBootstrap grid system
Bootstrap grid system
Amr Salman864 views
JavaScript - Chapter 12 - Document Object Model by WebStackAcademy
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy5.3K views
Learning jQuery in 30 minutes by Simon Willison
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison53.4K views
Interesting Facts About Javascript by Manish Jangir
Interesting Facts About JavascriptInteresting Facts About Javascript
Interesting Facts About Javascript
Manish Jangir819 views
css-presentation.ppt by MonishaAb1
css-presentation.pptcss-presentation.ppt
css-presentation.ppt
MonishaAb127 views

Similar to Interactive web with Fabric.js @ meet.js

Is WebAssembly the killer of JavaScript? by
Is WebAssembly the killer of JavaScript?Is WebAssembly the killer of JavaScript?
Is WebAssembly the killer of JavaScript?Boyan Mihaylov
2.3K views39 slides
Boyan Mihaylov - Is web assembly the killer of javascript by
Boyan Mihaylov - Is web assembly the killer of javascriptBoyan Mihaylov - Is web assembly the killer of javascript
Boyan Mihaylov - Is web assembly the killer of javascriptCodemotion
1.2K views39 slides
Reactive applications using Akka by
Reactive applications using AkkaReactive applications using Akka
Reactive applications using AkkaMiguel Pastor
7.6K views98 slides
Animations & swift by
Animations & swiftAnimations & swift
Animations & swiftArun Nagarajan
2.1K views19 slides
Minecraft in 500 lines with Pyglet - PyCon UK by
Minecraft in 500 lines with Pyglet - PyCon UKMinecraft in 500 lines with Pyglet - PyCon UK
Minecraft in 500 lines with Pyglet - PyCon UKRichard Donkin
22.2K views19 slides
An Introduction to Game Programming with Flash: An Introduction to Flash and ... by
An Introduction to Game Programming with Flash: An Introduction to Flash and ...An Introduction to Game Programming with Flash: An Introduction to Flash and ...
An Introduction to Game Programming with Flash: An Introduction to Flash and ...Krzysztof Opałka
698 views33 slides

Similar to Interactive web with Fabric.js @ meet.js(20)

Is WebAssembly the killer of JavaScript? by Boyan Mihaylov
Is WebAssembly the killer of JavaScript?Is WebAssembly the killer of JavaScript?
Is WebAssembly the killer of JavaScript?
Boyan Mihaylov2.3K views
Boyan Mihaylov - Is web assembly the killer of javascript by Codemotion
Boyan Mihaylov - Is web assembly the killer of javascriptBoyan Mihaylov - Is web assembly the killer of javascript
Boyan Mihaylov - Is web assembly the killer of javascript
Codemotion1.2K views
Reactive applications using Akka by Miguel Pastor
Reactive applications using AkkaReactive applications using Akka
Reactive applications using Akka
Miguel Pastor7.6K views
Minecraft in 500 lines with Pyglet - PyCon UK by Richard Donkin
Minecraft in 500 lines with Pyglet - PyCon UKMinecraft in 500 lines with Pyglet - PyCon UK
Minecraft in 500 lines with Pyglet - PyCon UK
Richard Donkin22.2K views
An Introduction to Game Programming with Flash: An Introduction to Flash and ... by Krzysztof Opałka
An Introduction to Game Programming with Flash: An Introduction to Flash and ...An Introduction to Game Programming with Flash: An Introduction to Flash and ...
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
Krzysztof Opałka698 views
Presentation plone conference 2012 by Cornelis Kolbach
Presentation plone conference 2012Presentation plone conference 2012
Presentation plone conference 2012
Cornelis Kolbach2.6K views
Secrets of Awesome JavaScript API Design by Brandon Satrom
Secrets of Awesome JavaScript API DesignSecrets of Awesome JavaScript API Design
Secrets of Awesome JavaScript API Design
Brandon Satrom2K views
University of arizona mobile matters - technology, a means to an end by Thibault Imbert
University of arizona   mobile matters - technology, a means to an endUniversity of arizona   mobile matters - technology, a means to an end
University of arizona mobile matters - technology, a means to an end
Thibault Imbert29.4K views
GR8Conf 2009: Groovy Usage Patterns by Dierk König by GR8Conf
GR8Conf 2009: Groovy Usage Patterns by Dierk KönigGR8Conf 2009: Groovy Usage Patterns by Dierk König
GR8Conf 2009: Groovy Usage Patterns by Dierk König
GR8Conf2.4K views
Introduction to jQuery by Alek Davis
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Alek Davis802 views
HTML5 - Daha Flash bir web? by Ankara JUG
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Ankara JUG755 views
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018 by Codemotion
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
Codemotion191 views
Shiny r, live shared and explored by Alex Brown
Shiny   r, live shared and exploredShiny   r, live shared and explored
Shiny r, live shared and explored
Alex Brown6.7K views
Web 2 . .3 Development Services by Theawaster485
Web 2 . .3 Development ServicesWeb 2 . .3 Development Services
Web 2 . .3 Development Services
Theawaster48547 views
JavaScript Libraries: The Big Picture by Simon Willison
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
Simon Willison4K views

Recently uploaded

Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...ShapeBlue
114 views12 slides
The Power of Heat Decarbonisation Plans in the Built Environment by
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
67 views20 slides
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...ShapeBlue
86 views25 slides
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
373 views86 slides
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesShapeBlue
178 views15 slides
Future of AR - Facebook Presentation by
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook PresentationRob McCarty
54 views27 slides

Recently uploaded(20)

Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue114 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE67 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue86 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software373 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue178 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty54 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue191 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue105 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson142 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue147 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue63 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue74 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue172 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue128 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash103 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue81 views

Interactive web with Fabric.js @ meet.js