Skip to content

Instantly share code, notes, and snippets.

@sk8terboi87
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk8terboi87/515496a40c272dc20279 to your computer and use it in GitHub Desktop.
Save sk8terboi87/515496a40c272dc20279 to your computer and use it in GitHub Desktop.
HTML5 Canvas
CANVAS
========
http://www.comp.nus.edu.sg/~stevenha/visualization/training.html
Introduction
HTML5
what is canvas?
why canvas?
<http://www.sitepoint.com/html5-canvas-tutorial-introduction/>
http://tutorials.jenkov.com/html5-canvas/paths.html
References
----------------------------------
Scaling:
http://corehtml5canvas.com/code-live/ch01/example-1.9/example.html
http://corehtml5canvas.com/code-live/ch04/example-4.9/example.html
Image
loading: http://corehtml5canvas.com/code-live/ch02/example-2.5/example.html
Shapes:
basics:
http://corehtml5canvas.com/code-live/ch02/example-2.9/example.html
http://corehtml5canvas.com/code-live/ch02/example-2.25/example.html
Lines & Mouse Events:
http://corehtml5canvas.com/code-live/ch02/example-2.15/example.html
circle:
http://corehtml5canvas.com/code-live/ch02/example-2.19/example.html
curve:
http://corehtml5canvas.com/code-live/ch02/example-2.22/example.html
http://corehtml5canvas.com/code-live/ch02/example-2.29/example.html
Animation
Fade
http://corehtml5canvas.com/code-live/ch04/example-4.20/example.html
http://corehtml5canvas.com/code-live/ch05/example-5.12/example.html
parapallax
http://corehtml5canvas.com/code-live/ch05/example-5.15/example.html
http://corehtml5canvas.com/code-live/ch05/example-5.17/example.html
spinning
http://corehtml5canvas.com/code-live/ch02/section-2.13.2.3/example.html
Text
http://corehtml5canvas.com/code-live/ch03/example-3.18/example.html
Physics
http://corehtml5canvas.com/code-live/ch07/example-7.1/example.html
Collission detection:
http://corehtml5canvas.com/code-live/ch08/section-8.4.1.6/example.html
http://corehtml5canvas.com/code-live/ch08/example-8.1/example.html
=====================
http://corehtml5canvas.com/code-live/
http://tutorials.jenkov.com/html5-canvas/animation.html
<html>
<head>
<style type="text/css">
/* Canvas has no border; like empty drawing paper */
canvas {
border:1px solid #000;
}
</style>
<script type="text/javascript">
function init() {
drawShape();
}
function drawShape() {
// now, we have reference to canvas
var canvas = document.getElementById('drawingArea');
// two types of canvas; 2d and 3d; 3d is still experimental stage
var canvasContext = canvas.getContext('2d');
// Part: 1
// rect will mark a position but will not draw
// starts from upper left corner
canvasContext.rect(5, 10, 50, 50);
// till stroke is called
canvasContext.stroke();
// Part: 2
// canvasContext
canvasContext.fillStyle = "red";
canvasContext.fillRect(10, 20, 100, 100);
canvasContext.strokeStyle = "blue";
canvasContext.lineWidth = 5;
canvasContext.strokeRect(10, 20, 100, 100);
// Part: 3
canvasContext.clearRect(10, 30, 100, 100);
}
</script>
</head>
<body onload='init()'>
<!-- Canvas is like drawing in paper -->
<canvas id='drawingArea'></canvas>
<a href='#' onclick='init()'>Draw</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment