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

163
Visualizações
Multiple overlays, right-click save only save one

Newbie here, experimenting. I'm trying to create in html/javascript a single image by stacking randomly selected layers (see code below). However, when I right-click the image it only saves the top layer, not all layers. How do I fix this (a button would be possible if it does not use any libraries -same goes for screenshots)?

Many thanks in advance!

Skipper

//html
<div><div id="layers"></div>

<canvas id="canvas1"></canvas>

// script

//create and attach layer1 to body;
            var img = document.createElement('img');
            img.alt = "Layer1";
            img.src = layer1_array[getRandomInt(0,3)];
            img.setAttribute("id","myImg");
            img.style.decoding = "async";
            document.getElementById("layers").appendChild(img);


//create and attach layer1 to body;
            var img = document.createElement('img');
            img.alt = "Layer2";
            img.src = layer2_array[getRandomInt(0,3)];
            img.setAttribute("id","myImg");
            img.style.decoding = "async";
            document.getElementById("layers").appendChild(img);
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

(async () => {
    innerImage(0);
    innerImage(1);
    innerImage(2);
})()
about 4 years ago · Juan Pablo Isaza Relatório

0

<script>
    const canvas = document.querySelector('canvas');
    const ctx = canvas.getContext("2d");

    const arrayImage = ["./img/img1.png", "./img/img2.png", "./img/img3.png"];

    const innerImage = (index) => {
        const image = new Image(canvas.width, canvas.height);
        image.addEventListener("load", () => {
            ctx.drawImage(image, 0, 0);
        });
        image.src = arrayImage[index];
    };
    innerImage(0);
    innerImage(2);
    innerImage(1);


</script>
about 4 years ago · Juan Pablo Isaza Relatório
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