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

227
Vistas
Perlin noise grid transformation question

Objective: Amend the compassGrid() function to create a grid of 25x25 lines of length stepSize. Make sure each compass is at the center of each tile. By default they should all be pointing up. You should use translate() to move to the center of each grid.

I've tried all kinds of stuff, but none of my attempts seem to reach the objective outlined above. Here’s my code:

var stepSize = 20;

function setup() {
  createCanvas(500, 500);
}
///////////////////////////////////////////////////////////////////////
function draw() {
  background(125);
  colorGrid();
  compassGrid();
}
///////////////////////////////////////////////////////////////////////
function colorGrid() {
  for (var x = 0; x < width; x += width / 25) {
    for (var y = 0; y < height; y += height / 25) {
      let from = color(255, 0, 0);
      let to = color(0, 255, 0);
      let interA = lerpColor(from, to, n);
      var n = noise(x / 50, y / 50, frameCount / 100);
      var c = map(n, 0, 1, 0, 255);
      fill(interA);
      stroke(c);
      rect(x, y, stepSize, stepSize);
    }
  }
}
///////////////////////////////////////////////////////////////////////
function compassGrid() {
  translate(10, 10);
  for (var x = 0; x < width; x += width / 25) {
    for (var y = 0; y < height; y += height / 25) {
      push();
      translate(x, y);
      stroke("black");
      line(0, 0, 0, stepSize - 5);
      pop();
    }
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.js"></script>

What's my mistake?

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