058fe22863da02a37d2d2075be7e3e9d560098e66b1d593282c3fdc8da8d38ad52b3a737c3c2fce255b4901dfefa458a5b1f08bf02248cb935be07501cbc2e 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf8" />
  5. <title>Rect</title>
  6. <style>
  7. html, body, #canvas {
  8. width: 100%;
  9. height: 100%;
  10. margin: 0px;
  11. padding: 0px;
  12. }
  13. </style>
  14. <script src="../../dist/crender.map.js"></script>
  15. </head>
  16. <body>
  17. <canvas id="canvas"></canvas>
  18. </body>
  19. <script>
  20. const { CRender, extendNewGraph } = window.CRender
  21. const render = new CRender(document.querySelector('#canvas'))
  22. const [w, h] = render.area
  23. const text = render.add({
  24. name: 'text',
  25. animationCurve: 'easeOutCubic',
  26. animationFrame: 50,
  27. drag: true,
  28. hover: true,
  29. hoverRect: [
  30. w / 2 - 125,
  31. h / 2 - 70,
  32. 250,
  33. 140
  34. ],
  35. shape: {
  36. position: [w / 2, h / 2],
  37. content: 'This is line 1\nThis is line 2\nThis is line 3'
  38. },
  39. style: {
  40. fill: '#ffee97',
  41. lineWidth: 2,
  42. fontSize: 40
  43. },
  44. moved (e, { hoverRect }) {
  45. const { movementX, movementY } = e
  46. hoverRect[0] += movementX
  47. hoverRect[1] += movementY
  48. }
  49. })
  50. </script>
  51. </html>