js实现文字变换排列动画效果代码
代码语言:html
所属分类:动画
代码描述:js实现文字变换排列动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { padding: 0; margin: 0; user-select: none; } </style> </head> <body> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script> <script> const getRandomNumber = function (min, max) { return Math.floor(Math.random() * (max - min + 1) + min); }; /** * Time class */ class Time { constructor(sketch) { this.sketch = sketch; this.initialize(); } initialize() { const time = Date.now(); //this.setupCanvas(); this.startTime = time; this.lastTime = time; } setupCanvas() { document. getElementsByTagName("body")[0]. appendChild(document.createElement("canvas")); this.canvas = document.getElementsByTagName('canvas')[1]; this.ctx = this.canvas.getContext('2d'); this.ctx.font = '16px sans-serif'; const metrics = this.ctx.measureText('000 FPS'); this.width = this.canvas.width = metrics.width; this.height = this.canvas.height = 16; this.canvas.style.position = 'fixed'; this.canvas.style.zIndex = '9999'; this.canvas.style.background = 'black'; this.canvas.style.display = 'block'; this.canvas.style.bottom = '0'; this.canvas.style.right = '0'; } calculateTime() { const time = Date.now(); this.elapsedTime = time - this.startTime; this.fps = 1000 / (time - this.lastTime); this.lastTime = time; } drawFPS() { const ctx = this.ctx; ctx.clearRect(0, 0, this.width, this.height); ctx.save(); ctx.fillStyle = 'rgb(2, 230, 231)&.........完整代码请登录后点击上方下载按钮下载查看
网友评论0