PNews jun 2015 | Page 20
Tutorials Point, Simply Easy Learning
WebSocket and finally when you click on "Run WebSocket" you would get Goodbye message
sent by the server script.
HTML5 – Canvas
HTML5 element gives you an easy and powerful way to draw graphics using
JavaScript. It can be used to draw graphs, make photo compositions or do simple (and not so
simple) animations.
Here is a simple element which has only two specific attributes width and height
plus all the core HTML5 attributes like id, name and class etc.
You can easily find that element in the DOM using getElementById() method as
follows:
var canvas
= document.getElementById("mycanvas");
Let us see a simple example on using element in HTML5 document.
The Rendering Context:
The is initially blank, and to display something, a script first needs to access the
rendering context and draw on it.
The canvas element has a DOM method called getContext, used to obtain the rendering
context and its drawing functions. This function takes one parameter, the type of context 2d.
Following is the code to get required context along with a check if your browser supports
element:
var canvas = document.getElementById("mycanvas");
if (canvas.getContext){
var ctx = canvas.getContext('2d');
// drawing code here
} else {
// canvas-unsupported code here
}
20 | P a g e
PNews jun 2015 | Page 19
PNews jun 2015 | Page 21
Joomag
is a leading digital publishing and content experience platform that helps businesses
create, distribute, and analyze high-design editorial content, including digital magazines, online catalogs,
digital brochures, sales proposals, and marketing reports. Powered by AI and content automation,
Joomag
enables marketers, publishers, and non-creatives to produce professional, interactive
content at scale.
The platform delivers an exceptional, mobile-optimized reading experience and improves content performance with
individual level analytics, audience insights, and segmentation tools. By uncovering reader interests and
enabling re-engagement through targeted campaigns and personalized content recommendations,
Joomag
helps businesses increase reader engagement and drive higher conversion rates.