sashomaga

canvas -> bicycle

May 10th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.     <title></title>
  5.     <style>
  6.         #can1
  7.         {
  8.             border: 1px solid black;
  9.         }
  10.     </style>
  11. </head>
  12. <body>
  13.     <canvas id="can1" width="800" height="500">
  14.     </canvas>
  15.    
  16. </body>
  17.     <script>
  18.         var ctx = document.getElementById('can1').getContext('2d');
  19.         // first wheel
  20.         ctx.beginPath();
  21.         ctx.arc(150, 350, 100, 0, 2 * Math.PI, false);      
  22.         ctx.fillStyle = '#90CAD7';
  23.         ctx.fill();
  24.         ctx.lineWidth = 2;
  25.         ctx.strokeStyle = '#317281';
  26.         ctx.stroke();
  27.         // rama
  28.         ctx.beginPath();
  29.         ctx.moveTo(150, 350);
  30.         ctx.lineTo(300, 200);
  31.         ctx.lineTo(550, 200);
  32.         ctx.lineTo(350, 350);
  33.         ctx.lineTo(150, 350);
  34.         ctx.stroke();
  35.         // second wheel
  36.         ctx.beginPath();
  37.         ctx.arc(570, 350, 100, 0, 2 * Math.PI, false);        
  38.         ctx.fill();        
  39.         ctx.stroke();
  40.         // rudder        
  41.         ctx.beginPath();
  42.         ctx.moveTo(570, 350);
  43.         ctx.lineTo(540, 100);
  44.         ctx.lineTo(460, 140);
  45.         ctx.moveTo(540, 100);
  46.         ctx.lineTo(580, 20);
  47.         ctx.stroke();
  48.         // treadle
  49.         ctx.beginPath();
  50.         ctx.arc(350, 350, 30, 0, 2 * Math.PI, false);
  51.         ctx.stroke();
  52.         ctx.beginPath();
  53.         ctx.moveTo(300, 340);
  54.         ctx.lineTo(320, 343);        
  55.         ctx.moveTo(400, 360);
  56.         ctx.lineTo(380, 357);
  57.         ctx.stroke();
  58.         //seat
  59.         ctx.beginPath();
  60.         ctx.moveTo(350, 350);
  61.         ctx.lineTo(275, 125);
  62.         ctx.lineTo(225, 125);
  63.         ctx.moveTo(275, 125);
  64.         ctx.lineTo(325, 125);
  65.         ctx.stroke();
  66.     </script>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment