SlideShare a Scribd company logo
1 of 19
CANVAS
An exciting HTML5 element.
WHAT HTML5 CANVAS IS USED FOR
■ dynamic graphics
■ online and offline games
■ animations
■ interactive video and audio
Easy to turn a plain web page into a dynamic web application and then convert that
application into a mobile app for use on smartphones and tablets.
Skeleton
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script type="application/javascript">
function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
//Draw Here }
}else{
//Fall bac kContent Goes Here
}
</script>
</head>
<body>
<canvas id="canvas" width="150" height="150"></canvas> //Create a Canvas
</body>
</html>
Understanding the Canvas Coordinate
System
Curves
var x = canvas.width / 2;
var y = canvas.height / 2;
var radius = 75;
var startAngle = 0 * Math.PI;
var endAngle = 2 * Math.PI;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle);
context.lineWidth = 15;
// line color
context.strokeStyle = 'green';
context.stroke();
Arc
Curves
context.moveTo(188, 130);
context.bezierCurveTo(140, 10, 388, 10, 388, 170);
context.lineWidth = 10;
Quadratic Curve
context.moveTo(188, 150);
context.quadraticCurveTo(288, 0, 388, 150);
Bezier Curve
Paths
context.moveTo(100, 20);
// line 1
context.lineTo(200, 160);
// quadratic curve
context.quadraticCurveTo(230, 200, 250, 120);
// bezier curve
context.bezierCurveTo(290, -40, 300, 200, 400, 150);
// line 2
context.lineTo(500, 90)
context.lineJoin = 'bevel';
Shape
// begin custom shape
context.beginPath();
context.moveTo(170, 80);
context.bezierCurveTo(130, 100, 130, 150, 230, 150);
context.bezierCurveTo(250, 180, 320, 180, 340, 150);
context.bezierCurveTo(420, 150, 420, 120, 390, 100);
context.bezierCurveTo(430, 40, 370, 30, 340, 50);
context.bezierCurveTo(320, 5, 250, 20, 250, 50);
context.bezierCurveTo(200, 5, 150, 20, 170, 80);
Shape
context.beginPath();
context.rect(188, 50, 200, 100);
context.fillStyle = 'yellow';
context.fill();
context.lineWidth = 7;
context.strokeStyle = 'black';
context.stroke();
Fill Style
context.fillStyle = '#8ED6FF';
context.fill();
Color Fill
// add linear gradient
var grd = context.createLinearGradient(0, 0, canvas.width, canvas.height);
// light blue
grd.addColorStop(0, '#8ED6FF');
// dark blue
grd.addColorStop(1, '#004CB3');
context.fillStyle = grd;
context.fill();
Linear Gradient
Radial Gradient
// create radial gradient
var grd = context.createRadialGradient(238, 50, 10, 238,50, 300);
// light blue
grd.addColorStop(0, '#8ED6FF');
// dark blue
grd.addColorStop(1, '#004CB3');
context.fillStyle = grd;
context.fill();
Pattern
var imageObj = new Image();
imageObj.onload = function() {
var pattern = context.createPattern(imageObj, 'repeat');
context.rect(0, 0, canvas.width, canvas.height);
context.fillStyle = pattern;
context.fill();
};
imageObj.src =
'http://www.html5canvastutorials.com/demos/assets/wood-
pattern.png';
Text
context.textAlign = 'left';
ontext.strokeText('Hello World!', x, y);
Align
Stroke
context.fillStyle = 'blue';
Color
context.font = 'italic 40pt Calibri';
Font Size Style
context.measureText(text);
Metricies
wrapText(context, text, x, y, maxWidth, lineHeight);
WrapText
Transformations
// translate context to center of canvas
context.translate(canvas.width / 2, canvas.height / 2);
// scale y component
context.scale(1, 0.5);
// rotate 45 degrees clockwise
context.rotate(Math.PI / 4);
// apply custom transform
context.transform(1, 0, 0, 1, tx, ty);
// apply custom transform
context.setTransform(1, 0, 0, 1, 0, 0);
Transformation State Stack
context.save();
// save state 1
context.translate(canvas.width / 2, canvas.height / 2);
context.save();
// save state 2
context.rotate(Math.PI / 4);
context.save();
// save state 3
context.scale(2, 2);
context.fillStyle = 'blue';
context.fillRect(rectWidth / -2, rectHeight / -2, rectWidth, rectHeight);
context.restore();
// restore state 1
context.fillStyle = 'green';
context.fillRect(rectWidth / -2, rectHeight / -2, rectWidth, rectHeight);
Composites
//Shadows
context.shadowColor = '#999';
context.shadowBlur = 20;
context.shadowOffsetX = 15;
context.shadowOffsetY = 15;
//Global alpha
context.globalAlpha = 0.5;
//Cliping Region
context.clip();
Animation
animate(myRectangle, canvas, context, startTime);
• Acceleration
• Oscillation
• Linear Motion
• Animation Frame
Lets Look at an example………..
Mouse Position
function writeMessage(canvas, message) {
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
context.font = '18pt Calibri';
context.fillStyle = 'black';
context.fillText(message, 10, 25);}
function getMousePos(canvas, evt) {
var rect = canvas.getBoundingClientRect();
return {
x: evt.clientX - rect.left,
y: evt.clientY - rect.top };}
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
canvas.addEventListener('mousemove', function(evt) {
var mousePos = getMousePos(canvas, evt);
var message = 'Mouse position: ' + mousePos.x + ',' + mousePos.y;
writeMessage(canvas, message);
}, false);
Should Check Out
■ http://cheatsheetworld.com/programming/html5-canvas-cheat-sheet/
■ http://www.sinuousgame.com/
■ http://corehtml5canvas.com/code-live/
■ http://curran.github.io/HT
■ http://www.williammalone.com/articles/create-html5-canvas-javascript-game-
character/1/ML5Examples/
■ http://cssdeck.com/labs/ping-pong-game-tutorial-with-html5-canvas-and-sounds

More Related Content

What's hot

Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...
Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...
Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...Skilld
 
JS.Chi CSS Animations
JS.Chi CSS AnimationsJS.Chi CSS Animations
JS.Chi CSS AnimationsJustin Meyer
 
Interactive Vector-Graphics in the Browser
Interactive Vector-Graphics in the BrowserInteractive Vector-Graphics in the Browser
Interactive Vector-Graphics in the Browsertec
 
Mobile Web Development
Mobile Web DevelopmentMobile Web Development
Mobile Web DevelopmentJonathan Snook
 
Barcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kóduBarcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kóduMilos Lenoch
 
6주 javaScript 시작하며
6주  javaScript 시작하며6주  javaScript 시작하며
6주 javaScript 시작하며지수 윤
 
Css sprite_maker-1
Css  sprite_maker-1Css  sprite_maker-1
Css sprite_maker-1lokku
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScriptersgerbille
 
Black-Scholes Calculator on Web
Black-Scholes Calculator on WebBlack-Scholes Calculator on Web
Black-Scholes Calculator on WebEugene Yang
 
Chrome presentation
Chrome presentationChrome presentation
Chrome presentationismnoiet
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mateCodemotion
 
Auto tools
Auto toolsAuto tools
Auto tools祺 周
 

What's hot (13)

Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...
Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...
Build tons of multi-device JavaScript applications - Part 2 : (black) Magic S...
 
JS.Chi CSS Animations
JS.Chi CSS AnimationsJS.Chi CSS Animations
JS.Chi CSS Animations
 
Interactive Vector-Graphics in the Browser
Interactive Vector-Graphics in the BrowserInteractive Vector-Graphics in the Browser
Interactive Vector-Graphics in the Browser
 
Mobile Web Development
Mobile Web DevelopmentMobile Web Development
Mobile Web Development
 
Barcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kóduBarcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kódu
 
6주 javaScript 시작하며
6주  javaScript 시작하며6주  javaScript 시작하며
6주 javaScript 시작하며
 
Css sprite_maker-1
Css  sprite_maker-1Css  sprite_maker-1
Css sprite_maker-1
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 
Black-Scholes Calculator on Web
Black-Scholes Calculator on WebBlack-Scholes Calculator on Web
Black-Scholes Calculator on Web
 
Chrome presentation
Chrome presentationChrome presentation
Chrome presentation
 
Render to Texture with Three.js
Render to Texture with Three.jsRender to Texture with Three.js
Render to Texture with Three.js
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
 
Auto tools
Auto toolsAuto tools
Auto tools
 

Viewers also liked

The DATA RING - A canvas for DATA PROJECT
The DATA RING - A canvas for DATA PROJECTThe DATA RING - A canvas for DATA PROJECT
The DATA RING - A canvas for DATA PROJECTTOP-IX Consortium
 
Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...
Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...
Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...Alessandro Almeida
 
Feedback Canvas - Agile Portugal 2017
Feedback Canvas - Agile Portugal 2017Feedback Canvas - Agile Portugal 2017
Feedback Canvas - Agile Portugal 2017Ricardo Fernandes
 
Construindo Produtos Inovadores
Construindo Produtos InovadoresConstruindo Produtos Inovadores
Construindo Produtos InovadoresHumberto Moura
 
Seminario Business Model Canvas
Seminario Business Model CanvasSeminario Business Model Canvas
Seminario Business Model CanvasFrancesco Zitelli
 
Memoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz Rolim
Memoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz RolimMemoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz Rolim
Memoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz RolimLuiz Moura
 
Inovação em modelos de negócios já estabelecidos o analista de modelos de n...
Inovação em modelos de negócios já estabelecidos   o analista de modelos de n...Inovação em modelos de negócios já estabelecidos   o analista de modelos de n...
Inovação em modelos de negócios já estabelecidos o analista de modelos de n...Daniel Pereira
 
Palestra Experiência do Cliente
Palestra Experiência do ClientePalestra Experiência do Cliente
Palestra Experiência do ClienteMarcus Pimenta
 
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...Louis Dorard
 
Strategic Business Model Canvas v3
Strategic Business Model Canvas v3Strategic Business Model Canvas v3
Strategic Business Model Canvas v3Mihai Ionescu
 
Company Presentation: Canvas
Company Presentation: CanvasCompany Presentation: Canvas
Company Presentation: CanvasKiley Judge
 

Viewers also liked (11)

The DATA RING - A canvas for DATA PROJECT
The DATA RING - A canvas for DATA PROJECTThe DATA RING - A canvas for DATA PROJECT
The DATA RING - A canvas for DATA PROJECT
 
Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...
Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...
Templates: Mapa da Empatia, Canvas da Proposta de Valor, Canvas do Modelo de ...
 
Feedback Canvas - Agile Portugal 2017
Feedback Canvas - Agile Portugal 2017Feedback Canvas - Agile Portugal 2017
Feedback Canvas - Agile Portugal 2017
 
Construindo Produtos Inovadores
Construindo Produtos InovadoresConstruindo Produtos Inovadores
Construindo Produtos Inovadores
 
Seminario Business Model Canvas
Seminario Business Model CanvasSeminario Business Model Canvas
Seminario Business Model Canvas
 
Memoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz Rolim
Memoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz RolimMemoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz Rolim
Memoria Seminario sobre Canvas Model com Alexander Osterwlader - by Luiz Rolim
 
Inovação em modelos de negócios já estabelecidos o analista de modelos de n...
Inovação em modelos de negócios já estabelecidos   o analista de modelos de n...Inovação em modelos de negócios já estabelecidos   o analista de modelos de n...
Inovação em modelos de negócios já estabelecidos o analista de modelos de n...
 
Palestra Experiência do Cliente
Palestra Experiência do ClientePalestra Experiência do Cliente
Palestra Experiência do Cliente
 
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
 
Strategic Business Model Canvas v3
Strategic Business Model Canvas v3Strategic Business Model Canvas v3
Strategic Business Model Canvas v3
 
Company Presentation: Canvas
Company Presentation: CanvasCompany Presentation: Canvas
Company Presentation: Canvas
 

Similar to 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
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 CanvasHenry Osborne
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not FlashThomas Fuchs
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video gamedandylion13
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...Codemotion
 
The Future of CSS with Web components
The Future of CSS with Web componentsThe Future of CSS with Web components
The Future of CSS with Web componentsdevObjective
 
The Future of CSS with Web Components
The Future of CSS with Web ComponentsThe Future of CSS with Web Components
The Future of CSS with Web ComponentsColdFusionConference
 
Rotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billyRotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billynimbleltd
 
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
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02PL dream
 
HTML5 & The Open Web - at Nackademin
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at NackademinRobert Nyman
 
Building mobile web apps with Mobello
Building mobile web apps with MobelloBuilding mobile web apps with Mobello
Building mobile web apps with MobelloJeong-Geun Kim
 

Similar to Canvas (20)

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
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 Canvas
 
Html5
Html5Html5
Html5
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
 
The Future of CSS with Web components
The Future of CSS with Web componentsThe Future of CSS with Web components
The Future of CSS with Web components
 
The Future of CSS with Web Components
The Future of CSS with Web ComponentsThe Future of CSS with Web Components
The Future of CSS with Web Components
 
Rotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billyRotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billy
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
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)
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
HTML5 & The Open Web - at Nackademin
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at Nackademin
 
Html canvas
Html canvasHtml canvas
Html canvas
 
HTML5 for Mobile
HTML5 for MobileHTML5 for Mobile
HTML5 for Mobile
 
Building mobile web apps with Mobello
Building mobile web apps with MobelloBuilding mobile web apps with Mobello
Building mobile web apps with Mobello
 

More from Rajon

Chat Application | RSD
Chat Application | RSDChat Application | RSD
Chat Application | RSDRajon
 
AND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtionalAND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtionalRajon
 
Modern Elicitation Process
Modern Elicitation ProcessModern Elicitation Process
Modern Elicitation ProcessRajon
 
Numerical Analysis lab 4
Numerical Analysis lab 4Numerical Analysis lab 4
Numerical Analysis lab 4Rajon
 
Pillar's of Pixel's | Project report
Pillar's of Pixel's | Project reportPillar's of Pixel's | Project report
Pillar's of Pixel's | Project reportRajon
 
Farm Manager | Project Proposal
Farm Manager | Project ProposalFarm Manager | Project Proposal
Farm Manager | Project ProposalRajon
 
Pillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposalPillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposalRajon
 
Displacement addressing
Displacement addressingDisplacement addressing
Displacement addressingRajon
 
System Design Flow
System Design FlowSystem Design Flow
System Design FlowRajon
 
Backup Photos- Project Proposal
Backup Photos- Project ProposalBackup Photos- Project Proposal
Backup Photos- Project ProposalRajon
 
Chat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & DesignChat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & DesignRajon
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 
Chat Application FAQ
Chat Application FAQChat Application FAQ
Chat Application FAQRajon
 
Presentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life CyclePresentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life CycleRajon
 
Chat Application [Full Documentation]
Chat Application [Full Documentation]Chat Application [Full Documentation]
Chat Application [Full Documentation]Rajon
 
Presentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project PlanningPresentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project PlanningRajon
 

More from Rajon (16)

Chat Application | RSD
Chat Application | RSDChat Application | RSD
Chat Application | RSD
 
AND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtionalAND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtional
 
Modern Elicitation Process
Modern Elicitation ProcessModern Elicitation Process
Modern Elicitation Process
 
Numerical Analysis lab 4
Numerical Analysis lab 4Numerical Analysis lab 4
Numerical Analysis lab 4
 
Pillar's of Pixel's | Project report
Pillar's of Pixel's | Project reportPillar's of Pixel's | Project report
Pillar's of Pixel's | Project report
 
Farm Manager | Project Proposal
Farm Manager | Project ProposalFarm Manager | Project Proposal
Farm Manager | Project Proposal
 
Pillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposalPillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposal
 
Displacement addressing
Displacement addressingDisplacement addressing
Displacement addressing
 
System Design Flow
System Design FlowSystem Design Flow
System Design Flow
 
Backup Photos- Project Proposal
Backup Photos- Project ProposalBackup Photos- Project Proposal
Backup Photos- Project Proposal
 
Chat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & DesignChat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & Design
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Chat Application FAQ
Chat Application FAQChat Application FAQ
Chat Application FAQ
 
Presentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life CyclePresentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life Cycle
 
Chat Application [Full Documentation]
Chat Application [Full Documentation]Chat Application [Full Documentation]
Chat Application [Full Documentation]
 
Presentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project PlanningPresentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project Planning
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

Canvas

  • 2. WHAT HTML5 CANVAS IS USED FOR ■ dynamic graphics ■ online and offline games ■ animations ■ interactive video and audio Easy to turn a plain web page into a dynamic web application and then convert that application into a mobile app for use on smartphones and tablets.
  • 3. Skeleton <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script type="application/javascript"> function draw() { var canvas = document.getElementById('canvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); //Draw Here } }else{ //Fall bac kContent Goes Here } </script> </head> <body> <canvas id="canvas" width="150" height="150"></canvas> //Create a Canvas </body> </html>
  • 4. Understanding the Canvas Coordinate System
  • 5. Curves var x = canvas.width / 2; var y = canvas.height / 2; var radius = 75; var startAngle = 0 * Math.PI; var endAngle = 2 * Math.PI; context.beginPath(); context.arc(x, y, radius, startAngle, endAngle); context.lineWidth = 15; // line color context.strokeStyle = 'green'; context.stroke(); Arc
  • 6. Curves context.moveTo(188, 130); context.bezierCurveTo(140, 10, 388, 10, 388, 170); context.lineWidth = 10; Quadratic Curve context.moveTo(188, 150); context.quadraticCurveTo(288, 0, 388, 150); Bezier Curve
  • 7. Paths context.moveTo(100, 20); // line 1 context.lineTo(200, 160); // quadratic curve context.quadraticCurveTo(230, 200, 250, 120); // bezier curve context.bezierCurveTo(290, -40, 300, 200, 400, 150); // line 2 context.lineTo(500, 90) context.lineJoin = 'bevel';
  • 8. Shape // begin custom shape context.beginPath(); context.moveTo(170, 80); context.bezierCurveTo(130, 100, 130, 150, 230, 150); context.bezierCurveTo(250, 180, 320, 180, 340, 150); context.bezierCurveTo(420, 150, 420, 120, 390, 100); context.bezierCurveTo(430, 40, 370, 30, 340, 50); context.bezierCurveTo(320, 5, 250, 20, 250, 50); context.bezierCurveTo(200, 5, 150, 20, 170, 80);
  • 9. Shape context.beginPath(); context.rect(188, 50, 200, 100); context.fillStyle = 'yellow'; context.fill(); context.lineWidth = 7; context.strokeStyle = 'black'; context.stroke();
  • 10. Fill Style context.fillStyle = '#8ED6FF'; context.fill(); Color Fill // add linear gradient var grd = context.createLinearGradient(0, 0, canvas.width, canvas.height); // light blue grd.addColorStop(0, '#8ED6FF'); // dark blue grd.addColorStop(1, '#004CB3'); context.fillStyle = grd; context.fill(); Linear Gradient
  • 11. Radial Gradient // create radial gradient var grd = context.createRadialGradient(238, 50, 10, 238,50, 300); // light blue grd.addColorStop(0, '#8ED6FF'); // dark blue grd.addColorStop(1, '#004CB3'); context.fillStyle = grd; context.fill();
  • 12. Pattern var imageObj = new Image(); imageObj.onload = function() { var pattern = context.createPattern(imageObj, 'repeat'); context.rect(0, 0, canvas.width, canvas.height); context.fillStyle = pattern; context.fill(); }; imageObj.src = 'http://www.html5canvastutorials.com/demos/assets/wood- pattern.png';
  • 13. Text context.textAlign = 'left'; ontext.strokeText('Hello World!', x, y); Align Stroke context.fillStyle = 'blue'; Color context.font = 'italic 40pt Calibri'; Font Size Style context.measureText(text); Metricies wrapText(context, text, x, y, maxWidth, lineHeight); WrapText
  • 14. Transformations // translate context to center of canvas context.translate(canvas.width / 2, canvas.height / 2); // scale y component context.scale(1, 0.5); // rotate 45 degrees clockwise context.rotate(Math.PI / 4); // apply custom transform context.transform(1, 0, 0, 1, tx, ty); // apply custom transform context.setTransform(1, 0, 0, 1, 0, 0);
  • 15. Transformation State Stack context.save(); // save state 1 context.translate(canvas.width / 2, canvas.height / 2); context.save(); // save state 2 context.rotate(Math.PI / 4); context.save(); // save state 3 context.scale(2, 2); context.fillStyle = 'blue'; context.fillRect(rectWidth / -2, rectHeight / -2, rectWidth, rectHeight); context.restore(); // restore state 1 context.fillStyle = 'green'; context.fillRect(rectWidth / -2, rectHeight / -2, rectWidth, rectHeight);
  • 16. Composites //Shadows context.shadowColor = '#999'; context.shadowBlur = 20; context.shadowOffsetX = 15; context.shadowOffsetY = 15; //Global alpha context.globalAlpha = 0.5; //Cliping Region context.clip();
  • 17. Animation animate(myRectangle, canvas, context, startTime); • Acceleration • Oscillation • Linear Motion • Animation Frame Lets Look at an example………..
  • 18. Mouse Position function writeMessage(canvas, message) { var context = canvas.getContext('2d'); context.clearRect(0, 0, canvas.width, canvas.height); context.font = '18pt Calibri'; context.fillStyle = 'black'; context.fillText(message, 10, 25);} function getMousePos(canvas, evt) { var rect = canvas.getBoundingClientRect(); return { x: evt.clientX - rect.left, y: evt.clientY - rect.top };} var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); canvas.addEventListener('mousemove', function(evt) { var mousePos = getMousePos(canvas, evt); var message = 'Mouse position: ' + mousePos.x + ',' + mousePos.y; writeMessage(canvas, message); }, false);
  • 19. Should Check Out ■ http://cheatsheetworld.com/programming/html5-canvas-cheat-sheet/ ■ http://www.sinuousgame.com/ ■ http://corehtml5canvas.com/code-live/ ■ http://curran.github.io/HT ■ http://www.williammalone.com/articles/create-html5-canvas-javascript-game- character/1/ML5Examples/ ■ http://cssdeck.com/labs/ping-pong-game-tutorial-with-html5-canvas-and-sounds