Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1: HTML5
Dr. Sanjay P. Bhakkad
Associate Professor
IMSCD&R, Ahmednagar
Introduction to HTML
HyperText Markup Language, commonly abbreviated
as HTML, is the standard markup language used to
create web pages as well as to create user interfaces
for mobile and web applications.
Web browsers can read HTML files and render them
into visible or audible web pages.
HTML describes the structure of a website semantically
and included cues for the presentation or appearance
of the document (web page), making it a markup
language, rather than a programming language.
Dr. Sanjay P. Bhakkad, Associate Professor, IMSCD&R Ahmednagar.
Basics of HTML5
HTML5 is a markup language used for structuring and
presenting content on the World Wide Web.
It is the 5th and current version of the HTML standard.
It was published in October 2014 by the World Wide
Web Consortium(W3C) to improve the language with
support for the latest multimedia, while keeping it easily
readable by humans—and consistently understood by
computers and devices such as web browsers, parsers,
etc.
HTML5 is the next major revision of the HTML standard
superseding not only HTML 4, but also XHTML 1
and DOM Level 2 HTML.
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Interesting blog</title>
</head>
<body>
<p>Today I drank coffee for breakfast. 14 hours later, I
went to bed.</p>
</body>
</html>
Autoplay:
<video src=sampleVideo.ogv autoplay></video>
Code with Fallback Content facility:
<h1>Video and legacy browser fallback</h1>
<video src=sampleVideo.ogv>
Your browser does not support HTML5. Please upgrade your
browser.
</video>
Muted:
A boolean attribute when present, it specifies that the
audio output of the video should be muted.
<video src=sampleVideo.ogv controls muted></video>
Value Description
auto A suggestion to the browser that it should begin
downloading the entire file.
metadata Suggest the browser to download metadata, such
as length of the video or its format.
none Suggest the browser not to download any of the
video. This saves bandwidth.
Dr. Sanjay P. Bhakkad, Associate Professor, IMSCD&R Ahmednagar.
A <video> element : Codecs
Since not all browsers can play the same formats, in production
environments you need to have more than one source file.
For example, Opera and Firefox support Vorbis and Theora.
Safari provide native support for the H.264 video codec and
MP3 audio. IE9 support H.264, which is also supported on
iPhone and Android. Google Chrome supports Theora and
H.264 video, and Vorbis and MP3 audio.
Google announced it is opensourcing a video codec called
VP8 (webM). Opera, Firefox and Chrome have announced it
will support it. every YouTube video will be in webM format.
The rule is: provide both royalty-free (webM or Theora) and
H.264 video in your pages, and both Vorbis and MP3 audio so
that nobody gets locked out of your content.
Dr. Sanjay P. Bhakkad, Associate Professor, IMSCD&R Ahmednagar.
Multiple <source> elements
To do this you need to tie the separate versions of the file to the
media element. Instead of using the single src attribute, you nest
separate <source> elements for each encoding with appropriate
type attributes inside the <audio> or <video> element and let the
browser download the format that it can display.
<video controls>
<source src=“sampleVideo.ogv” type=“video/ogg” >
<source src=“sampleVideo.mp4” type=“video/mp4”>
</video>
If you miss out on the type attribute, the browser downloads a small
bit of each file before it figures out that it is unsupported, which
wastes bandwidth and could delay the media playing.
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);
</script>
</body>
</html> See: Canvas2.html
<script>
var canvas = document.getElementById("myCanvas");
var ctx=canvas.getContext("2d");
ctx.font="30px Comic Sans MS";
ctx.fillStyle = "red";
ctx.textAlign = "center";
ctx.fillText("Hello World", canvas.width/2, canvas.height/2);
</script>
</body>
</html>
See: CanvasText.html
TextBaseLineEx.html
Dr. Sanjay P. Bhakkad, Associate Professor, IMSCD&R Ahmednagar.
Canvas : Gradients
Shapes on the canvas are not limited to solid colors. Gradients
can be used to fill rectangles, circles, lines, text, etc.
There are two different types of gradients:
createLinearGradient(x,y,x1,y1) - creates a linear gradient
createRadialGradient(x, y, r, x1,y1,r1) - creates a
radial/circular gradient
Once we have a gradient object, we must add two or more
color stops using the addColorStop() method. This method
specifies the color stops, and its position along the gradient.
Gradient positions can be anywhere between 0 to 1.
To use the gradient, set the fillStyle or strokeStyle property to
the gradient, then draw the shape (rectangle, text, or a line).
Dr. Sanjay P. Bhakkad, Associate Professor, IMSCD&R Ahmednagar.
Linear Gradient
createLinearGradient():
Used to create a linear gradient.
Linear gradients are defined by an imaginary line which defines the
direction of the gradient.
Once we've created our gradient, we can insert colors using
the addColorStop method.
The direction of the linear gradient moves from the starting point to
the ending point of the imaginary line defined with
createLinearGradient() method.
We've used two color stops, one that originates at the starting point
of the gradient, and the other that ends with the ending point.
Color stops are placed along the imaginary line somewhere
between 0 and 1, where 0 is at the starting point, and 1 is at the
ending point.
Dr. Sanjay P. Bhakkad, Associate Professor, IMSCD&R Ahmednagar.
Linear Gradient : Example
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
SVG Canvas
Vector based (composed of shapes) Raster based (composed of pixel)
Multiple graphical elements, which Single HTML element similar
become the part of the DOM to <img> in behavior
Modified through script and CSS Modified through script only
Give better performance with Give better performance with
smaller number of objects or larger smaller surface or larger number of
surface, or both objects, or both
Better scalability — can be printed Poor scalability — not suitable for
with high quality at any resolution printing on higher resolution