Creating an array of Perlin noise points
in
Programming Questions
•
11 months ago
edited for ease. No since in asking a complicated question when there is a simpler more fundamental problem embedded.
Start question...
I have adapted a perlin noise object off of openprocessing and wish to create an array of these objects. I have read multiple tutorials and seen may example, which I understand but when a go to apply there examples syntax it just doesnt work. How would I go about making lets say 100 of these perlin points?
Ultimately I hope to take this and apply it to text using geomerative, but this application can wait.
int elapsedFrames = 0;
ArrayList points = new ArrayList();
void setup() {
smooth();
size(600, 600);
background(255);
}
void draw() {
PVector pos = new PVector();
pos.x = width/2;
pos.y = height/2;
PVector vel = new PVector();
vel.x = (0);
vel.y = (0);
Point punt = new Point(pos, vel, 1000);
points.add(punt);
for (int i = 0; i < points.size(); i++) {
Point localPoint = (Point) points.get(i);
if (localPoint.isDead == true) {
points.remove(i);
}
localPoint.update();
localPoint.draw();
}
elapsedFrames++;
}
Point Class-------
class Point{
PVector pos, vel, noiseVec;
float noiseFloat, lifeTime, age;
boolean isDead;
Point(PVector _pos, PVector _vel, float _lifeTime){
pos = _pos;
vel = _vel;
lifeTime = _lifeTime;
age = 0;
isDead = false;
noiseVec = new PVector();
}
void update(){
noiseFloat = noise(pos.x * 0.0025, pos.y * 0.0025, elapsedFrames * 0.001);
noiseVec.x = cos(((noiseFloat -0.3) * TWO_PI) * 5);
noiseVec.y = sin(((noiseFloat - 0.3) * TWO_PI) * 5);
vel.add(noiseVec);
vel.div(2);
pos.add(vel);
if(1.0-(age/lifeTime) == 0){
isDead = true;
}
if(pos.x < 0 || pos.x > width || pos.y < 0 || pos.y > height){
isDead = true;
}
age++;
}
void draw(){
fill(0,5);
noStroke();
ellipse(pos.x, pos.y, 2-(age/lifeTime), 2-(age/lifeTime));
}
};
1