Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 KB | None | 0 0
  1. <meta name="description" content="TDF Test #1">
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <body>
  6.  
  7. <h1>My first SVG</h1>
  8.  
  9. <svg width="100" height="100">
  10. <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
  11. Sorry, your browser does not support inline SVG.
  12. </svg>
  13.  
  14.  
  15. <canvas id="myCanvas" width="200" height="100"
  16. style="border:1px solid #d3d3d3;">
  17. Your browser does not support the canvas element.
  18. </canvas>
  19.  
  20. <script>
  21. var canvas = document.getElementById("myCanvas");
  22. var ctx = canvas.getContext("2d");
  23. ctx.font = "30px Arial";
  24. ctx.strokeText("Hello World",10,50);
  25. </script>
  26.  
  27. <canvas id="canvas" width="400" height="400"
  28. style="background-color:#333">
  29. </canvas>
  30.  
  31. <script>
  32. var canvas = document.getElementById("canvas");
  33. var ctx = canvas.getContext("2d");
  34. var radius = canvas.height / 2;
  35. ctx.translate(radius, radius);
  36. radius = radius * 0.90
  37. setInterval(drawClock, 1000);
  38.  
  39. function drawClock() {
  40. drawFace(ctx, radius);
  41. drawNumbers(ctx, radius);
  42. drawTime(ctx, radius);
  43. }
  44.  
  45. function drawFace(ctx, radius) {
  46. var grad;
  47. ctx.beginPath();
  48. ctx.arc(0, 0, radius, 0, 2*Math.PI);
  49. ctx.fillStyle = 'white';
  50. ctx.fill();
  51. grad = ctx.createRadialGradient(0,0,radius*0.95, 0,0,radius*1.05);
  52. grad.addColorStop(0, '#333');
  53. grad.addColorStop(0.5, 'white');
  54. grad.addColorStop(1, '#333');
  55. ctx.strokeStyle = grad;
  56. ctx.lineWidth = radius*0.1;
  57. ctx.stroke();
  58. ctx.beginPath();
  59. ctx.arc(0, 0, radius*0.1, 0, 2*Math.PI);
  60. ctx.fillStyle = '#333';
  61. ctx.fill();
  62. }
  63.  
  64. function drawNumbers(ctx, radius) {
  65. var ang;
  66. var num;
  67. ctx.font = radius*0.15 + "px arial";
  68. ctx.textBaseline="middle";
  69. ctx.textAlign="center";
  70. for(num = 1; num < 13; num++){
  71. ang = num * Math.PI / 6;
  72. ctx.rotate(ang);
  73. ctx.translate(0, -radius*0.85);
  74. ctx.rotate(-ang);
  75. ctx.fillText(num.toString(), 0, 0);
  76. ctx.rotate(ang);
  77. ctx.translate(0, radius*0.85);
  78. ctx.rotate(-ang);
  79. }
  80. }
  81.  
  82. function drawTime(ctx, radius){
  83. var now = new Date();
  84. var hour = now.getHours();
  85. var minute = now.getMinutes();
  86. var second = now.getSeconds();
  87. //hour
  88. hour=hour%12;
  89. hour=(hour*Math.PI/6)+
  90. (minute*Math.PI/(6*60))+
  91. (second*Math.PI/(360*60));
  92. drawHand(ctx, hour, radius*0.5, radius*0.07);
  93. //minute
  94. minute=(minute*Math.PI/30)+(second*Math.PI/(30*60));
  95. drawHand(ctx, minute, radius*0.8, radius*0.07);
  96. // second
  97. second=(second*Math.PI/30);
  98. drawHand(ctx, second, radius*0.9, radius*0.02);
  99. }
  100.  
  101. function drawHand(ctx, pos, length, width) {
  102. ctx.beginPath();
  103. ctx.lineWidth = width;
  104. ctx.lineCap = "round";
  105. ctx.moveTo(0,0);
  106. ctx.rotate(pos);
  107. ctx.lineTo(0, -length);
  108. ctx.stroke();
  109. ctx.rotate(-pos);
  110. }
  111. </script>
  112.  
  113.  
  114. <script id="jsbin-javascript">
  115. console.log('Testing....');
  116. function myApartment() {}
  117.  
  118. var myCoffeeMaker = 'Aeropress';
  119. var buildingAddress = '150 E 14th St, New York, NY';
  120. var myCloset = 'Extra coats in the back';
  121. var buildingLaundryCode = 4927;
  122. var myRefridgerator = 'Filled with veggies and dark chocolate.';
  123. var myDog = 'Nikko';
  124. var buildingPhone = '(481) 516-2342';
  125.  
  126. // Do not edit the code after this line
  127. document.write("\n\n\n**Apartment Building Information**");
  128. document.write("Laundry code: " + buildingLaundryCode + "\nPhone: " + buildingPhone + "\nMailing address: " + buildingAddress);
  129. </script>
  130.  
  131. <script id="jsbin-source-html" type="text/html"><meta name="description" content="TDF Test #1">
  132.  
  133. <!DOCTYPE html>
  134. <html>
  135. <body>
  136.  
  137. <h1>My first SVG</h1>
  138.  
  139. <svg width="100" height="100">
  140. <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
  141. Sorry, your browser does not support inline SVG.
  142. </svg>
  143.  
  144.  
  145. <canvas id="myCanvas" width="200" height="100"
  146. style="border:1px solid #d3d3d3;">
  147. Your browser does not support the canvas element.
  148. </canvas>
  149.  
  150. <script>
  151. var canvas = document.getElementById("myCanvas");
  152. var ctx = canvas.getContext("2d");
  153. ctx.font = "30px Arial";
  154. ctx.strokeText("Hello World",10,50);
  155. <\/script>
  156.  
  157. <canvas id="canvas" width="400" height="400"
  158. style="background-color:#333">
  159. </canvas>
  160.  
  161. <script>
  162. var canvas = document.getElementById("canvas");
  163. var ctx = canvas.getContext("2d");
  164. var radius = canvas.height / 2;
  165. ctx.translate(radius, radius);
  166. radius = radius * 0.90
  167. setInterval(drawClock, 1000);
  168.  
  169. function drawClock() {
  170. drawFace(ctx, radius);
  171. drawNumbers(ctx, radius);
  172. drawTime(ctx, radius);
  173. }
  174.  
  175. function drawFace(ctx, radius) {
  176. var grad;
  177. ctx.beginPath();
  178. ctx.arc(0, 0, radius, 0, 2*Math.PI);
  179. ctx.fillStyle = 'white';
  180. ctx.fill();
  181. grad = ctx.createRadialGradient(0,0,radius*0.95, 0,0,radius*1.05);
  182. grad.addColorStop(0, '#333');
  183. grad.addColorStop(0.5, 'white');
  184. grad.addColorStop(1, '#333');
  185. ctx.strokeStyle = grad;
  186. ctx.lineWidth = radius*0.1;
  187. ctx.stroke();
  188. ctx.beginPath();
  189. ctx.arc(0, 0, radius*0.1, 0, 2*Math.PI);
  190. ctx.fillStyle = '#333';
  191. ctx.fill();
  192. }
  193.  
  194. function drawNumbers(ctx, radius) {
  195. var ang;
  196. var num;
  197. ctx.font = radius*0.15 + "px arial";
  198. ctx.textBaseline="middle";
  199. ctx.textAlign="center";
  200. for(num = 1; num < 13; num++){
  201. ang = num * Math.PI / 6;
  202. ctx.rotate(ang);
  203. ctx.translate(0, -radius*0.85);
  204. ctx.rotate(-ang);
  205. ctx.fillText(num.toString(), 0, 0);
  206. ctx.rotate(ang);
  207. ctx.translate(0, radius*0.85);
  208. ctx.rotate(-ang);
  209. }
  210. }
  211.  
  212. function drawTime(ctx, radius){
  213. var now = new Date();
  214. var hour = now.getHours();
  215. var minute = now.getMinutes();
  216. var second = now.getSeconds();
  217. //hour
  218. hour=hour%12;
  219. hour=(hour*Math.PI/6)+
  220. (minute*Math.PI/(6*60))+
  221. (second*Math.PI/(360*60));
  222. drawHand(ctx, hour, radius*0.5, radius*0.07);
  223. //minute
  224. minute=(minute*Math.PI/30)+(second*Math.PI/(30*60));
  225. drawHand(ctx, minute, radius*0.8, radius*0.07);
  226. // second
  227. second=(second*Math.PI/30);
  228. drawHand(ctx, second, radius*0.9, radius*0.02);
  229. }
  230.  
  231. function drawHand(ctx, pos, length, width) {
  232. ctx.beginPath();
  233. ctx.lineWidth = width;
  234. ctx.lineCap = "round";
  235. ctx.moveTo(0,0);
  236. ctx.rotate(pos);
  237. ctx.lineTo(0, -length);
  238. ctx.stroke();
  239. ctx.rotate(-pos);
  240. }
  241. <\/script>
  242.  
  243.  
  244. </body>
  245. </html>
  246. </script>
  247.  
  248.  
  249. <script id="jsbin-source-javascript" type="text/javascript">console.log('Testing....');
  250. function myApartment() {}
  251.  
  252. var myCoffeeMaker = 'Aeropress';
  253. var buildingAddress = '150 E 14th St, New York, NY';
  254. var myCloset = 'Extra coats in the back';
  255. var buildingLaundryCode = 4927;
  256. var myRefridgerator = 'Filled with veggies and dark chocolate.';
  257. var myDog = 'Nikko';
  258. var buildingPhone = '(481) 516-2342';
  259.  
  260. // Do not edit the code after this line
  261. document.write("\n\n\n**Apartment Building Information**");
  262. document.write("Laundry code: " + buildingLaundryCode + "\nPhone: " + buildingPhone + "\nMailing address: " + buildingAddress);
  263. </script></body>
  264. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement