SlideShare una empresa de Scribd logo
1 de 63
Descargar para leer sin conexión
Canvas
                                L5 FT W!
                            H TM
Web Directions
               South 2009
   Dmitry Barano
                  vskiy
“The canvas element represents
 a!resolution-dependent bitmap
  canvas, which can be used for
 rendering graphs, game graphics,
or other visual images on the fly”
                     HTML 5 Specification
Teenager of web
  technologies
Awesome
  What is
 Awesome?   !
Draw!
You can draw!
api
API is small & simple
HTML5
 HTML 5
HTML5
 HTML5
Howto?
 How to…
JavaScript
Context
  Context
var canvas = document.getElementById("canvas"),
    context = canvas.getContext("2d");
context.save();
context.restore();
context.scale(x, y);
context.rotate(angle);
context.translate(x, y);
context.transform(m11, m12, m21, m22, dx, dy);
context.setTransform(m11, m12, m21, m22, dx, dy);
var a = context.globalAlpha;
context.globalAlpha = a * 0.5;

var b = context.globalCompositeOperation;
context.globalCompositeOperation = "xor";
context.strokeStyle = "#fc0";
context.fillStyle = "#000";

var gradient = context.createLinearGradient(x1, y1, x2,
y2);
// or
var gradient = context.createRadialGradient(x1, y1, r1,
x2, y2, r2);
gradient.addColorStop(0 / 6, "red");
gradient.addColorStop(1 / 6, "orange");
gradient.addColorStop(2 / 6, "yellow");
gradient.addColorStop(3 / 6, "green");
gradient.addColorStop(4 / 6, "blue");
gradient.addColorStop(5 / 6, "navy");
gradient.addColorStop(6 / 6, "purple");
context.fillStyle = gradient;
context.lineWidth = 2;
context.lineCap = "round";
context.lineJoin = "bevel";
context.miterLimit = 5;

context.shadowColor = "#000";
context.shadowOffsetX = 0;
context.shadowOffsetY = 3;
context.shadowBlur = 7;
primiti
  Primitives
               ve
context.clearRect(x, y, width, height);
context.fillRect(x, y, width, height);
context.strokeRect(x, y, width, height);
paths
 Paths
context.beginPath();
context.closePath();

context.moveTo(x, y);
context.lineTo(x, y);
context.quadraticCurveTo(cpx, cpy, x, y);
context.bezierCurveTo(c1x, c1y, c2x, c2y, x, y);
context.arcTo(x1, y1, x2, y2, radius);
context.arc(x, y, radius, startAngle, endAngle,
anticlockwise);
context.rect(x, y, width, height);

context.fill();
context.stroke();
context.clip();
context.isPointInPath(x, y);
text
 Text
context.font = 'italic 400 12px/2 Palatino, »
Georgia, serif';
context.textAlign = "center";
context.textBaseline = "middle";

context.fillText("Web Directions", 100, 120);
context.strokeText("Canvas FTW", 100, 150, 140);

var metrics = context.measureText("How wide is »
this text?"),
    width = metrics.width;
images
  Images
var image = new Image;
image.onload = function () {
    context.drawImage(image, x, y);
    // or
    context.drawImage(image, x, y, w, h);
    // or
    context.drawImage(image, sx, sy, sw, sh,
                       x, y, w, h);
};
image.src = "graffiti.jpg";
sy                y
var image = new Image;
image.onload = sx
                function () {
                           sh      x        h
    context.drawImage(image, x, y);
    // or
                     sw               w
    context.drawImage(image, x, y, w, h);
    // or
    context.drawImage(image, sx, sy, sw, sh,
                        x, y, w, h);
};
image.src = "graffiti.jpg";
pixels
Pixel Pushing
var data = context.createImageData(w, h);
// or
var data = context.createImageData(old_data);
var data = context.getImageData(x, y, w, h);
context.putImageData(data, dx, dy);
// or
context.putImageData(data, dx, dy, x, y, w, h);
var data = {
    width: 100,
    height: 100,
    data: [0, 0, 0, 0, 255, 128, 0, 255, … , 0]
};
var data = {
    width: 100,
    height: 100,
    data: [0, 0, 0, 0, 255, 128, 0, 255, … , 0]
};
var data = {
    width: 100,
    height: 100,
    data: [0, 0, 0, 0, 255, 128, 0, 255, … , 0]
};
                        R G B A
not!
What is not
Awesome?
ugly
API is ugly
1by1
Setting attributes one by one
context.lineWidth = 2;
context.lineCap = "round";
context.lineJoin = "bevel";
context.miterLimit = 5;

context.shadowColor = "#000";
context.shadowOffsetX = 0;
context.shadowOffsetY = 3;
context.shadowBlur = 7;
context.setAttr({
    lineWidth: 2,
    lineCap: "round",
    lineJoin: "bevel",
    miterLimit: 5,
    shadowColor: "#000",
    shadowOffsetX: 0,
    shadowOffsetY: 3,
    shadowBlur: 7
});
pain!
Coding paths is painful
context.beginPath();
context.moveTo(x, y);
context.lineTo(x, y);
context.quadraticCurveTo(cpx, cpy, x, y);
context.bezierCurveTo(c1x, c1y, c2x, c2y, x, y);
context.arcTo(x1, y1, x2, y2, radius);
context.arc(x, y, radius, startAngle, endAngle,
anticlockwise);
context.rect(x, y, width, height);
context.closePath();
context.fill();
context.beginPath()
    .moveTo(x, y)
    .lineTo(x, y)
    .quadraticCurveTo(cpx, cpy, x, y)
    .bezierCurveTo(c1x, c1y, c2x, c2y, x, y)
    .arcTo(x1, y1, x2, y2, radius)
    .arc(x, y, radius, startAngle, endAngle,
anticlockwise)
    .rect(x, y, width, height)
    .closePath()
    .fill();
var path = ["move", x, y,
            "line", x, y,
            "quadratic", cpx, cpy, x, y,
            "arc", x, y, radius, startAngle,
endAngle, anticlockwise];
context.path(path).close().fill();

context.path(["move", 10, 10, "line", 50,
50]).close().fill();
no way
No way to store path
more!
Not enough primitives
support
  Bad support
89%
81%
76%
74%
Zero
HTML 5
Thank You


dmitry@baranovskiy.com
Thank You
Photos used in this presentation:
http://www.flickr.com/photos/garryknight/2390411392/
http://www.flickr.com/photos/livenature/233281535/
http://www.flickr.com/photos/yoadolescente/3212368604/
http://www.flickr.com/photos/andreassolberg/433734311/
http://www.flickr.com/photos/cassidy/67331975/
http://www.flickr.com/photos/b-tal/93425807/
http://www.flickr.com/photos/pefectfutures/163853250/
http://www.flickr.com/photos/streetart-berlin/3746020273/
http://www.flickr.com/photos/streetart-berlin/3954856553/
http://www.flickr.com/photos/streetart-berlin/3947360186/
http://www.flickr.com/photos/streetart-berlin/3949549099/
http://www.flickr.com/photos/streetart-berlin/3949546871/
http://www.flickr.com/photos/streetart-berlin/3926942710/
http://www.flickr.com/photos/streetart-berlin/3834021290/


                dmitry@baranovskiy.com

Más contenido relacionado

La actualidad más candente (20)

Mosaic plot in R.
Mosaic plot in R.Mosaic plot in R.
Mosaic plot in R.
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 
My favorite slides
My favorite slidesMy favorite slides
My favorite slides
 
Proga 0706
Proga 0706Proga 0706
Proga 0706
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 Canvas
 
CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction
 
Funcion matematica
Funcion matematicaFuncion matematica
Funcion matematica
 
Proga 0518
Proga 0518Proga 0518
Proga 0518
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Proga 0629
Proga 0629Proga 0629
Proga 0629
 
Supstat nyc subway
Supstat nyc subwaySupstat nyc subway
Supstat nyc subway
 
UIWebViewでつくるUI
UIWebViewでつくるUIUIWebViewでつくるUI
UIWebViewでつくるUI
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
 
Kwp2 100121
Kwp2 100121Kwp2 100121
Kwp2 100121
 
OOXX
OOXXOOXX
OOXX
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
 
Css5 canvas
Css5 canvasCss5 canvas
Css5 canvas
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 

Destacado

Selenium: What Is It Good For
Selenium: What Is It Good ForSelenium: What Is It Good For
Selenium: What Is It Good ForAllan Chappell
 
Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...
Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...
Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...Sightlines
 
Enhancing the Value of Streets for Pedestrians, Bicyclists, and Motorists
Enhancing the Value of Streets for Pedestrians, Bicyclists, and MotoristsEnhancing the Value of Streets for Pedestrians, Bicyclists, and Motorists
Enhancing the Value of Streets for Pedestrians, Bicyclists, and MotoristsAndy Boenau
 
Pg connects bangalore re engagment advertising a dummies guide
Pg connects bangalore re engagment advertising a dummies guidePg connects bangalore re engagment advertising a dummies guide
Pg connects bangalore re engagment advertising a dummies guideFiksu
 
Backlog, Deferred Maintenance and its use in Planning
Backlog, Deferred Maintenance and its use in PlanningBacklog, Deferred Maintenance and its use in Planning
Backlog, Deferred Maintenance and its use in PlanningSightlines
 
Kakamega County Audit Report 2014/2015
Kakamega County Audit Report 2014/2015Kakamega County Audit Report 2014/2015
Kakamega County Audit Report 2014/2015The Star Newspaper
 
Make your pitch perfect, using competitive and emotional intelligence - SEOZONE
Make your pitch perfect, using competitive and emotional intelligence - SEOZONEMake your pitch perfect, using competitive and emotional intelligence - SEOZONE
Make your pitch perfect, using competitive and emotional intelligence - SEOZONEAlexandraTachalova
 
JAWS FESTA TOKAIDO 2016
JAWS FESTA TOKAIDO 2016JAWS FESTA TOKAIDO 2016
JAWS FESTA TOKAIDO 2016陽平 山口
 
Lire Rythme, une nouvelle de Chaplin
Lire Rythme, une nouvelle de ChaplinLire Rythme, une nouvelle de Chaplin
Lire Rythme, une nouvelle de ChaplinLaila Methnani
 
Spartan challenge 10 11
Spartan challenge 10 11Spartan challenge 10 11
Spartan challenge 10 11Robjenna
 
Create content according to buyer's journey
Create content according to buyer's journeyCreate content according to buyer's journey
Create content according to buyer's journeyPengyuan Zhao
 
交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業
交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業 交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業
交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業 交點
 
14 Machine Learning Single Layer Perceptron
14 Machine Learning Single Layer Perceptron14 Machine Learning Single Layer Perceptron
14 Machine Learning Single Layer PerceptronAndres Mendez-Vazquez
 
Connected health
Connected healthConnected health
Connected healthDeloitte UK
 
TOP Growth Hacking acquisition Tools for 2017 - BY Akshay Gaur
TOP Growth Hacking acquisition Tools for 2017 - BY Akshay GaurTOP Growth Hacking acquisition Tools for 2017 - BY Akshay Gaur
TOP Growth Hacking acquisition Tools for 2017 - BY Akshay GaurAkshay Gaur
 

Destacado (17)

Selenium: What Is It Good For
Selenium: What Is It Good ForSelenium: What Is It Good For
Selenium: What Is It Good For
 
Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...
Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...
Take Control of Your Facilities: Explore the Tools for Aligning Space, Capita...
 
Enhancing the Value of Streets for Pedestrians, Bicyclists, and Motorists
Enhancing the Value of Streets for Pedestrians, Bicyclists, and MotoristsEnhancing the Value of Streets for Pedestrians, Bicyclists, and Motorists
Enhancing the Value of Streets for Pedestrians, Bicyclists, and Motorists
 
Pg connects bangalore re engagment advertising a dummies guide
Pg connects bangalore re engagment advertising a dummies guidePg connects bangalore re engagment advertising a dummies guide
Pg connects bangalore re engagment advertising a dummies guide
 
More than a score - Using Ratings and Reviews in Real Estate
More than a score - Using Ratings and Reviews in Real EstateMore than a score - Using Ratings and Reviews in Real Estate
More than a score - Using Ratings and Reviews in Real Estate
 
Backlog, Deferred Maintenance and its use in Planning
Backlog, Deferred Maintenance and its use in PlanningBacklog, Deferred Maintenance and its use in Planning
Backlog, Deferred Maintenance and its use in Planning
 
Kakamega County Audit Report 2014/2015
Kakamega County Audit Report 2014/2015Kakamega County Audit Report 2014/2015
Kakamega County Audit Report 2014/2015
 
Make your pitch perfect, using competitive and emotional intelligence - SEOZONE
Make your pitch perfect, using competitive and emotional intelligence - SEOZONEMake your pitch perfect, using competitive and emotional intelligence - SEOZONE
Make your pitch perfect, using competitive and emotional intelligence - SEOZONE
 
JAWS FESTA TOKAIDO 2016
JAWS FESTA TOKAIDO 2016JAWS FESTA TOKAIDO 2016
JAWS FESTA TOKAIDO 2016
 
Lire Rythme, une nouvelle de Chaplin
Lire Rythme, une nouvelle de ChaplinLire Rythme, une nouvelle de Chaplin
Lire Rythme, une nouvelle de Chaplin
 
Spartan challenge 10 11
Spartan challenge 10 11Spartan challenge 10 11
Spartan challenge 10 11
 
Create content according to buyer's journey
Create content according to buyer's journeyCreate content according to buyer's journey
Create content according to buyer's journey
 
交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業
交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業 交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業
交點台中2016.3月 - 簡正強 - 青銀世代,翻轉農業
 
14 Machine Learning Single Layer Perceptron
14 Machine Learning Single Layer Perceptron14 Machine Learning Single Layer Perceptron
14 Machine Learning Single Layer Perceptron
 
My favourite game
My favourite gameMy favourite game
My favourite game
 
Connected health
Connected healthConnected health
Connected health
 
TOP Growth Hacking acquisition Tools for 2017 - BY Akshay Gaur
TOP Growth Hacking acquisition Tools for 2017 - BY Akshay GaurTOP Growth Hacking acquisition Tools for 2017 - BY Akshay Gaur
TOP Growth Hacking acquisition Tools for 2017 - BY Akshay Gaur
 

Similar a Canvas

How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphaelPippi Labradoodle
 
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationSVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationAnthony Starks
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Exploring fractals in CSS, @fronttrends, Warsaw, 2015Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Exploring fractals in CSS, @fronttrends, Warsaw, 2015pixelass
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasSteve Purkis
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tddMarcos Iglesias
 
HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebRobin Hawkes
 
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, ViewsStandford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, Views彼得潘 Pan
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfarihantmobileselepun
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)zahid-mian
 
Canvas
CanvasCanvas
CanvasRajon
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 

Similar a Canvas (20)

SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
CoW Documentatie
CoW DocumentatieCoW Documentatie
CoW Documentatie
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
Canvas - The Cure
Canvas - The CureCanvas - The Cure
Canvas - The Cure
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphael
 
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationSVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generation
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Exploring fractals in CSS, @fronttrends, Warsaw, 2015Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
 
Raphaël
RaphaëlRaphaël
Raphaël
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tdd
 
HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the Web
 
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, ViewsStandford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, Views
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
 
Canvas
CanvasCanvas
Canvas
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 

Más de Dmitry Baranovskiy (14)

JavaScript: enter the dragon
JavaScript: enter the dragonJavaScript: enter the dragon
JavaScript: enter the dragon
 
The Origins of Magic
The Origins of MagicThe Origins of Magic
The Origins of Magic
 
Demystifying Prototypes
Demystifying PrototypesDemystifying Prototypes
Demystifying Prototypes
 
Type Recognition
Type RecognitionType Recognition
Type Recognition
 
Raphaël JS Conf
Raphaël JS ConfRaphaël JS Conf
Raphaël JS Conf
 
Obvious Secrets of JavaScript
Obvious Secrets of JavaScriptObvious Secrets of JavaScript
Obvious Secrets of JavaScript
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
 
SVG
SVGSVG
SVG
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
Raphael
RaphaelRaphael
Raphael
 
Web Vector Graphics
Web Vector GraphicsWeb Vector Graphics
Web Vector Graphics
 
Typography on the Web
Typography on the WebTypography on the Web
Typography on the Web
 
Microformats—the hidden treasure
Microformats—the hidden treasureMicroformats—the hidden treasure
Microformats—the hidden treasure
 
Advanced JavaScript Techniques
Advanced JavaScript TechniquesAdvanced JavaScript Techniques
Advanced JavaScript Techniques
 

Último

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 

Último (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 

Canvas

  • 1. Canvas L5 FT W! H TM Web Directions South 2009 Dmitry Barano vskiy
  • 2. “The canvas element represents a!resolution-dependent bitmap canvas, which can be used for rendering graphs, game graphics, or other visual images on the fly” HTML 5 Specification
  • 3.
  • 4. Teenager of web technologies
  • 5.
  • 6.
  • 7. Awesome What is Awesome? !
  • 8.
  • 10. api API is small & simple
  • 13.
  • 14.
  • 15.
  • 17.
  • 20. var canvas = document.getElementById("canvas"), context = canvas.getContext("2d");
  • 22. var a = context.globalAlpha; context.globalAlpha = a * 0.5; var b = context.globalCompositeOperation; context.globalCompositeOperation = "xor";
  • 23. context.strokeStyle = "#fc0"; context.fillStyle = "#000"; var gradient = context.createLinearGradient(x1, y1, x2, y2); // or var gradient = context.createRadialGradient(x1, y1, r1, x2, y2, r2); gradient.addColorStop(0 / 6, "red"); gradient.addColorStop(1 / 6, "orange"); gradient.addColorStop(2 / 6, "yellow"); gradient.addColorStop(3 / 6, "green"); gradient.addColorStop(4 / 6, "blue"); gradient.addColorStop(5 / 6, "navy"); gradient.addColorStop(6 / 6, "purple"); context.fillStyle = gradient;
  • 24. context.lineWidth = 2; context.lineCap = "round"; context.lineJoin = "bevel"; context.miterLimit = 5; context.shadowColor = "#000"; context.shadowOffsetX = 0; context.shadowOffsetY = 3; context.shadowBlur = 7;
  • 26. context.clearRect(x, y, width, height); context.fillRect(x, y, width, height); context.strokeRect(x, y, width, height);
  • 28. context.beginPath(); context.closePath(); context.moveTo(x, y); context.lineTo(x, y); context.quadraticCurveTo(cpx, cpy, x, y); context.bezierCurveTo(c1x, c1y, c2x, c2y, x, y); context.arcTo(x1, y1, x2, y2, radius); context.arc(x, y, radius, startAngle, endAngle, anticlockwise); context.rect(x, y, width, height); context.fill(); context.stroke(); context.clip(); context.isPointInPath(x, y);
  • 30. context.font = 'italic 400 12px/2 Palatino, » Georgia, serif'; context.textAlign = "center"; context.textBaseline = "middle"; context.fillText("Web Directions", 100, 120); context.strokeText("Canvas FTW", 100, 150, 140); var metrics = context.measureText("How wide is » this text?"), width = metrics.width;
  • 32. var image = new Image; image.onload = function () { context.drawImage(image, x, y); // or context.drawImage(image, x, y, w, h); // or context.drawImage(image, sx, sy, sw, sh, x, y, w, h); }; image.src = "graffiti.jpg";
  • 33. sy y var image = new Image; image.onload = sx function () { sh x h context.drawImage(image, x, y); // or sw w context.drawImage(image, x, y, w, h); // or context.drawImage(image, sx, sy, sw, sh, x, y, w, h); }; image.src = "graffiti.jpg";
  • 35. var data = context.createImageData(w, h); // or var data = context.createImageData(old_data); var data = context.getImageData(x, y, w, h); context.putImageData(data, dx, dy); // or context.putImageData(data, dx, dy, x, y, w, h);
  • 36. var data = { width: 100, height: 100, data: [0, 0, 0, 0, 255, 128, 0, 255, … , 0] };
  • 37. var data = { width: 100, height: 100, data: [0, 0, 0, 0, 255, 128, 0, 255, … , 0] };
  • 38. var data = { width: 100, height: 100, data: [0, 0, 0, 0, 255, 128, 0, 255, … , 0] }; R G B A
  • 40.
  • 43. context.lineWidth = 2; context.lineCap = "round"; context.lineJoin = "bevel"; context.miterLimit = 5; context.shadowColor = "#000"; context.shadowOffsetX = 0; context.shadowOffsetY = 3; context.shadowBlur = 7;
  • 44. context.setAttr({ lineWidth: 2, lineCap: "round", lineJoin: "bevel", miterLimit: 5, shadowColor: "#000", shadowOffsetX: 0, shadowOffsetY: 3, shadowBlur: 7 });
  • 46. context.beginPath(); context.moveTo(x, y); context.lineTo(x, y); context.quadraticCurveTo(cpx, cpy, x, y); context.bezierCurveTo(c1x, c1y, c2x, c2y, x, y); context.arcTo(x1, y1, x2, y2, radius); context.arc(x, y, radius, startAngle, endAngle, anticlockwise); context.rect(x, y, width, height); context.closePath(); context.fill();
  • 47. context.beginPath() .moveTo(x, y) .lineTo(x, y) .quadraticCurveTo(cpx, cpy, x, y) .bezierCurveTo(c1x, c1y, c2x, c2y, x, y) .arcTo(x1, y1, x2, y2, radius) .arc(x, y, radius, startAngle, endAngle, anticlockwise) .rect(x, y, width, height) .closePath() .fill();
  • 48. var path = ["move", x, y, "line", x, y, "quadratic", cpx, cpy, x, y, "arc", x, y, radius, startAngle, endAngle, anticlockwise]; context.path(path).close().fill(); context.path(["move", 10, 10, "line", 50, 50]).close().fill();
  • 49. no way No way to store path
  • 51.
  • 52.
  • 53. support Bad support
  • 54.
  • 55. 89%
  • 56. 81%
  • 57. 76%
  • 58. 74%
  • 59. Zero
  • 61.
  • 63. Thank You Photos used in this presentation: http://www.flickr.com/photos/garryknight/2390411392/ http://www.flickr.com/photos/livenature/233281535/ http://www.flickr.com/photos/yoadolescente/3212368604/ http://www.flickr.com/photos/andreassolberg/433734311/ http://www.flickr.com/photos/cassidy/67331975/ http://www.flickr.com/photos/b-tal/93425807/ http://www.flickr.com/photos/pefectfutures/163853250/ http://www.flickr.com/photos/streetart-berlin/3746020273/ http://www.flickr.com/photos/streetart-berlin/3954856553/ http://www.flickr.com/photos/streetart-berlin/3947360186/ http://www.flickr.com/photos/streetart-berlin/3949549099/ http://www.flickr.com/photos/streetart-berlin/3949546871/ http://www.flickr.com/photos/streetart-berlin/3926942710/ http://www.flickr.com/photos/streetart-berlin/3834021290/ dmitry@baranovskiy.com