UNPKG

@jiaminghi/c-render

Version:

Canvas-based vector graphics rendering plugin

59 lines (48 loc) 1.12 kB
<!DOCTYPE html> <html> <head> <meta charset="utf8" /> <title>clone</title> <style> html, body, #canvas { width: 100%; height: 100%; margin: 0px; padding: 0px; } </style> <script src="../../dist/crender.map.js"></script> </head> <body> <canvas id="canvas"></canvas> </body> <script> const { CRender, extendNewGraph } = window.CRender const render = new CRender(document.querySelector('#canvas')) const [w, h] = render.area const circle = render.add({ name: 'circle', animationCurve: 'easeOutCubic', animationFrame: 50, drag: true, hover: true, shape: { rx: w / 2, ry: h / 2, r: 100 }, style: { fill: '#ffee97', stroke: 'goldenrod', lineWidth: 2 } }) const circleCloned = render.clone(circle) circle.animation('shape', { rx: w / 2 - 150 }, true) circleCloned.animation('shape', { rx: w / 2 + 150 }) </script> </html>