Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda