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

164
Views
Rotate of a specific element inside the canvas JS

is it possible that in this code

<canvas id="ctx" width="500" height="500" style="border:1px solid #000000;"></canvas>

<script>
setInterval(function() {
    testf();
},1000/25);

    var ctx = document.getElementById("ctx").getContext("2d");
    var img = new Image();
    img.src = 'C:/.../img/player.png';
    var img2 = new Image();
    img2.src = 'C:/.../img/player2.png';
 
// ctx.rotate(45 * Math.PI / 180);

function testf() {
        ctx.clearRect(0,0,500,500);
        ctx.rotate(5 * Math.PI / 180);
        ctx.drawImage(img,100,100);
        ctx.drawImage(img2,200,200);
    };
</script>

it was possible to rotate only player2, and not all elements of the canvas. Options, create another canvas, I am not satisfied. I would like to implement this through JS, for example img.rotate 5; or rotate(this.angle); but I don’t know how to write it correctly.

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