| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <!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>
|