1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
<!doctype html>
<html>
<head>
<title>canvas.js | basics (2)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../../pattern/canvas.js"></script>
</head>
<body>
<script type="text/canvas">
// You don't need to define a <canvas> explicitly.
// For each <script type="text/canvas"> a 500 x 500 <canvas> is automatically generated
// and inserted in the document right before the <script> element.
// Variations include:
// <script type="text/canvas" canvas="[id]">
// <script type="text/canvas" loop="false">
function setup(canvas) {
canvas.size(500, 500);
}
function draw(canvas) {
canvas.clear();
translate(250, 250);
rotate(canvas.frame);
rect(-150, -150, 300, 300, {fill: color(1,0,0,1)});
}
</script>
</body>
</html>
|