JSFiddle - React, Tailwind, and code Playground
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test</title>
<script src="https://unpkg.com/spritejs@3/dist/spritejs.js">
</script>
</head>
<body>
<div id="adaptive" style="width: 500px;height:600px;"></div>
<script>
const {Scene, Sprite, Gradient, Path} = spritejs;
const container = document.getElementById('adaptive');
const scene = new Scene({
container,
width: 600,
height: 360,
});
const layer = scene.layer();
const gradient = new Gradient({
vector: [0, 0, 150, 150],
colors: [
{offset: 0, color: 'red'},
{offset: 1, color: 'green'},
],
});
const box = new Sprite({
anchor: [0.5, 0.5],
size: [150, 150],
pos: [300, 180],
bgcolor: gradient,
});
layer.append(box);
const cross = new Path('M-5 0L5 0M0 5L0 -5');
cross.attr({
pos: [300, 180],
lineWidth: 2,
strokeColor: 'blue',
});
layer.append(cross);
box.animate([
{rotate: 0},
{rotate: 360},
], {
iterations: Infinity,
duration: 3000,
});
</script>
</body>
</html>