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

134
Vistas
Drawing a Grid With Canvas / Line Width Creating Black Box

I'm trying to create a JS Function (nodeJS) that takes in width, height, padding (size of each square) and line width. I'd like to fit the grid perfectly into the provided width and height. Right now, it's not working.

When I put in the line width, it gives me a black box. When it's gone, it prints out a grid.

    let left = 0;
    let top = 0;
    let bottom = canvas.height;
    let right = canvas.width;

    ctx.lineWidth = lineWidth;
    ctx.beginPath();
    for (let x=left; x<right; x+=padding) {
        ctx.moveTo(x, top);
        ctx.lineTo(x, bottom);
    }

    for (let y=top; y<bottom; y+=padding) {
        ctx.moveTo(left, y);
        ctx.lineTo(right, y);
    }

    ctx.strokeStyle = "#000000";
    ctx.stroke();

Any help would be appreciated. Thanks.

about 4 years ago · Juan Pablo Isaza
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