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

128
Views
Mirror a shape from HTML5 canvas using javascript

I have this shape that I have made on my HTML canvas, so basically what I want to do is that I want to mirror the shape and move it to a different part of the canvas. I have tried folds.scale(-1,1); but it does not work. I have viewed this other post about mirroring shapes but my code somehow doesn't work.

HTML Canvas: How to draw a flipped/mirrored image?

This is my code:

function folds(x, y ,z){
    draw.beginPath();
    draw.arc(x, y, z, 5.25, 2 * Math.PI);
    draw.closePath();
    draw.lineWidth = 7;
    draw.strokeStyle = "black";
    draw.stroke();
}

function folds2(){
    folds.scale(-1,1);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The most popular solution is to create another invisible canvas in your HTML and transform its horizontal dimensions backwards:

const flippedCanvas = document.getElementById("flipped-canvas");
const flippedContext = canvas.getContext("2d");

flippedContext.scale(-1, 1);

Then, you can draw an image (or shape) on that canvas and copy it to your original canvas using drawImage:

flippedContext.beginPath();
// ...
flippedContext.stroke();
draw.drawImage(flippedCanvas, 0, 0);
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!