doc.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>画板程序</title>
  8. <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
  9. <style>
  10. .canvas {
  11. width: 400px;
  12. height: 200px;
  13. border: 1px solid rgb(170, 170, 170);
  14. cursor: pointer;
  15. }
  16. .mgTop {
  17. margin-top: 30px;
  18. }
  19. </style>
  20. <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js "></script>
  21. <script src="https://cdn.bootcss.com/fabric.js/2.0.0-rc.4/fabric.js "></script>
  22. <script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  23. <script>hljs.initHighlightingOnLoad();</script>
  24. </head>
  25. <body style="padding-left: 10px;">
  26. <div class="mgTop">
  27. <h1>1.自由绘</h1>
  28. <canvas id="freeCanvas" class="canvas"></canvas>
  29. <br /> 代码:
  30. <pre><code class="javascipt">
  31. var canvas = new fabric.Canvas("freeCanvas", {
  32. isDrawingMode: true,
  33. width: 400,
  34. height: 250
  35. });
  36. </code></pre>
  37. </div>
  38. <HR color=#ccc SIZE=1>
  39. <div class="mgTop">
  40. <h1>2.画直线</h1>
  41. <canvas id="lineCanvas" class="canvas"></canvas>
  42. <br /> 代码:
  43. <pre><code class="javascipt">
  44. </code></pre>
  45. </div>
  46. <script>
  47. //自由绘
  48. var fCanvas = new fabric.Canvas("freeCanvas", {
  49. isDrawingMode: true,
  50. width: 400,
  51. height: 250
  52. });
  53. //画直线
  54. var lCanvas = new fabric.Canvas("lineCanvas");
  55. var line = new fabric.Path(_config);
  56. line.set("stroke", "red");
  57. </script>
  58. </body>
  59. </html>