/
cto_ego
/
website
Обзор
Документация
Войти
/
cto_ego
/
website
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
mod/update.js
86 строк
4 KB
cto_ego
Create: styles.css, bugs.md, changelog.md, handbook.html, img_1.png, config.js, draw.js, formula.js, logger.js, mathf.js, matrixControllerState.js, matrixData.js, save.js, ui.js, update.js, index.html, index.js
23 июн 2026, 21:22
Верифицирован
23 июн 2026, 21:22
6eab19d
Код
Авторство
О чём код?
class Update { constructor(data, draw) { this.data = data; this.draw = draw; this.delta = 0; this.data.columns = this.draw.canvas.width / this.data.fontSize; this.updateSize(); this.updateDrops(); }; updateDrops() { const newLength = Math.ceil(this.data.columns); this.data.drops = new Array(newLength); for (let i = 0; i < newLength; i++) { this.data.drops[i] = 1; }; }; updateSize() { this.draw.canvas.width = window.innerWidth; this.draw.canvas.height = window.innerHeight; this.fillcolumns(); this.updateDrops(); window.mathf.newSize(); Logger.debug(`New size: ${this.draw.canvas.width}x${this.draw.canvas.height}, columns: ${this.data.columns}`); this.data.ages = new Array(Math.ceil(this.data.columns)).fill(0); }; changeDirection(newDirection) { this.data.way = newDirection; this.fillcolumns(); // Сброс позиций при смене направления }; /** * запоняет или очищает массив drops при изменении размера экрана * @returns */ fillcolumns () { this.fillColumnsUpdate(); draw.updateCache(); if (this.data.mode_matrix == 'find') { this.data.charArray_my = centerText(this.data.cacheText[0], this.data.cacheText[1], this.data.columns); } ; }; fillColumnsUpdate () { switch(this.data.way) { case 'up': case 'down': this.data.columns = this.draw.canvas.width / this.data.fontSize for(let i = 0; i < this.data.drops.length; i++) { this.data.drops[i] = Math.floor(Math.random() * this.data.columns); } if (this.data.drops.length < this.data.columns) { for(let i = this.data.drops.length; i < this.data.columns; i++) { this.data.drops.push(Math.floor(Math.random() * this.draw.canvas.width)); }; } else if (this.data.drops.length > this.data.columns) { for(let i = this.data.columns; i < this.data.drops.length; i++) { this.data.drops.pop(); }; }; break; case 'left': case 'right': this.data.columns = this.draw.canvas.height / this.data.fontSize for(let i = 0; i < this.data.drops.length; i++) { this.data.drops[i] = Math.floor(Math.random() * this.data.columns); }; if (this.data.drops.length < this.data.columns) { for(let i = this.data.drops.length; i < this.data.columns; i++) { this.data.drops.push(Math.floor(Math.random() * (this.draw.canvas.height) )); }; } else if (this.data.drops.length > this.data.columns) { for(let i = this.data.columns; i < this.data.drops.length; i++) { this.data.drops.pop(); }; }; break; default: Logger.error("Error fillColumnsUpdate: I don't found this way", {way: this.data.way}); }; }; }; window.update = new Update(data, draw);