You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.3 KiB
HTML
76 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf8" />
|
|
<title>Sector</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 sector = render.add({
|
|
name: 'sector',
|
|
animationCurve: 'easeOutCubic',
|
|
animationFrame: 50,
|
|
drag: true,
|
|
hover: true,
|
|
shape: {
|
|
rx: w / 2,
|
|
ry: h / 2,
|
|
r: 100,
|
|
startAngle: -Math.PI / 2,
|
|
endAngle: Math.PI
|
|
},
|
|
style: {
|
|
fill: '#ffee97',
|
|
stroke: 'goldenrod',
|
|
lineWidth: 2,
|
|
rotate: 0
|
|
}
|
|
})
|
|
|
|
function wait (time) {
|
|
return new Promise(resolve => setTimeout(resolve, time))
|
|
}
|
|
|
|
async function start () {
|
|
await wait(1000)
|
|
|
|
sector.animation('shape', {
|
|
r: 150
|
|
}, true)
|
|
|
|
await sector.animation('style', {
|
|
rotate: 45
|
|
})
|
|
|
|
await wait(1000)
|
|
|
|
sector.animation('style', {
|
|
fill: 'lemonchiffon'
|
|
})
|
|
}
|
|
|
|
start()
|
|
|
|
</script>
|
|
</html> |