网站建设用的是什么软件,购物网站开发背景,轻创优选地推app,阳江建设网站文章目录 前言基本绿色的彩色版本飘散雪花状后言 前言 hello world欢迎来到前端的新世界 #x1f61c;当前文章系列专栏#xff1a;前端面试 #x1f431;#x1f453;博主在前端领域还有很多知识和技术需要掌握#xff0c;正在不断努力填补技术短板。(如果出现错误当前文章系列专栏前端面试 博主在前端领域还有很多知识和技术需要掌握正在不断努力填补技术短板。(如果出现错误感谢大家指出) 感谢大家支持您的观看就是作者创作的动力 基本绿色的 !DOCTYPE html
html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestyle* {padding: 0;margin: 0;overflow: hidden;}/style
/headbodycanvas idcanvas/canvasscript srcindex.js/script/body/htmllet canvas document.querySelector(canvas)let ctx canvas.getContext(2d);canvas.width screen.availWidth;
canvas.height screen.availHeight;let str 鋜 斗 z s y y d s 加 油 干.split( );let arr Array(Math.ceil(canvas.width / 10)).fill(0);
const rain () {ctx.fillStyle rgba(0,0,0,0.05);ctx.fillRect(0, 0, canvas.width, canvas.height);ctx.fillStyle #0f0;arr.forEach((item, index) {ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, item 10)arr[index] item canvas.height || item Math.random() * 10000 ? 0 : item 10;})
}setInterval(rain, 40)彩色版本 html
!DOCTYPE html
html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestyle* {padding: 0;margin: 0;overflow: hidden;}/style
/headbodycanvas idcanvas/canvasscript srcindex.js/script/body/htmljs
let canvas document.querySelector(canvas);
let ctx canvas.getContext(2d);
canvas.width screen.availWidth;
canvas.height screen.availHeight;let str 鋜 斗 z s y y d s 加 油 干.split( );let arr Array(Math.ceil(canvas.width / 10)).fill(0);
const colors [#0f0, #f00, #00f, #ff0, #0ff]; // 添加颜色数组const rain () {ctx.fillStyle rgba(0,0,0,0.05);ctx.fillRect(0, 0, canvas.width, canvas.height);arr.forEach((item, index) {const randomColor colors[Math.floor(Math.random() * colors.length)]; // 随机选取颜色ctx.fillStyle randomColor; // 使用随机颜色ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, item 10);arr[index] item canvas.height || item Math.random() * 10000 ? 0 : item 10;});
};setInterval(rain, 40);飘散雪花状 !DOCTYPE html
html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestyle* {padding: 0;margin: 0;overflow: hidden;}/style
/headbodycanvas idcanvas/canvasscript srcindex.js/script/body/htmllet canvas document.querySelector(canvas);
let ctx canvas.getContext(2d);
canvas.width screen.availWidth;
canvas.height screen.availHeight;let str 鋜 斗 加 油 猛 猛 干 .split( );
let strIndex 0;let arr Array(Math.ceil(canvas.width / 10)).fill(0);class Drop {constructor() {this.x Math.random() * canvas.width;this.y Math.random() * -canvas.height;this.speed Math.random() * 2 2;this.color # Math.floor(Math.random() * 16777215).toString(16);this.height Math.random() * 20 10;this.text str[strIndex];strIndex (strIndex 1) % str.length;}update() {this.y this.speed;if (this.y canvas.height) {this.y Math.random() * -canvas.height;this.x Math.random() * canvas.width;this.color # Math.floor(Math.random() * 16777215).toString(16);this.height Math.random() * 20 10;this.text str[strIndex];strIndex (strIndex 1) % str.length;}}draw() {ctx.fillStyle rgba(0, 0, 0, 0.1);ctx.fillRect(0, 0, canvas.width, canvas.height);ctx.fillStyle white;ctx.font this.height px Arial;ctx.fillText(this.text, this.x, this.y this.height);}
}let drops [];for (let i 0; i 100; i) {drops.push(new Drop());
}const animate () {drops.forEach((drop) {drop.update();drop.draw();});requestAnimationFrame(animate);
};animate();
后言 创作不易要是本文章对广大读者有那么一点点帮助 不妨三连支持一下您的鼓励就是博主创作的动力