UNPKG

@jiaminghi/c-render

Version:

Canvas-based vector graphics rendering plugin

71 lines (57 loc) 1.32 kB
<!DOCTYPE html> <html> <head> <meta charset="utf8" /> <title>Rect</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 rect = render.add({ name: 'rect', animationCurve: 'easeOutCubic', animationFrame: 50, drag: true, hover: true, shape: { x: w / 2 - 100, y: h / 2 - 50, w: 200, h: 100 }, style: { fill: '#ffee97', stroke: 'goldenrod', lineWidth: 2 } }) function wait (time) { return new Promise(resolve => setTimeout(resolve, time)) } async function start () { await wait(1000) await rect.animation('shape', { x: w / 2 - 200, w: 400 }) await wait(1000) rect.animation('style', { fill: 'lemonchiffon' }) } start() </script> </html>