Guest User

Untitled

a guest
Mar 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <script>
  2. //Page size
  3. var bw = 207;
  4. var bh = 315;
  5.  
  6. //page padding
  7. var pw = 0 + 0.5;
  8. var ph = 0;
  9.  
  10. //Grid every
  11. var v = 9;
  12. var h = 9;
  13.  
  14. //margins
  15. var tm = 9;
  16. var bm = 18;
  17. var om = 18;
  18. var im = 9;
  19.  
  20. var canvas = document.getElementById("canvas");
  21. var context = canvas.getContext("2d");
  22.  
  23. function drawBoard() {
  24.  
  25. //horizontal lines
  26. for (var x = 0; x <= bw; x += h) {
  27. context.moveTo(x + pw, ph);
  28. context.lineTo(x + pw, bh);
  29. context.strokeStyle = "#999";
  30. context.stroke();
  31. }
  32.  
  33. //vertical lines
  34. for (var x = 0; x <= bh; x += v) {
  35. context.moveTo(pw, x + ph + 0.5);
  36. context.lineTo(bw, x + ph + 0.5);
  37. context.strokeStyle = "#ddd";
  38. context.stroke();
  39.  
  40. }
  41. // Paper -- Red box
  42. context.beginPath();
  43. context.strokeStyle = "red";
  44. context.rect(pw, ph, bw, bh + 0.5);
  45. //duplicate
  46. context.rect(pw + bw, ph, bw, bh + 0.5);
  47.  
  48.  
  49. context.stroke();
  50.  
  51. // text area -- Blue box
  52. var mw = bw - (im + om);
  53. var mh = bh - (tm + bm);
  54.  
  55. context.beginPath();
  56. context.strokeStyle = "blue";
  57. context.rect(om + 0.5, tm + 0.5, mw, mh);
  58. //duplicate --- Inverted
  59. context.rect(im + 0.5 + bw, tm + 0.5, mw, mh);
  60.  
  61. context.stroke();
  62. }
  63.  
  64. drawBoard();
  65.  
  66. </script>
Add Comment
Please, Sign In to add comment