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

124
Views
Clock loop numbers in canvas

Good evening.

Who can explain why, after canvas.translate(0, -canvasRadius * 0.8); we need to use canvas.rotate(-ang)?

I assume this is to "return" to the original 0 position. But it is not clear what the lines after it are for.

for (num = 1; num < 13; num++) {
    ang = (num * Math.PI) / 6;
    canvas.rotate(ang);
    canvas.translate(0, -canvasRadius * 0.8);
    canvas.rotate(-ang);
    canvas.fillText(num.toString(), 0, 0);
    canvas.rotate(ang);
    canvas.translate(0, canvasRadius * 0.8);
    canvas.rotate(-ang);
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looks like it rotates canvas so that the subsequent translate is at the correct point for the number. A rotation in the opposite direction makes sure that the subsequent fillText is the right way up.

The remaining rotations and translate reverse the previous operations and relocate back to the origin ready for the next iteration.

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!