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

244
Visualizações
How do I create a random hue overlay in JavaScript?

I'm currently working on a random image generator, which combines different .png files (attributes) into one image. I have managed to get these working, however there's one part I want for my project that I haven't been able to find out how to do.

I realise there are ways to do this in CSS and HTML, however neither of these suffice for what I need. The character is generated in the JavaScript portion of my code, and thus for it to work I need JavaScript.

Here's an example of a piece of code in JavaScript that generates one of the body parts. In this case, it's the body.

        //body
    var characterbody = new Image();
    var characterbodynum=Math.floor(Math.random()*4)+1; 
    var characterbodyname="body" + characterbodynum + ".png";
    characterbody.src=characterbodyname;

To explain this code: The first line indicates an image. The second line indicates to the computer that there are four images, and one should be randomly selected. The third line indicates based on files saved to my computer it needs to find a file named "body", followed by a number, and then .png on the end. For example, if the random whole number between 1 and 4 chooses the number 3, it picks body3.png and places that .png file into the overall image.

What I want now is an overlay to be added which will randomly select a hue value and shift the hue of the picture that amount. Preferably, I'd like it to work like the code above somewhat so it will be easy to implement into my code.

I'm guessing, but I could be wrong, is the style.filter the right code to use to do this?

about 4 years ago · Juan Pablo Isaza
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