joannakr

Untitled

Dec 10th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. body {
  5. background: #ffffff url("img_tree.png") no-repeat right top;
  6. margin-right: 200px;
  7. }
  8. </style>
  9. <title>Курсова работа</title>
  10. </head>
  11. <body>
  12. <form name="data_IN">
  13. L:<input type="text" name="l" value=""> <br>
  14. B:<input type="text" name="b" value=""> <br>
  15. </form>
  16. <button onclick="draw();">Draw</button>
  17. <button onclick="clean();">Clean</button>
  18. <br>
  19. <canvas id="myCanvas" width="1300" height="475" style="border:1px solid #d3d3d3;">
  20. Your browser doesn't support the HTML5 canvas tag. </canvas>
  21. <script>
  22. var canvas = document.getElementById("myCanvas");
  23. var ctx = canvas.getContext("2d");
  24. var k =4.47;
  25. function draw()
  26. {
  27. var h=document.data_IN.l.value*-1;
  28. var p=document.data_IN.b.value*-1;
  29. ctx.clearRect(0,0, canvas.width, canvas.height);
  30.  
  31.  
  32. ctx.beginPath();
  33. ctx.moveTo((20+(2*p/2))*k,40*k);
  34. ctx.lineTo((20+(2*p/2))*k,66*k); // 1 liniq
  35.  
  36. ctx.moveTo((22+(p/2))*k,38*k);
  37. ctx.lineTo((22+(p/2))*k,68*k); // 2 liniq
  38.  
  39. ctx.moveTo((20+(2*p/2))*k,40*k);
  40. ctx.lineTo((22+(p/2))*k,38*k); //45 ygyl
  41.  
  42. ctx.moveTo((20+(2*p/2))*k,66*k);
  43. ctx.lineTo((22+(p/2))*k,68*k); //45 ygyl
  44.  
  45. ctx.moveTo((22+(p/2))*k,38*k); //liniq chast ot B 34mm otgore
  46. ctx.lineTo((56+(p/2))*k,38*k);
  47.  
  48. ctx.moveTo((22+(p/2))*k,68*k);
  49. ctx.lineTo((56+(p/2))*k,68*k); //liniq chast ot B 34mm otdolu
  50.  
  51. ctx.moveTo((56+(p/2))*k,35*k);
  52. ctx.lineTo((56+(p/2))*k,71*k); //3 liniq
  53.  
  54. ctx.moveTo((56+(p/2))*k,71*k);
  55. ctx.lineTo(138*k,71*k); //liniq 82mm otdolu
  56.  
  57. ctx.moveTo((56+(p/2))*k,35*k);
  58. ctx.lineTo(138*k,35*k); //liniq 82mm otgore
  59.  
  60. ctx.moveTo(138*k,35*k);
  61. ctx.lineTo(138*k,71*k); //liniq 4
  62.  
  63. ctx.moveTo(138*k,35*k);
  64. ctx.lineTo(138*k,29*k); //liniq 4
  65.  
  66. ctx.moveTo(138*k,71*k);
  67. ctx.lineTo(138*k,77*k); //liniq 4
  68.  
  69. ctx.moveTo(138*k,29*k);
  70. ctx.lineTo(183*k,29*k); //liniq 45mm otgore
  71.  
  72. ctx.moveTo(138*k,77*k);
  73. ctx.lineTo(183*k,77*k); //liniq 45mm otdolu
  74.  
  75. ctx.moveTo(183*k,29*k);
  76. ctx.lineTo(183*k,77*k); //liniq 5
  77.  
  78. ctx.moveTo(183*k,31.5*k);
  79. ctx.lineTo(186*k,31.5*k); //liniq 3mm otgore
  80.  
  81. ctx.moveTo(183*k,74.5*k);
  82. ctx.lineTo(186*k,74.5*k); //liniq 3mm otdolu
  83.  
  84.  
  85.  
  86. ctx.moveTo(186*k,27*k);
  87. ctx.lineTo(186*k,79*k); //liniq 6
  88.  
  89. ctx.moveTo(186*k,27*k);
  90. ctx.lineTo(191*k,27*k); //liniq 5mm otgore
  91.  
  92. ctx.moveTo(186*k,79*k);
  93. ctx.lineTo(191*k,79*k); //liniq 5mm otdolu
  94.  
  95. ctx.moveTo(191*k,27*k);
  96. ctx.lineTo(191*k,79*k); //liniq 7
  97.  
  98. ctx.moveTo(193*k,29*k);
  99. ctx.lineTo(193*k,77*k); //liniq 8
  100.  
  101. ctx.moveTo(191*k,27*k);
  102. ctx.lineTo(193*k,29*k); //ъгъл 45 горе
  103.  
  104. ctx.moveTo(191*k,79*k);
  105. ctx.lineTo(193*k,77*k); //ъгъл 45 долу
  106.  
  107. ctx.moveTo(193*k,35*k);
  108. ctx.lineTo(263*k,35*k); //liniq 70mm gore
  109.  
  110. ctx.moveTo(193*k,71*k);
  111. ctx.lineTo(263*k,71*k); //liniq 70mm dolu
  112.  
  113. ctx.moveTo(263*k,35*k);
  114. ctx.lineTo(263*k,71*k); //liniq 9
  115.  
  116. ctx.moveTo(263*k,40.5*k);
  117. ctx.lineTo(265*k,40.5*k); //liniq 2mm otgore
  118.  
  119. ctx.moveTo(263*k,65.5*k);
  120. ctx.lineTo(265*k,65.5*k); //liniq 2mm otdolu
  121.  
  122. ctx.moveTo(265*k,((38+(h/2)))*k);
  123. ctx.lineTo(265*k,((68+(-h/2)))*k); //liniq 10
  124.  
  125. ctx.moveTo(265*k,((38+(h/2)))*k);
  126. ctx.lineTo(275*k,((38+(h/2)))*k); // liniq 10mm otgore
  127.  
  128. ctx.moveTo(265*k,((68+(-h/2)))*k);
  129. ctx.lineTo(275*k,((68+(-h/2)))*k); //liniq 10mm otdolu
  130.  
  131. ctx.moveTo(275*k,((38+(h/2)))*k);
  132. ctx.lineTo(275*k,((68+(-h/2)))*k); //liniq 11
  133.  
  134. ctx.moveTo(277*k,((40+(h/2)))*k);
  135. ctx.lineTo(277*k,((66+(-h/2)))*k); //liniq 12
  136.  
  137. ctx.moveTo(277*k,((40+(h/2)))*k);
  138. ctx.lineTo(275*k,((38+(h/2)))*k); //ygyl 45
  139.  
  140. ctx.moveTo(277*k,((66+(-h/2)))*k);
  141. ctx.lineTo(275*k,((68+(-h/2)))*k); //ygyl 45
  142.  
  143. ctx.stroke();
  144. ctx.closePath();
  145.  
  146. }
  147. function clean()
  148. {
  149. ctx.clearRect(0,0, canvas.width, canvas.height);
  150. }
  151. </script>
  152. </body
  153. </html>
Advertisement
Add Comment
Please, Sign In to add comment