Okay, sorry to hear you're having problems, but there're a few things to say about this:
First off, the NullPointer exception is thrown because you don't actually create an instance of the PerlinNoise class. In the above code you only declare variables for each type, but in order to use them correctly you should have looked at the Javadocs first ;)
Also, SimplexNoise is currently implemented as static class, so declaring a variable for it is meaningless since you'd use it like this:
Code:float val=(float)SimplexNoise.noise(x,y,z);
For SimplexNoise, please also note that currently only the 3D version works as expected and the 2D and 4D variants have weird artifacts. This is a known issue and I'll look into it when I can...
SimplexNoise currently also still returns results as
double only, so you need to cast it back into a float. And, if you'd have read the javadocs you would have seen that SimplexNoise values come in the -1...+1 range, so turning it into a grayscale pixel value needs a tiny bit more work than just multiplying with 255 (see the fixed code below)
PerlinNoise is currently the exact same implementation as in Processing and is only there for non-Processing projects (this is because all my libraries have
no dependency on Processing). But for completeness here, you'll have to create an instance of the class first before using it. So you'd have to replace the line with:
Code:PerlinNoise pn=new PerlinNoise();
Last but not least, judging by the reference to the "frameCount" variable in your code I assume you wanted to see this animated. However, then your code is missing the draw() function necessary...
Code:import toxi.math.noise.*;
//SimplexNoise sn; // removed, since obsolete
PerlinNoise pn=new PerlinNoise();
int x=0;
float NS=0.01;
void setup() {
size(200,200);
background(255);
}
void draw() {
color c=0;
for(int i = 0; i< width; i++){
for(int j = 0; j< height; j++){
// built-in perlin noise
//c = int(noise(i*.05,j*.05)*255);
// simplex noise with scaling adjusted
c = int((float)SimplexNoise.noise(i*NS,frameCount*NS,j*NS)*127+128);
// perlin noise as lib
// (currently the same as built-in, but will be replaced with different algorithm soon)
//c = int(pn.noise(i*NS,frameCount*NS,j*NS)*255);
stroke(c);
point(i,j);
}
}
}
Hope that helps!