Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark theme not working properly #2

Closed
codenashwan opened this issue Jul 28, 2023 · 2 comments
Closed

Dark theme not working properly #2

codenashwan opened this issue Jul 28, 2023 · 2 comments

Comments

@codenashwan
Copy link

codenashwan commented Jul 28, 2023

When I change the theme to dark, the cmatrix behavior is not working as expected. The matrix is not displayed correctly with the dark theme.

Html

<canvas id="matrix"></canvas>

Javascript

import matrix from "cmatrix/dist/matrix";


var canvas = document.getElementById("matrix");
var someFunction = function (event) {
    //clear canvas before drawing
    canvas.getContext("2d").clearRect(0, 0, canvas.width, canvas.height);

    matrix(canvas, {
        chars: ["0", "1"],
        color: localStorage.getItem("theme") === "dark" ? "#0F0" : "#000",
        background:
            localStorage.getItem("theme") === "dark"
                ? "rgba(51, 65, 84, 0.09)"
                : "rgba(255,255,255, 0.05)",
        exit: true,
        font_size: 20,
    });
};
window.addEventListener("theme", someFunction, false);

Untitled3.1.mp4
@jcubic
Copy link
Owner

jcubic commented Jul 28, 2023

The problem is that you execute matrix multiple times. You need a way to destroy/stop old code before running it again.

@jcubic
Copy link
Owner

jcubic commented Jul 28, 2023

It should be fixed now, can you confirm?

@jcubic jcubic closed this as completed Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants