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

261
Views
Cómo dibujar una imagen en lienzo con y y x según la posición fría

ingrese la descripción de la imagen aquí

 function drawImage() { var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); var image = document.getElementById("image"); ctx.drawImage(image, canvas.width / 2 - image.width / 2, canvas.height / 2 - image.height / 2 ); } var mousePosition; var offset = [0, 0]; var div; var isDown = false; div = document.getElementById('square'); document.body.appendChild(div); div.addEventListener('mousedown', function (e) { isDown = true; offset = [ div.offsetLeft - e.clientX, div.offsetTop - e.clientY ]; }, true); document.addEventListener('mouseup', function () { isDown = false; }, true); document.addEventListener('mousemove', function (event) { event.preventDefault(); if (isDown) { mousePosition = { x: event.clientX, y: event.clientY }; div.style.left = (mousePosition.x + offset[0]) + 'px'; div.style.top = (mousePosition.y + offset[1]) + 'px'; } }, true);

¿Cómo establecer la posición para que la parte de la imagen contenida en el cuadrado rojo se monte en el lienzo?

Este ejemplo x & y está configurado para estar en el medio, pero debería estar donde esté el elemento secundario (borde rojo), en relación con el elemento principal (borde naranja)

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!