SlideShare a Scribd company logo
Graphics & Animation
with HTML5
Graphics & Animation
with HTML5
Pushpendu Purkait
Software Consultant
Knoldus Software LLP
Pushpendu Purkait
Software Consultant
Knoldus Software LLP
Agenda
● Introduction of HTML5
● What's new in HTML5 ?
● HTML5 Graphics
● HTML5 Animation
● Demo
Introduction of HTML5
● HTML5 is the fifth revision and newest version of the HTML
standard.
● It offers new features that provide not only rich media support,
but also enhance support for creating web applications that
can interact with the user, his/her local data, and servers,
more easily and effectively than was possible previously.
What's new in HTML5
● DOCTYPE
● The <Figure> element
● No More Types for Scripts and Links
● New <input> types
– color
– number
– email
– url
– range
What's new in HTML5 cont..
● <header>,<footer> tags
● Required Attribute
● <audio>,<video> tag
● Regular Expression
DOCTYPE
● HTML4
– <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" “
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.
”>
● HTML5
– <!DOCTYPE html>
The <figure> tag
● Before
<img src=”path/to/image” alt=”alternate text”>
<p>Description of image</p>
● Now
<figure>
<img src=”path/to/image” alt=”alternate text”>
<figcaption>
<p>Description of image</p>
</figcaption>
<figure>
No more types for Scripts and links
● Before
<link rel="stylesheet" href="path/to/stylesheet.css"
type="text/css" />
● Now
<link rel="stylesheet" href="path/to/stylesheet.css" />
New <input> tags
● Color - To choose color from the color palette
● Number – To get only numbers in textbox.
● Email – To get only email in textbox.
● Url – To get only URL in textbox.
● Range – To get value within a range.(By using
Slider)
<header><footer> tags
● <header> tag is used to add header on web
page.
● <footer> tag is used to add footer on web
page.
Required Attribute
● User can't leave the field blank
● JavaScript is no longer required for client side
validation.
<input type="text" name="Input"
required="required">
<audio> tag
● <audio> tag is used to add an audio file to web page.
● In case <audio> tag is not supported by web browser, We can
add alternative text.
● Multiple files can be added if first is not supported by browser
then next will be played.
● We can add controllers in <audio> tag.
<audio autoplay="autoplay" controls="controls">
     <source src="file.ogg" />
     <source src="file.mp3" /> 
     <a>Download this file.</a>
  </audio>
<video> tag
● <video> tag is used to add video to the web page.
● In case <video> tag is not supported by web browser, We can add alternative text.
● Multiple files can be added if first is not supported by browser then next will be played.
● We can add controllers in <video> tag.
● We can access out webcam and show it in <video> tag.
<video id=”webcam”>
    <p> Your browser is doesn't support it.</p>
</video>
<script> var video = document.getElementById('webcam');
Video.src = window.URL.createObjectURL(localMediaStream);
<script>
Regular Expressions
● We can add regular expressions to <input> tags for
validation, There is no JavaScript required.
<form action="" method="post">
    <label for="username">Create a Username: </label>
    <input type="text"
       name="username"
       id="username"
       placeholder="4 <> 10"
       pattern="[A-Za-z]{4,10}"
       autofocus
       required>
    <button type="submit">Go </button>
</form>
HTML5 Graphics
● <canvas> is the most important part of HTML5
graphics.
– At first sight  a  <canvas>  looks  like  the  <img> 
element,  with  the  only  clear  difference  being 
that it doesn't have the src and alt attributes.
– <canvas> has only two attributes height & width. 
both  are  optional  and  can  be  set  using  DOM 
properties.
● Fallback Content- If browser doesn't support canvas
than we can add fallback content.
HTML5 Graphics cont...
● We can draw anything on <canvas> by using
some inbuilt functions.
● Some tasks which can be done in canvas:
– Drawing Rectangle
– Drawing Path (lines & arcs)
– Applying Colors & Style
– Rendering Text
– Applying Transformation (translation,scaling, rotating)
Canvas Context
● There is a context of canvas by which we draw
everything on canvas.
● Context contains some properties for drawing
for example: color, width etc.
● For best practice when we call any function,
we should always save() the context first and
at last restore() the context.
Drawing Rectangle
● We can draw rectangles by 3 ways
– fillRect(x,y, width, height):- draws a filled rectangle.
– strokeRect(x,y, width, height):- draws an outline.
– clearRect(x,y,width, height):- clears the area.
Drawing Path
● Paths can be of two types
– Closed
– Open
● There are some steps of drawing a line on canvas
– BeginPath():- creates a new path
– moveTo(x,y):- moves the cursor to (x,y) point.
– lineTo(x,y):- draws line from current position to (x,y) point
– stroke() :- draws the line on canvas.(without this no lines will be
drawn)
– closePath():- draws line from current position to first point.
– fill():- fills the closed path.
Applying Colors & Style
● We can set fillStyle for filling the object.
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
for (var i=0;i<6;i++){
for (var j=0;j<6;j++){
ctx.fillStyle = 'rgb(' + Math.floor(255-42.5*i) + ',' +
Math.floor(255-42.5*j) + ',0)';
ctx.fillRect(j*25,i*25,25,25);
}
}
}
Applying Colors & Style
●
We can set strokeStyle for outlining the object.
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
for (var i=0;i<6;i++){
for (var j=0;j<6;j++){
ctx.strokeStyle = 'rgb(0,' + Math.floor(255-42.5*i) + ',' +
Math.floor(255-42.5*j) + ')';
ctx.beginPath();
ctx.arc(12.5+j*25,12.5+i*25,10,0,Math.PI*2,true);
ctx.stroke();
}
}
}
Rendering Text
● We can fill text or make outline of text by using
fillText(text, x, y, [maxWidth]) and strokeText(text,x,y,
[maxWidth]) here maxWidth is optional.
function draw(){
var ctx = document.getElementById('canvas').getContext('2d');
ctx.font = “48px serif”;
ctx.fillText(“Hello world”, 10, 50);
ctx.stroke(“Hello world”,50, 50);
}
Applying Transformation
● There are 3 types of transformations
– Translation – change position of an object.
– Scaling – change size of an object.
– Rotation – rotating an object with respect to a
point.
Translation
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
for (var i=0;i<3;i++) {
for (var j=0;j<3;j++) {
ctx.save();
ctx.fillStyle = 'rgb('+(51*i)+','+(255-51*i)+',255)';
ctx.translate(10+j*50,10+i*50);
ctx.fillRect(0,0,25,25);
ctx.restore();
}
}
}
Rotating
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
ctx.fillStyle = "#0095DD";
ctx.fillRect(30,30, 100, 100);
ctx.rotate((Math.PI/180)*25);
ctx.fillStyle = "#4D4E53";
ctx.fillRect(30,30, 100, 100);
ctx.fillStyle = "#0095DD";
ctx.fillRect(150, 30, 100, 100);
ctx.translate(200, 80); // translate to rectangle center
ctx.rotate((Math.PI/180)*25); // rotate
ctx.translate(-200, -80);
ctx.fillStyle = "#4D4E53";
ctx.fillRect(150, 30, 100, 100);
}
Scaling
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
// draw a simple rectangle, but scale it.
ctx.save();
ctx.scale(10, 3);
ctx.fillRect(1,10,10,10);
ctx.restore();
// mirror horizontally
ctx.scale(-1, 1);
ctx.font = "48px serif";
ctx.fillText("MDN", -135, 120);
}
HTML5 Animation
● Animation is a part of Canvas.
● Animation is nothing but rendering canvas
frame by frame.
● There are some basic steps for animation
– Clear the canvas
– Save the canvas state
– Draw animated shapes
– Restore canvas state
Controlling the animation
● Shapes are drawn to the canvas by using the canvas methods directly
or by calling custom functions. In normal circumstances, we only see
these results appear on the canvas when the script finishes executing.
For instance, it isn't possible to do an animation from within a for loop.
● Instead we can schedule them to occur after a particular time.
● There are three ways to control the rendering of frames.
– setInterval(function, delay)
– setTImeout(function, delay)
– requestAnimationFrame(callback)
Controlling the animation cont...
● setInterval(fxn, delay):- Starts repeatedly executing the
function specified by function every delay milliseconds.
● setTimeout(fnx,delay):- Executes the function specified
by function in delay milliseconds.
● requestAminationFrame(callback):-Tells the browser that
you wish to perform an animation and requests that the
browser call a specified function to update an animation
before the next repaint. It gives us 60 frames/second.
Demo
● Video Demo: Video
● Webcam Demo : Webcam
● HTML5 Graphics: Graphics
● HTML5 Animation: Animation
Graphics & Animation with HTML5
Ad

More Related Content

What's hot (20)

html-table
html-tablehtml-table
html-table
Dhirendra Chauhan
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Html
HtmlHtml
Html
Nisa Soomro
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
vikasgaur31
 
HTML Tags
HTML TagsHTML Tags
HTML Tags
Pranay Agrawal
 
Html list
Html listHtml list
Html list
sayed fathey
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
Html images syntax
Html images syntaxHtml images syntax
Html images syntax
JayjZens
 
Basic HTML
Basic HTMLBasic HTML
Basic HTML
Sayan De
 
Html media
Html mediaHtml media
Html media
Webtech Learning
 
Html5 semantics
Html5 semanticsHtml5 semantics
Html5 semantics
Webtech Learning
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Java swing
Java swingJava swing
Java swing
Apurbo Datta
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
Sgml
SgmlSgml
Sgml
rahul kundu
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
HTML/HTML5
HTML/HTML5HTML/HTML5
HTML/HTML5
People Strategists
 

Viewers also liked (20)

Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scala
Sandeep Purohit
 
Splunk
SplunkSplunk
Splunk
Knoldus Inc.
 
Css3
Css3Css3
Css3
Knoldus Inc.
 
Kanban
KanbanKanban
Kanban
Knoldus Inc.
 
Couchbase - Introduction
Couchbase - IntroductionCouchbase - Introduction
Couchbase - Introduction
Knoldus Inc.
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in Scala
Knoldus Inc.
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
Knoldus Inc.
 
GulpJs - An Introduction
GulpJs - An IntroductionGulpJs - An Introduction
GulpJs - An Introduction
Knoldus Inc.
 
Fsm knolx
Fsm knolxFsm knolx
Fsm knolx
Knoldus Inc.
 
Spark
SparkSpark
Spark
Knoldus Inc.
 
Couchbase training advanced
Couchbase training advancedCouchbase training advanced
Couchbase training advanced
Knoldus Inc.
 
Http programming in play
Http programming in playHttp programming in play
Http programming in play
Knoldus Inc.
 
Couchbase training basic
Couchbase training basicCouchbase training basic
Couchbase training basic
Knoldus Inc.
 
Getting Started With AureliaJs
Getting Started With AureliaJsGetting Started With AureliaJs
Getting Started With AureliaJs
Knoldus Inc.
 
BlinkDB - Approximate Queries on Very Large Data
BlinkDB - Approximate Queries on Very Large DataBlinkDB - Approximate Queries on Very Large Data
BlinkDB - Approximate Queries on Very Large Data
Knoldus Inc.
 
Mandrill Templates
Mandrill TemplatesMandrill Templates
Mandrill Templates
Knoldus Inc.
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
Knoldus Inc.
 
Angular Js
Angular JsAngular Js
Angular Js
Knoldus Inc.
 
Into the domain
Into the domainInto the domain
Into the domain
Knoldus Inc.
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
Knoldus Inc.
 
Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scala
Sandeep Purohit
 
Couchbase - Introduction
Couchbase - IntroductionCouchbase - Introduction
Couchbase - Introduction
Knoldus Inc.
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in Scala
Knoldus Inc.
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
Knoldus Inc.
 
GulpJs - An Introduction
GulpJs - An IntroductionGulpJs - An Introduction
GulpJs - An Introduction
Knoldus Inc.
 
Couchbase training advanced
Couchbase training advancedCouchbase training advanced
Couchbase training advanced
Knoldus Inc.
 
Http programming in play
Http programming in playHttp programming in play
Http programming in play
Knoldus Inc.
 
Couchbase training basic
Couchbase training basicCouchbase training basic
Couchbase training basic
Knoldus Inc.
 
Getting Started With AureliaJs
Getting Started With AureliaJsGetting Started With AureliaJs
Getting Started With AureliaJs
Knoldus Inc.
 
BlinkDB - Approximate Queries on Very Large Data
BlinkDB - Approximate Queries on Very Large DataBlinkDB - Approximate Queries on Very Large Data
BlinkDB - Approximate Queries on Very Large Data
Knoldus Inc.
 
Mandrill Templates
Mandrill TemplatesMandrill Templates
Mandrill Templates
Knoldus Inc.
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
Knoldus Inc.
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
Knoldus Inc.
 
Ad

Similar to Graphics & Animation with HTML5 (20)

Html5
Html5Html5
Html5
prithag92
 
Html5
Html5Html5
Html5
prithag92
 
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-phpapp02
PL dream
 
Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4
BeeNear
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
Kevin DeRudder
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
Patrick Chanezon
 
gdsc-html-ppt.pptx
gdsc-html-ppt.pptxgdsc-html-ppt.pptx
gdsc-html-ppt.pptx
yuvakiran15
 
Brave new world of HTML5
Brave new world of HTML5Brave new world of HTML5
Brave new world of HTML5
Chris Mills
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5
smueller_sandsmedia
 
DV10 HTML5: The Future of Web Development
DV10 HTML5: The Future of Web Development DV10 HTML5: The Future of Web Development
DV10 HTML5: The Future of Web Development
Ronald Widha
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with Wings
Remy Sharp
 
What you need to know bout html5
What you need to know bout html5What you need to know bout html5
What you need to know bout html5
Kevin DeRudder
 
Html5
Html5Html5
Html5
Zeeshan Ahmed
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
Mahmoud Samir Fayed
 
05-06 HTML lecture FOR BS STUDENTS IUB.ppt
05-06 HTML lecture FOR BS STUDENTS IUB.ppt05-06 HTML lecture FOR BS STUDENTS IUB.ppt
05-06 HTML lecture FOR BS STUDENTS IUB.ppt
allsoftwarekeys
 
HTML5 and CSS3 Shizzle
HTML5 and CSS3 ShizzleHTML5 and CSS3 Shizzle
HTML5 and CSS3 Shizzle
Chris Mills
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutes
Jos Dirksen
 
Basic html5 and javascript
Basic html5 and javascriptBasic html5 and javascript
Basic html5 and javascript
wendy017
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
Stephen Chin
 
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-phpapp02
PL dream
 
Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4
BeeNear
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
Patrick Chanezon
 
gdsc-html-ppt.pptx
gdsc-html-ppt.pptxgdsc-html-ppt.pptx
gdsc-html-ppt.pptx
yuvakiran15
 
Brave new world of HTML5
Brave new world of HTML5Brave new world of HTML5
Brave new world of HTML5
Chris Mills
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5
smueller_sandsmedia
 
DV10 HTML5: The Future of Web Development
DV10 HTML5: The Future of Web Development DV10 HTML5: The Future of Web Development
DV10 HTML5: The Future of Web Development
Ronald Widha
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with Wings
Remy Sharp
 
What you need to know bout html5
What you need to know bout html5What you need to know bout html5
What you need to know bout html5
Kevin DeRudder
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
Mahmoud Samir Fayed
 
05-06 HTML lecture FOR BS STUDENTS IUB.ppt
05-06 HTML lecture FOR BS STUDENTS IUB.ppt05-06 HTML lecture FOR BS STUDENTS IUB.ppt
05-06 HTML lecture FOR BS STUDENTS IUB.ppt
allsoftwarekeys
 
HTML5 and CSS3 Shizzle
HTML5 and CSS3 ShizzleHTML5 and CSS3 Shizzle
HTML5 and CSS3 Shizzle
Chris Mills
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutes
Jos Dirksen
 
Basic html5 and javascript
Basic html5 and javascriptBasic html5 and javascript
Basic html5 and javascript
wendy017
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
Stephen Chin
 
Ad

More from Knoldus Inc. (20)

Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-HealingOptimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - HealeniumSelf-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Java 17 features and implementation.pptxJava 17 features and implementation.pptx
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in KubernetesChaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM PresentationGraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime PresentationDAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN PresentationIntroduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Introduction to Argo Rollouts PresentationIntroduction to Argo Rollouts Presentation
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Intro to Azure Container App PresentationIntro to Azure Container App Presentation
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability ExcellenceInsights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis FrameworkCode Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS PresentationAWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and AuthorizationAmazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web DevelopmentZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-HealingOptimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - HealeniumSelf-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Java 17 features and implementation.pptxJava 17 features and implementation.pptx
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in KubernetesChaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM PresentationGraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime PresentationDAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN PresentationIntroduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Introduction to Argo Rollouts PresentationIntroduction to Argo Rollouts Presentation
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Intro to Azure Container App PresentationIntro to Azure Container App Presentation
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability ExcellenceInsights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis FrameworkCode Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS PresentationAWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and AuthorizationAmazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web DevelopmentZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 

Recently uploaded (20)

Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 

Graphics & Animation with HTML5

  • 1. Graphics & Animation with HTML5 Graphics & Animation with HTML5 Pushpendu Purkait Software Consultant Knoldus Software LLP Pushpendu Purkait Software Consultant Knoldus Software LLP
  • 2. Agenda ● Introduction of HTML5 ● What's new in HTML5 ? ● HTML5 Graphics ● HTML5 Animation ● Demo
  • 3. Introduction of HTML5 ● HTML5 is the fifth revision and newest version of the HTML standard. ● It offers new features that provide not only rich media support, but also enhance support for creating web applications that can interact with the user, his/her local data, and servers, more easily and effectively than was possible previously.
  • 4. What's new in HTML5 ● DOCTYPE ● The <Figure> element ● No More Types for Scripts and Links ● New <input> types – color – number – email – url – range
  • 5. What's new in HTML5 cont.. ● <header>,<footer> tags ● Required Attribute ● <audio>,<video> tag ● Regular Expression
  • 6. DOCTYPE ● HTML4 – <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" “ http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional. ”> ● HTML5 – <!DOCTYPE html>
  • 7. The <figure> tag ● Before <img src=”path/to/image” alt=”alternate text”> <p>Description of image</p> ● Now <figure> <img src=”path/to/image” alt=”alternate text”> <figcaption> <p>Description of image</p> </figcaption> <figure>
  • 8. No more types for Scripts and links ● Before <link rel="stylesheet" href="path/to/stylesheet.css" type="text/css" /> ● Now <link rel="stylesheet" href="path/to/stylesheet.css" />
  • 9. New <input> tags ● Color - To choose color from the color palette ● Number – To get only numbers in textbox. ● Email – To get only email in textbox. ● Url – To get only URL in textbox. ● Range – To get value within a range.(By using Slider)
  • 10. <header><footer> tags ● <header> tag is used to add header on web page. ● <footer> tag is used to add footer on web page.
  • 11. Required Attribute ● User can't leave the field blank ● JavaScript is no longer required for client side validation. <input type="text" name="Input" required="required">
  • 12. <audio> tag ● <audio> tag is used to add an audio file to web page. ● In case <audio> tag is not supported by web browser, We can add alternative text. ● Multiple files can be added if first is not supported by browser then next will be played. ● We can add controllers in <audio> tag. <audio autoplay="autoplay" controls="controls">      <source src="file.ogg" />      <source src="file.mp3" />       <a>Download this file.</a>   </audio>
  • 13. <video> tag ● <video> tag is used to add video to the web page. ● In case <video> tag is not supported by web browser, We can add alternative text. ● Multiple files can be added if first is not supported by browser then next will be played. ● We can add controllers in <video> tag. ● We can access out webcam and show it in <video> tag. <video id=”webcam”>     <p> Your browser is doesn't support it.</p> </video> <script> var video = document.getElementById('webcam'); Video.src = window.URL.createObjectURL(localMediaStream); <script>
  • 14. Regular Expressions ● We can add regular expressions to <input> tags for validation, There is no JavaScript required. <form action="" method="post">     <label for="username">Create a Username: </label>     <input type="text"        name="username"        id="username"        placeholder="4 <> 10"        pattern="[A-Za-z]{4,10}"        autofocus        required>     <button type="submit">Go </button> </form>
  • 15. HTML5 Graphics ● <canvas> is the most important part of HTML5 graphics. – At first sight  a  <canvas>  looks  like  the  <img>  element,  with  the  only  clear  difference  being  that it doesn't have the src and alt attributes. – <canvas> has only two attributes height & width.  both  are  optional  and  can  be  set  using  DOM  properties. ● Fallback Content- If browser doesn't support canvas than we can add fallback content.
  • 16. HTML5 Graphics cont... ● We can draw anything on <canvas> by using some inbuilt functions. ● Some tasks which can be done in canvas: – Drawing Rectangle – Drawing Path (lines & arcs) – Applying Colors & Style – Rendering Text – Applying Transformation (translation,scaling, rotating)
  • 17. Canvas Context ● There is a context of canvas by which we draw everything on canvas. ● Context contains some properties for drawing for example: color, width etc. ● For best practice when we call any function, we should always save() the context first and at last restore() the context.
  • 18. Drawing Rectangle ● We can draw rectangles by 3 ways – fillRect(x,y, width, height):- draws a filled rectangle. – strokeRect(x,y, width, height):- draws an outline. – clearRect(x,y,width, height):- clears the area.
  • 19. Drawing Path ● Paths can be of two types – Closed – Open ● There are some steps of drawing a line on canvas – BeginPath():- creates a new path – moveTo(x,y):- moves the cursor to (x,y) point. – lineTo(x,y):- draws line from current position to (x,y) point – stroke() :- draws the line on canvas.(without this no lines will be drawn) – closePath():- draws line from current position to first point. – fill():- fills the closed path.
  • 20. Applying Colors & Style ● We can set fillStyle for filling the object. function draw() { var ctx = document.getElementById('canvas').getContext('2d'); for (var i=0;i<6;i++){ for (var j=0;j<6;j++){ ctx.fillStyle = 'rgb(' + Math.floor(255-42.5*i) + ',' + Math.floor(255-42.5*j) + ',0)'; ctx.fillRect(j*25,i*25,25,25); } } }
  • 21. Applying Colors & Style ● We can set strokeStyle for outlining the object. function draw() { var ctx = document.getElementById('canvas').getContext('2d'); for (var i=0;i<6;i++){ for (var j=0;j<6;j++){ ctx.strokeStyle = 'rgb(0,' + Math.floor(255-42.5*i) + ',' + Math.floor(255-42.5*j) + ')'; ctx.beginPath(); ctx.arc(12.5+j*25,12.5+i*25,10,0,Math.PI*2,true); ctx.stroke(); } } }
  • 22. Rendering Text ● We can fill text or make outline of text by using fillText(text, x, y, [maxWidth]) and strokeText(text,x,y, [maxWidth]) here maxWidth is optional. function draw(){ var ctx = document.getElementById('canvas').getContext('2d'); ctx.font = “48px serif”; ctx.fillText(“Hello world”, 10, 50); ctx.stroke(“Hello world”,50, 50); }
  • 23. Applying Transformation ● There are 3 types of transformations – Translation – change position of an object. – Scaling – change size of an object. – Rotation – rotating an object with respect to a point.
  • 24. Translation function draw() { var ctx = document.getElementById('canvas').getContext('2d'); for (var i=0;i<3;i++) { for (var j=0;j<3;j++) { ctx.save(); ctx.fillStyle = 'rgb('+(51*i)+','+(255-51*i)+',255)'; ctx.translate(10+j*50,10+i*50); ctx.fillRect(0,0,25,25); ctx.restore(); } } }
  • 25. Rotating function draw() { var ctx = document.getElementById('canvas').getContext('2d'); ctx.fillStyle = "#0095DD"; ctx.fillRect(30,30, 100, 100); ctx.rotate((Math.PI/180)*25); ctx.fillStyle = "#4D4E53"; ctx.fillRect(30,30, 100, 100); ctx.fillStyle = "#0095DD"; ctx.fillRect(150, 30, 100, 100); ctx.translate(200, 80); // translate to rectangle center ctx.rotate((Math.PI/180)*25); // rotate ctx.translate(-200, -80); ctx.fillStyle = "#4D4E53"; ctx.fillRect(150, 30, 100, 100); }
  • 26. Scaling function draw() { var ctx = document.getElementById('canvas').getContext('2d'); // draw a simple rectangle, but scale it. ctx.save(); ctx.scale(10, 3); ctx.fillRect(1,10,10,10); ctx.restore(); // mirror horizontally ctx.scale(-1, 1); ctx.font = "48px serif"; ctx.fillText("MDN", -135, 120); }
  • 27. HTML5 Animation ● Animation is a part of Canvas. ● Animation is nothing but rendering canvas frame by frame. ● There are some basic steps for animation – Clear the canvas – Save the canvas state – Draw animated shapes – Restore canvas state
  • 28. Controlling the animation ● Shapes are drawn to the canvas by using the canvas methods directly or by calling custom functions. In normal circumstances, we only see these results appear on the canvas when the script finishes executing. For instance, it isn't possible to do an animation from within a for loop. ● Instead we can schedule them to occur after a particular time. ● There are three ways to control the rendering of frames. – setInterval(function, delay) – setTImeout(function, delay) – requestAnimationFrame(callback)
  • 29. Controlling the animation cont... ● setInterval(fxn, delay):- Starts repeatedly executing the function specified by function every delay milliseconds. ● setTimeout(fnx,delay):- Executes the function specified by function in delay milliseconds. ● requestAminationFrame(callback):-Tells the browser that you wish to perform an animation and requests that the browser call a specified function to update an animation before the next repaint. It gives us 60 frames/second.
  • 30. Demo ● Video Demo: Video ● Webcam Demo : Webcam ● HTML5 Graphics: Graphics ● HTML5 Animation: Animation
  翻译: