日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

html信号动画,HTML5 Canvas火箭着陆和雷达信号动画

發布時間:2024/7/23 HTML 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html信号动画,HTML5 Canvas火箭着陆和雷达信号动画 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

JavaScript

語言:

JaveScriptBabelCoffeeScript

確定

let canvas = document.querySelector('canvas');

let ctx = canvas.getContext('2d');

canvas.width = document.body.clientWidth;

canvas.height = 150;

let centerX = canvas.width / 2;

let centerY = canvas.height / 2;

let lineY = 0;

let lines = [];

for (let i = 0; i < 3; i++) {

lines.push({

y: i * canvas.height / 3

});

}

function update(dt) {

for (let i = 0; i < lines.length; i++) {

lines[i].y += 1.2;

if (lines[i].y >= canvas.height) {

lines[i].y = 0;

}

}

}

function draw(dt) {

requestAnimationFrame(draw);

update(dt);

ctx.fillStyle = "#24241f";

ctx.strokeStyle = "#dd5277";

ctx.clearRect(0, 0, canvas.width, canvas.height);

ctx.fillRect(0, 0, canvas.width, canvas.height);

ctx.shadowColor = '#dd5277';

ctx.shadowOffsetX = 0;

ctx.shadowOffsetY = 0;

ctx.shadowBlur = 20;

for (let i = lines.length - 1; i >= 0; i--) {

ctx.beginPath();

ctx.moveTo(0, lines[i].y);

ctx.lineWidth = 0.2 + (lines[i].y * (1.5 - 0.2) / canvas.height)

ctx.lineTo(canvas.width, lines[i].y);

ctx.stroke();

}

ctx.lineWidth = 3.0;

// middle line

ctx.beginPath();

ctx.moveTo(centerX, 0);

ctx.lineTo(centerX, canvas.height);

ctx.stroke();

let spacing = 80;

let verticalLines = Math.round(canvas.width / spacing / 2);

for (let i = 1; i <= verticalLines; i++) {

ctx.beginPath();

ctx.moveTo(centerX - (i * spacing), -1);

ctx.bezierCurveTo(

centerX - (i * spacing) * 1.5, 10,

centerX - (i * spacing) * 2.5, canvas.height,

centerX - (i * spacing) * 2.5, canvas.height,

);

ctx.stroke();

ctx.beginPath();

ctx.moveTo(centerX + (i * spacing), -1);

ctx.bezierCurveTo(

centerX + (i * spacing) * 1.5, 10,

centerX + (i * spacing) * 2.5, canvas.height,

centerX + (i * spacing) * 2.5, canvas.height,

);

ctx.stroke();

}

}

draw();

總結

以上是生活随笔為你收集整理的html信号动画,HTML5 Canvas火箭着陆和雷达信号动画的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。