Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
How do I change the ctx.fillStyle when the url changes?

so I am experimenting with 2d drawings in Javascript and what I am trying to do is change the ctx.fillStyle (which is the drawing colour) and change it to another colour when the URL changes.

Any help would be greatly appreciated. Here is a part of my code:

The codepen link for the animation: https://codepen.io/LudovicTomlo/pen/PEWEwJ

    window.draw = setInterval(function() {
        ctx.fillStyle = "rgba(0, 0, 0, 0.1)";
        ctx.fillRect(0, 0, c.width, c.height);
        ctx.fillStyle = "#00ff00";
        ctx.font = font_size + "px Sawarabi Gothic";
    if(location.pathname.endsWith("/401?e=1")) {
            ctx.fillStyle = "rgba(0, 0, 0, 0.1)";
            ctx.fillRect(0, 0, c.width, c.height);
            ctx.fillStyle = "#ff0000";
            ctx.font = font_size + "px Sawarabi Gothic";
       } 
    for(var i = 0; i < rain.length; i++) {
        // random character from the set
        var text = chars[Math.floor(Math.random()*chars.length)];
        ctx.fillText(text, i*font_size, rain[i]*font_size);

        if(rain[i]*font_size > c.height && Math.random() > 0.975) {
            rain[i] = 0;
        }

        //incrementing Y coordinate
        rain[i]++;
    }
}, speed);

}

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda