写一个放烟花的HTML代码
时间: 2023-03-14 19:15:47 浏览: 142
使用HTML 实现一个烟花效果
<html>
<head>
<title>Fireworks</title>
</head>
<body>
<h1>烟花!</h1>
<canvas id="canvas" width="500" height="500"></canvas>
<script>
// Get the canvas element
let canvas = document.getElementById('canvas'); // Create an empty project and a view for the canvas:
paper.setup(canvas); // Create a Paper.js Path to draw a line into it:
let path = new paper.Path();
// Give the stroke a color
path.strokeColor = 'black';
let start = new paper.Point(100, 100);
// Move to start and draw a line from there
path.moveTo(start);
// Note that the plus operator on Point objects does not work
// in JavaScript. Instead, we need to call the add() function:
path.lineTo(start.add([ 200, -50 ])); // Create a circle shaped path
let circle = new paper.Path.Circle(start, 5);
circle.fillColor = 'red'; // Draw the view now:
paper.view.draw();
</script>
</body>
</html>
阅读全文