testCanvas.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8">
  5. <title>Canvas Demo</title>
  6. <script src="../../../lib/jquery/jquery.min.js"></script>
  7. <script>
  8. var test = "test";
  9. function setId(){
  10. return "testSetId";
  11. }
  12. </script>
  13. </head>
  14. <body>
  15. <canvas id="cv"></canvas>
  16. <input type="hidden" id="">
  17. <div id="di">sss</div>
  18. </body>
  19. <script>
  20. window.onload = function(){
  21. var canvas = document.getElementById("cv");
  22. var ctx = canvas.getContext("2d");
  23. //ctx.setLineDash([1,1]);
  24. ctx.beginPath();
  25. ctx.moveTo(100, 100);
  26. //ctx.lineWidth = 0.5;
  27. ctx.strokeStyle = "gray";
  28. ctx.lineTo(100, 120);
  29. ctx.lineTo(120, 120);
  30. ctx.lineTo(120, 100);
  31. ctx.lineTo(100, 100);
  32. ctx.stroke();
  33. ctx.beginPath();
  34. ctx.strokeStyle = "black";
  35. ctx.moveTo(105, 110);
  36. ctx.lineTo(115, 110);
  37. ctx.stroke();
  38. ctx.beginPath();
  39. ctx.moveTo(100, 50);
  40. ctx.strokeStyle = "gray";
  41. ctx.lineTo(100, 70);
  42. ctx.lineTo(120, 70);
  43. ctx.lineTo(120, 50);
  44. ctx.lineTo(100, 50);
  45. ctx.stroke();
  46. ctx.beginPath();
  47. ctx.strokeStyle = "black";
  48. ctx.moveTo(105, 60);
  49. ctx.lineTo(115, 60);
  50. ctx.moveTo(110, 55);
  51. ctx.lineTo(110, 65);
  52. ctx.stroke();
  53. $("#di").remove();
  54. }
  55. </script>
  56. </html>