Advertisement
xeromino

fbm

Nov 6th, 2016
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. float nx, ny;
  2. float nStep = 0.007;
  3. float s1 = 1, s2 = 1;
  4. int h = 0, offSet = 100 ;
  5.  
  6. void setup() {
  7.   size(1000, 300);
  8.   //colorMode(HSB, 360, 100, 100);
  9.   fbm();
  10. }
  11.  
  12. void draw() {
  13. }
  14.  
  15. void fbm() {
  16.   nx = 0;
  17.   float c = 0;
  18. //  color to = color(#0A1A02);
  19. //  color from = color(#F8FAC2);
  20.   color to = color(#250846);
  21.   color from = color(#F8FAC2);
  22.   for (int x = 0; x<width; x++) {
  23.     ny = 0;
  24.     for (int y = 0; y<height; y++) {
  25.       float n = noise(nx, ny);
  26.       float f = n;
  27.       n*= s1;
  28.       float o = noise(nx+n, ny+n);
  29.       f += o;
  30.       o *= s2;
  31.       float p = noise(nx+o, ny+n);
  32.       f+=p;
  33.       c = map(f,0.5,2.5,0,255);
  34.       //c = map(f, 0.5, 3, 0,360);
  35.       //fill(c,255);
  36.      
  37.       float l = map(f,0.5,2.5,0,1);
  38.       color col = lerpColor(from, to,l);
  39.       fill(col,150);
  40.       noStroke();
  41.       rect(x, y, 1, 1);
  42.       ny += nStep;
  43.     }
  44.     nx+=nStep;
  45.   }
  46. }
  47.  
  48. void mouseReleased() {
  49.   noiseSeed((long)random(123456));
  50.   s1 = 1;
  51.   s2 = 1;
  52.   fbm();
  53. }
  54.  
  55. void keyPressed() {
  56.   if (key == CODED) {
  57.     if (keyCode == UP) {
  58.       saveFrame("image-###.png");
  59.       s1++;
  60.       s2++;
  61.     }
  62.     if (keyCode == DOWN) {
  63.       s1--;
  64.       s2--;
  65.     }    
  66.   fbm();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement