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

161
Views
¿Qué me estoy perdiendo al poner una imagen en este lienzo?

Estoy tratando de dibujar en un lienzo a partir de una matriz de matrices que inicialmente debería ser gris #808080 . Ninguna de las permutaciones que estoy intentando está cambiando, tengo un lienzo de pantalla completa que es completamente blanco.

Creo que me he saltado algún paso básico al pasar de un imageData a un rectángulo gris dibujado en la pantalla.

¿Qué me estoy perdiendo o he hecho mal?

Gracias,

 ;(function() { var context = null; var grid = []; var height = null; var image_data = null; var width = null; var draw = function() { var data = image_data.data; for (var index = 0; index < data.length; index += 4) { var x = Math.floor(Math.floor(index / 4) / width); var y = Math.floor(Math.floor(index / 4) * width); data[index] = grid[x][y][0]; data[index + 1] = grid[x][y][1]; data[index + 2] = grid[x][y][2]; } image_data.data = data; context.putImageData(image_data, 0, 0); } var init = function() { height = jQuery(window).height(); width = jQuery(window).width(); jQuery('#container').html('<canvas id="map" height="' + height + '" width="' + width + '"></canvas>') context = document.getElementById('map').getContext('2d'); image_data = context.getImageData(0, 0, width, height); for (var outer = 0; outer < width; outer += 1) { grid[outer] = []; for (var inner = 0; inner < height; inner += 1) { grid[outer][inner] = [128, 128, 128]; } } } var start_drawing = function() { draw(); setTimeout(start_drawing, 1); }; init(); start_drawing(); })();
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <div id="container"></div>

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!