Canvas: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
The [[wikipedia:Canvas element|canvas]] tag was introduced by Apple and has been [http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html standardized to become part of HTML5].
The [[wikipedia:Canvas element|canvas]] tag was introduced by Apple and has been [http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html standardized to become part of HTML5].


To use it, you add the canvas tag to your HTML page, then use javascript draw on it.


Get the canvas tag:
<canvas id="canvas" showsrc>
function draw() {
  c = document.getElementById("canvas");
  p = c.getContext("2d");
  p.fillRect(50, 50, 150, 150);
}
</canvas>


c=document.getElementById("c")
== Loop ==


Get the "context" (like a paper):
== Template ==
 
p=c.getContext("2d");
 
Draw something!
 
p.fillRect(0, 0, 100, 100);


x
== Links ==
== Links ==



Revision as of 16:55, 25 September 2012

The canvas tag was introduced by Apple and has been standardized to become part of HTML5.

To use it, you add the canvas tag to your HTML page, then use javascript draw on it.

<canvas id="canvas" showsrc> function draw() {

 c = document.getElementById("canvas");
 p = c.getContext("2d");
 p.fillRect(50, 50, 150, 150);

} </canvas>

Loop

Template

x

Links