Hormold

Vk.com

Oct 24th, 2011
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.89 KB | None | 0 0
  1. <html><head>
  2. <script>
  3. //based on http://jswidget.com/blog/2011/03/06/drawing-heart-shape/
  4. function onload(type) {
  5.     drawHeart(document.getElementById('drawing'));
  6. }
  7. function drawHeart(canvas){
  8.    var x0 = 0.5 * 10, y0 = 0.3 * 11, x1 = 0.1 * 10, y1 = 0.0 * 11, x2 = 0.0 * 10, y2 = 0.6 * 11, x3 = 0.5 * 10, y3 = 0.9 * 11, x4 = 1.0 * 10, y4 = 0.6 * 11, x5 = 0.9 * 10, y5 = 0.0 * 11;
  9.    var ctx = canvas.getContext("2d");
  10.    ctx.save(); ctx.beginPath();
  11.    ctx.moveTo(x0,y0);
  12.    ctx.bezierCurveTo(x1,y1,x2,y2,x3,y3);
  13.    ctx.bezierCurveTo(x4,y4,x5,y5,x0,y0);
  14.    ctx.fillStyle = '#799DC1';
  15.    ctx.strokeStyle = '#6B8FB6';
  16.    ctx.stroke();
  17.    ctx.fill();
  18.    ctx.restore();
  19. }
  20.  
  21. </script>
  22. <title>VK</title></head><body onload="onload()">
  23. <center><br /><br /><br /><h1>Canvas demo<br /><br /></h1>
  24. <canvas style="margin:10px" id="drawing" width="100" height="500">
  25. </canvas>
  26. </center>
  27. </body></html>
  28.  
Advertisement
Add Comment
Please, Sign In to add comment