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

129
Views
Moving canvas with translate() method

According to MDN documentation translate() method "moves the canvas and its origin" but the below code does not move the border of the canvas. If the translate() method moves the canvas shouldn't the border move as well?

<!DOCTYPE html>

<head>
    <title>Temp</title>
    <style>
        canvas {
            border: 1px solid black;
        }

        body {
            margin: 0;
        }
    </style>
</head>

<body>
    <canvas id="myCanvas"></canvas>
    <script>
        const canvas = document.getElementById("myCanvas")
        canvas.width = 300;
        canvas.height = 300;

        const ctx = canvas.getContext("2d");
        ctx.translate(canvas.width / 2, canvas.height / 2);
    </script>
</body>

</html>

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I don't quite understand what you are trying to do. If you want to offset your canva, why not just do this?

document.getElementById("myCanvas").style.transform = "translate(50%, 50%)";
about 4 years ago · Santiago Trujillo 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!