Loading...
Logo
Processing Forum
Hello all...
I've noticed something odd. I have a sketch which uses noise() that I then map to the width and height of the display window. On Java Mode this works fine, and the co-ordinates move around the whole display.
However, when I switch to JavaScript mode, the values seem to constrain themselves to near the centre of the screen (or near the starting point) They don't drift near as much as in the Java mode.
Any ideas why this is happening?

Copy code
  1. float x,y,x2,y2,px,py;
  2. float nx,ny;
  3. color c;

  4. void setup(){
  5.   size(800,600);
  6.   colorMode(HSB);
  7.   background(0);
  8.   c = 255;
  9.   stroke(c,20);
  10.   nx = 0;
  11.   ny = 20000;
  12.   x = map(noise(nx),0,1,0,width); 
  13.   y = map(noise(ny),0,1,0,height);
  14.   px = x;
  15.   py = y;
  16. }

  17. void draw(){
  18.   x = map(noise(nx),0,1,0,width); 
  19.   y = map(noise(ny),0,1,0,height);
  20.     for(int i = 0;i<int(random(25,50));i++){
  21.     float d = random(360);
  22.     float r = radians(d);
  23.     float x2 = x + sin(r) * random(50);
  24.     float y2 = y + cos(r) * random(50);
  25.       stroke(c,20);
  26.       line(x,y,x2,y2);
  27.     }
  28.     stroke(c,200);
  29.     line(x,y,px,py);
  30.   nx+=0.01;
  31.   ny+=0.01;
  32.   px = x;
  33.   py = y;
  34. }

Replies(3)

i noticed this too when working on Daniel Shiffman's Nature of Code.

When to the pjs bug tracker and it's a known bug:


feel free to vote it up by stopping by and linking to this thread.  i'll make a mention too.
Ruboto, i've just read your post. 
I've just posted something very similar to your problem. My noise() values behave different in processing.js , they are closer to each other.
So maybe its a bug
" So maybe its a bug"
Well, that's what benj.n.sugar wrote, indeed...