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

225
Views
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
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!