Simple Perlin noise random walk behavior in C++

We are trying to get this same random walk behaviour from the simple perlin noise random walk as in the p5.js sketch below. But for us in C++ with openFrameworks Perlin Noise we get a behaviour where the dot is always drifting to the center and not having these random rests at certain positions…

See this video for the behaviour we get with C++

Cheers!

let radiusSlider;
let speedSlider;
let smallCircleRadius = 12;
let noiseOffsetX = 0;
let noiseOffsetY = 10000;

function setup() {
  createCanvas(windowWidth, windowHeight);
  radiusSlider = createSlider(10, min(windowWidth, windowHeight) / 10, 90);
  radiusSlider.position(10, 10);
  speedSlider = createSlider(0.001, 0.1, 0.01, 0.001);
  speedSlider.position(10, 40);
}

function draw() {
  background(255);
  let radius = radiusSlider.value();
  let speed = speedSlider.value();
  
  stroke(0);
  strokeWeight(2);
  noFill();
  ellipse(width / 2, height / 2, radius * 2, radius * 2);

  let noiseX = noise(noiseOffsetX) * 2 - 1;
  let noiseY = noise(noiseOffsetY) * 2 - 1;
  
  let smallCircleX = width / 2 + noiseX * (radius - smallCircleRadius);
  let smallCircleY = height / 2 + noiseY * (radius - smallCircleRadius);
  
  fill(0);
  noStroke();
  ellipse(smallCircleX, smallCircleY, smallCircleRadius * 2, smallCircleRadius * 2);
  
  noiseOffsetX += speed;
  noiseOffsetY += speed;
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

Unable to view the video get the warning

No video with supported format and MIME type found

2 Likes