72f825fd5005f82a9116694c253c8b27d6181395ed9840e2d9eeff74aedc645da41186299820eb6bbb1cbc7e50014b8672f0fc56ecea14bfe90e7a241b4f9f 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf8" />
  5. <title>Ellipse</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 ellipse = render.add({
  24. name: 'ellipse',
  25. animationCurve: 'easeOutCubic',
  26. animationFrame: 50,
  27. drag: true,
  28. hover: true,
  29. shape: {
  30. rx: w / 2,
  31. ry: h / 2,
  32. hr: 100,
  33. vr: 50
  34. },
  35. style: {
  36. fill: '#ffee97',
  37. stroke: 'goldenrod',
  38. lineWidth: 2
  39. }
  40. })
  41. function wait (time) {
  42. return new Promise(resolve => setTimeout(resolve, time))
  43. }
  44. async function start () {
  45. await wait(1000)
  46. await ellipse.animation('shape', {
  47. hr: 200
  48. })
  49. await wait(1000)
  50. ellipse.animation('style', {
  51. fill: 'lemonchiffon'
  52. })
  53. }
  54. start()
  55. </script>
  56. </html>