Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
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 answers
Answer question

0

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

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!