Guest User

Untitled

a guest
Jan 13th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.57 KB | None | 0 0
  1. <html>
  2. <head>
  3. <canvas id="example" width="800" height="600">
  4. This text is displayed if your browser does not support HTML5 Canvas.
  5. </canvas>
  6. <script type="text/javascript">
  7.  
  8. var example = document.getElementById('example');
  9. var context = example.getContext('2d');
  10. context.fillStyle = "rgb(255,0,0)";
  11. context.strokeStyle = "rgb(80,80,80)";
  12. context.lineWidth = 3;
  13.  
  14. function drawRectangle()
  15. {
  16.     // set up drawing
  17.     context.beginPath();
  18.        
  19.     // set up rectangle
  20.     context.moveTo(0, 0)
  21.     context.lineTo(0, 100)
  22.     context.lineTo(100, 100)
  23.     context.lineTo(100, 0)
  24.     context.lineTo(0, 0)
  25.  
  26.     // fill rectangle
  27.     context.fill();
  28.  
  29.     // draw rectangle
  30.     context.stroke();
  31.  
  32.     // close down drawing
  33.     context.closePath();
  34. }
  35. function drawCross()
  36. {
  37.     // set up drawing
  38.     context.beginPath();
  39.  
  40.     // set up line vertically in middle
  41.     context.moveTo(50, 0)
  42.     context.lineTo(50, 100)
  43.  
  44.     // set up line horizontally in middle
  45.     context.moveTo(0,50)
  46.     context.lineTo(100,50)
  47.  
  48.     // draw the lines
  49.     context.stroke();
  50.  
  51.     // close down drawing
  52.     context.closePath()
  53. }
  54. function drawS()
  55. {
  56.     // set up drawing
  57.     context.beginPath();
  58.     context.lineWidth = 1.5;
  59.  
  60.     // set start of S
  61.     context.moveTo(75, 35)
  62.  
  63.     context.lineTo(74, 34)
  64.     context.lineTo(73, 33)
  65.     context.lineTo(72, 32)
  66.     context.lineTo(71, 31)
  67.    
  68.  
  69.     context.lineTo(50, 17.5)
  70.  
  71.  
  72.     context.lineTo(25, 35)
  73.  
  74.  
  75.     context.lineTo(75, 70)
  76.  
  77.  
  78.  
  79.     context.lineTo(50, 87.5)
  80.  
  81.  
  82.  
  83.     context.lineTo(25, 70)
  84.  
  85.  
  86.  
  87.  
  88.  
  89.     // draw the S
  90.     context.stroke();
  91.  
  92.     // close down the drawing
  93.     context.closePath();
  94. }
  95. </script>
  96. </head>
  97.  
  98. <body>
  99.  
  100.  
  101. <script type="text/javascript">
  102. <!--
  103. drawRectangle()
  104. //drawCross()
  105. drawS()
  106. // -->
  107. </script>
  108.  
  109.  
  110.  
  111. </body>
  112. </html>
Add Comment
Please, Sign In to add comment