5 things about HTML5

5 things about HTML5: talk overview

Why am I here?

What I will talking about

What I will not be talking about

HTML5: what does it give you?

HTML5: what does it take away?

Thing 1: Semantics

Why bother?

Thing 1: New semantic tags

Thing 1: Semantics - what is extensibility?

Thing 1: Why extend?

Thing 1: Semantic Microdata - how?

Thing 1: Web3.0?

Thing 2: HTML5 gives you load of new form elements

  • Forms, up till now, consist of text boxes radio buttons , check boxes ; selection lists . And textareas for big blocks of text.
  • HTML5 adds...
  • Email, URL, Number, Range, Date, Time, Search, and Color.
  • Attributes for placeholder text placeholder="text" that work in textual input elements
  • An autofocus attribute
  • A required attribute

Thing 2: What do these new elements look like ?

  • Email:
  • URL:
  • Number:
  • Range:
  • Date:
  • Time:
  • Search:
  • Color:
  • Spot anything interesting?

Thing 2: advantages of semantic form elements

Thing 3: localStorage and taking it offline

Thing 3: using localStorage

Thing 3: downloadable apps

Thing 4: you can access suprisingly detailed device information

Thing 4: really there's not much I can do here using a lectern PC

On the code snippets and examples page I've got a few demos...

The device orientation is fairly new - the w3 event specification is dated 12 June 2012.

(So don't be surprised if it doesn't work.)

Thing 5: So what's canvas give you?

<canvas id="mycan" width="20" height="20"></canvas>
<script>
var canv=document.getElementById("mycan");
var ctx=mycan.getContext("2d");
ctx.fillStyle='#faa';
ctx.fillRect(0,0,15,15);
<script>
    

Thing 5: It's all about the canvas context

Thing 5: basic graphics - the canvas coordinate system

Thing 5: Colours on the canvas

Thing 5: graphics with fillStyles and gradients

var bee_picture=document.getElementById("bee");
gradcontext.fillStyle=
   gradcontext.createPattern(bee_picture,"repeat");

Thing 5: graphics with lines and paths

c_context.beginPath();
c_context.moveTo(x1, y1);
c_context.lineTo(x2, y2);
c_context.stroke(); 
var c_canvas = document.getElementById("id of your canvas");
var c_context = c_canvas.getContext("2d");

Thing 5: canvas graphics with linestyles

lineWidth
lineCap
lineJoin
miterLimit

The W drawn on the canvas is then filled with transparent red - this lets you see the effect of filling a shape that's not been closed using closePath(). Filling closed shapes works as expected.

Thing 5: arcs and circles

X centre
Y centre
Radius
Start angle
End angle
circ_context.arc(x, y, r, 
start_angle, end_angle, false);

Thing 5: Transformations: translations, rotations and scaling

Thing 5: Including images on a canvas

var bee_img=document.getElementById("bee");
ctx.drawImage(bee_img,20,20); 
var bee_img=new Image();
bee_img.src="bee_small.png";
ctx.drawImage(bee_img,20,20);

Thing 5: Text on a canvas

Well that was the 5 things - but can we bring it all together?

Basic idea:

My target audience

Step 1: do some intensive market research

Ladies and gentlemen, I give you...

POO BUM DINOSAUR TRAIN EXPLOSION

http://users.aber.ac.uk/hmd1/html5/poo_game.html

Controls

Problems