Программирование на jquery
Anonymous
Измените цвет фонового текста для холста [закрыто]
Сообщение
Anonymous » 06 окт 2025, 13:09
Я использую готовый сценарий:
https://codepen.io/koray-gen-/pen/ypwpkzj
Я хочу изменить цвет текста прокрутки в фоне кнопкой. Я редактирую функцию изменения цвета, но она не работает: < /p>
Код: Выделить всё
function draw(color) {
const ctx = document.querySelector("canvas").getContext("2d");
if (document.body.classList.contains("body-style-dark")) {
cbg_color = document.getElementById("canvas_matrix_bg").dataset.cbgd;
} else {
cbg_color = document.getElementById("canvas_matrix_bg").dataset.cbg;
}
if (cbg_color.length > 1) {
ctx.fillStyle = "rgba(" + hexToRgb(cbg_color).r + "," + hexToRgb(cbg_color).g + "," + hexToRgb(cbg_color).b + "," + "0.04)";
} else {
ctx.fillStyle = "rgba(0, 0, 0, 0.04)";
}
ctx.fillRect(0, 0, c.width, c.height);
if (document.body.classList.contains("body-style-dark")) {
ctx_color = document.getElementById("canvas_matrix").dataset.ctxd;
} else {
ctx_color = document.getElementById("canvas_matrix").dataset.ctx;
}
if (ctx_color.length > 1) {
ctx.fillStyle = ctx_color;
} else {
ctx.fillStyle = color;
}
ctx.font = font_size + "px arial";
for (var i = 0; i < drops.length; i++) {
var text = matrix[Math.floor(Math.random() * matrix.length)];
ctx.fillText(text, i * font_size, drops[i] * font_size);
if (drops[i] * font_size > c.height && Math.random() > 0.975)
drops[i] = 0;
drops[i]++;
}
}< /code>
Подробнее здесь: [url]https://stackoverflow.com/questions/79783226/change-background-text-color-for-canvas[/url]
1759745380
Anonymous
Я использую готовый сценарий: https://codepen.io/koray-gen-/pen/ypwpkzj Я хочу изменить цвет текста прокрутки в фоне кнопкой. Я редактирую функцию изменения цвета, но она не работает: < /p> [code]function draw(color) { const ctx = document.querySelector("canvas").getContext("2d"); if (document.body.classList.contains("body-style-dark")) { cbg_color = document.getElementById("canvas_matrix_bg").dataset.cbgd; } else { cbg_color = document.getElementById("canvas_matrix_bg").dataset.cbg; } if (cbg_color.length > 1) { ctx.fillStyle = "rgba(" + hexToRgb(cbg_color).r + "," + hexToRgb(cbg_color).g + "," + hexToRgb(cbg_color).b + "," + "0.04)"; } else { ctx.fillStyle = "rgba(0, 0, 0, 0.04)"; } ctx.fillRect(0, 0, c.width, c.height); if (document.body.classList.contains("body-style-dark")) { ctx_color = document.getElementById("canvas_matrix").dataset.ctxd; } else { ctx_color = document.getElementById("canvas_matrix").dataset.ctx; } if (ctx_color.length > 1) { ctx.fillStyle = ctx_color; } else { ctx.fillStyle = color; } ctx.font = font_size + "px arial"; for (var i = 0; i < drops.length; i++) { var text = matrix[Math.floor(Math.random() * matrix.length)]; ctx.fillText(text, i * font_size, drops[i] * font_size); if (drops[i] * font_size > c.height && Math.random() > 0.975) drops[i] = 0; drops[i]++; } }< /code> Подробнее здесь: [url]https://stackoverflow.com/questions/79783226/change-background-text-color-for-canvas[/url]