|
| 1 | +<!-- |
| 2 | +http://devhammer.net/blog/exploring-html5-canvas-part-2---basic-shapes |
| 3 | +--> |
| 4 | +<!DOCTYPE html> |
| 5 | +<html> |
| 6 | +<head> |
| 7 | + <meta charset="utf-8" /> |
| 8 | + <title>Canvas Experimental Page</title> |
| 9 | + <style type="text/css"> |
| 10 | + html { background: transparent url('webx-bkg.png') repeat-x; margin: 0; padding: 0; } |
| 11 | + body { font-family: "Segoe UI", Tahoma, Helvetica, Arial, Sans-Serif; margin: 0; padding: 0; line-height: 150%; background: transparent url('webx-content-bkg.jpg') no-repeat center top; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; color: #434343; } |
| 12 | + |
| 13 | + .container { width: 800px; margin: 0 auto 0 auto; padding: 40px 0 0 0; } |
| 14 | + </style> |
| 15 | +</head> |
| 16 | +<body> |
| 17 | + <div class="container"> |
| 18 | + <canvas id="myCanvas" width="500" height="500"> |
| 19 | + <p>Canvas is not supported by your browser.</p> |
| 20 | + </canvas> |
| 21 | + </div> |
| 22 | + <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js" type="text/javascript"></script> |
| 23 | + <script type="text/javascript"> |
| 24 | + $(document).ready(function() { |
| 25 | + var canvas = $('#myCanvas').get(0); |
| 26 | + var context = canvas.getContext("2d"); |
| 27 | + |
| 28 | + function renderContent() { |
| 29 | + context.fillRect(0, 0, canvas.width, canvas.height); |
| 30 | + |
| 31 | + context.fillStyle = "#FF0000"; |
| 32 | + context.fillRect(5, 5, 200, 100); |
| 33 | + context.strokeStyle = "#00ff00"; |
| 34 | + context.strokeRect(5, 5, 200, 100); |
| 35 | + |
| 36 | + // draw a circle with context.arc |
| 37 | + context.lineWidth = 3; |
| 38 | + context.fillStyle = "#0000FF"; |
| 39 | + context.strokeStyle = "#FF0000"; |
| 40 | + context.beginPath(); |
| 41 | + //context.arc(155, 155, 42, Math.PI, Math.PI * 2, false); |
| 42 | + context.arc(155, 155, 42, 0, Math.PI * 2, false); |
| 43 | + context.closePath(); |
| 44 | + context.fill(); |
| 45 | + context.stroke(); |
| 46 | + } |
| 47 | + |
| 48 | + renderContent(); |
| 49 | + }); |
| 50 | + </script> |
| 51 | +</body> |
| 52 | +</html> |
| 53 | + |
0 commit comments