<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with noiseseed() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=noiseseed%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:09:45 +0000</pubDate>
         <description>Tagged with noiseseed() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggednoiseseed%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How can a roguelike have so large maps?</title>
      <link>https://forum.processing.org/two/discussion/5985/how-can-a-roguelike-have-so-large-maps</link>
      <pubDate>Tue, 24 Jun 2014 06:10:55 +0000</pubDate>
      <dc:creator>Matyze</dc:creator>
      <guid isPermaLink="false">5985@/two/discussions</guid>
      <description><![CDATA[<p>I'm wondering how a roguelike can store HUGE maps (think Dwarf Fortress) without the speed of the program being affected much? Generating a world of, say, 1000x1000 tiles is incredibly tolling on my programs.</p>
]]></description>
   </item>
   <item>
      <title>Interactive fractal tree</title>
      <link>https://forum.processing.org/two/discussion/26813/interactive-fractal-tree</link>
      <pubDate>Tue, 13 Mar 2018 20:50:55 +0000</pubDate>
      <dc:creator>BjarkePedersen</dc:creator>
      <guid isPermaLink="false">26813@/two/discussions</guid>
      <description><![CDATA[<p>Yes, it's just a regular old fractal tree. But it's pretty :)</p>

<p>Try dragging it with your mouse</p>

<pre><code>int iterations = 14;
int treeSize = floor(pow(2, iterations)-1);
Branch[] tree = new Branch[treeSize];

float t, t2, colorT;

float angle = 45;
float startangle;
float startererangle = angle;

float wind = 1;
float startwind = wind;
float tempWind;

float r, g, b;
boolean mouseBegin = true;
PVector startMouse;
float tempAngle;

float friction = 0.98; // 0.95 for original
float tension = 0.03;  // 0.1 for original

PGraphics pg;

int noiseSeed1, noiseSeed2, noiseSeed3;

int cursorCount = 0;

void setup () {
  fill(0);
  //size(800, 800, P2D);
  fullScreen(OPENGL);
  pixelDensity(displayDensity());
  smooth(8);
  pg = createGraphics(width, height);

  for (int i=1; i&lt;treeSize; i++) {
    tree[i] = new Branch(new PVector(0,0),new PVector(0,0));
  }
  seed();
  plant();

  noiseSeed1 = day() + hour() + minute() + second();
  noiseSeed2 = int(noiseSeed1 * 1.41421356237);
  noiseSeed3 = int(noiseSeed2 * 3.14159265358);

}

void seed() {
  PVector dir = new PVector(0, -300);
  dir.rotate(rad(wind));

  PVector a = new PVector(width/2, height-100) ;
  PVector b = new PVector(width/2+dir.x, height+dir.y-100);
  tree[0] = new Branch(a, b);
}


void plant() {
  seed();

  for (int i=1; i&lt;treeSize; i++) {
    int n = floor((i-1)/2);
    if (i % 2 == 0) {
      tree[n].branch(-1, tree[i]);
    } else {
      tree[n].branch(1, tree[i]);
    }
  }
}

void physics() {
  wind = startwind*(cos(t))*-1;
  startwind *= friction;
  noiseSeed(1337);
  startwind += map(noise(t/51-100), 0, 1, -0.2, 0.2);
  t -= tension;

  angle = startererangle + startangle*(cos(t2));
  startangle *= friction;
  noiseSeed(42);
  startangle += map(noise(t2/50), 0, 1, -0.2, 0.2);
  t2 -= tension;
}

PVector prevMouse, mouse;

void mouse(){
  // Hide / show cursor
  prevMouse = mouse!=null ? mouse : new PVector(mouseX, mouseY);
  mouse = new PVector(mouseX, mouseY);
  cursorCount ++;
  if (mouse.x != prevMouse.x || mousePressed) {cursorCount = 0; cursor();};
  if (cursorCount &gt; 20) noCursor();

  if (!mousePressed) {
      physics();
      mouseBegin = true;
    } else {
      if (mouseBegin == true) {
        startMouse = new PVector(mouseX, mouseY);
        tempWind = wind;
        tempAngle = angle;
        mouseBegin = false;
      }
      wind = tempWind + map(mouseX-startMouse.x, -width, width, deg(-1), deg(1));
      startwind = abs(wind);
      t = abs((wind/abs(wind)+1)*PI/2);

      angle = abs(tempAngle + map(mouseY-startMouse.y, -height, height, deg(-1), deg(1)))+0.01;
      startangle = startererangle-angle;
      t2 = abs(((angle/abs(angle)+1))*PI/2);
    }
}

void draw() {
  //println(frameRate);
  mouse();
  plant();

  noiseSeed(noiseSeed1);
  float r = map(noise(colorT/50), 0, 1, 0, 255);
  noiseSeed(noiseSeed2);
  float g = map(noise(colorT/75), 0, 1, 0, 255);
  noiseSeed(noiseSeed3);
  float b = map(noise(colorT/100), 0, 1, 0, 255);
  colorT--;


  // Start drawing image
  background(25);

  stroke(r, g, b);
  fill(r, g, b);
  rect(width/2-20, height-100, 40, 20, 3, 3, 40, 40);

  int level = 1;

  for (int i=0; i&lt;treeSize; i++) {
    if ((i % (pow(2, level)-1)) == 0) {
      //if (level &gt; 6) strokeWeight(1);
      strokeWeight((iterations-level)/2);

      noiseSeed(noiseSeed1);
      r = map(noise(colorT/50+level*0.2), 0, 1, 0, 255);
      noiseSeed(noiseSeed2);
      g = map(noise(colorT/75+level*0.2), 0, 1, 0, 255);
      noiseSeed(noiseSeed3);
      b = map(noise(colorT/100+level*0.2), 0, 1, 0, 255);

      stroke(r, g, b);

      level++;
    }
    tree[i].show();
  }
}

public class Branch {
  PVector begin;
  PVector end;
  float rand;
  boolean finished = false;
  float rotation = 0;

  public Branch(PVector begin, PVector end) {
    this.begin = begin;
    this.end = end;
  }

  public void show() {
    line(this.begin.x, this.begin.y, this.end.x, this.end.y);
  }

  public void branch(int direction, Branch targetBranch) {
    PVector dir = new PVector(this.end.x-this.begin.x, this.end.y-this.begin.y);
    dir.rotate(rad(direction*angle+wind));
    dir.mult(0.6667);
    PVector newEnd = new PVector(this.end.x+dir.x, this.end.y+dir.y);
    targetBranch.begin = this.end;
    targetBranch.end = newEnd;
  }
}

static float rad(float deg) {
  return deg*PI/180;
}

static float deg(float rad) {
  return rad*180/PI;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Warping texture with an other texture</title>
      <link>https://forum.processing.org/two/discussion/24198/warping-texture-with-an-other-texture</link>
      <pubDate>Thu, 21 Sep 2017 12:45:58 +0000</pubDate>
      <dc:creator>Stanlepunk</dc:creator>
      <guid isPermaLink="false">24198@/two/discussions</guid>
      <description><![CDATA[<p>I try to warp an image with an other image but I don't find the way to do it. The idea at the end it's use the a stable fluid to warp the image. Here a little example to show the problem :
<a rel="nofollow" href="https://github.com/StanLepunK/Sketches/tree/master/BUG/warping_with_texture">link sketch problem</a></p>

<p><a rel="nofollow" href="https://github.com/StanLepunK/Sketches/tree/master/BUG/force_field">link project in problem version</a></p>

<p>So any idea are very very welcome !</p>

<p>shader frag</p>

<pre><code>/**
ROPE - Romanesco processing environment – 
* Copyleft (c) 2014-2017 
* Stan le Punk &gt; <a href="http://stanlepunk.xyz/" target="_blank" rel="nofollow">http://stanlepunk.xyz/</a>

Shader to warp texture

Render fluid
v 0.0.2
*/
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

#define PROCESSING_TEXTURE_SHADER

#define PI 3.1415926535897932384626433832795

varying vec4 vertTexCoord;
uniform sampler2D texture;

uniform int mode;
uniform float roof_component_colour;

uniform sampler2D vel_texture;
uniform sampler2D dir_texture;
uniform vec2 grid_wh;

float map(float value, float start1, float stop1, float start2, float stop2) {
  float result = start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
  return result;
}  
vec2 cartesian_coord(float angle) {
  float x = cos(angle);
  float y = sin(angle);
  return vec2(x,y);
}

void main() {

  vec2 ratio = gl_FragCoord.xy / grid_wh;
  // vec2 ratio = vertTexCoord.st / grid_wh;

  vec4 vel = texture2D(vel_texture, ratio);
  vec4 dir = texture2D(dir_texture, ratio);


  // rendering picture ;
  if(mode == 0 ) {

    float angle_rad = map(dir.x, 0, roof_component_colour, -PI, PI);
    vec2 dir_cart = cartesian_coord(angle_rad) ;

    // float gap = max(grid_wh.x, grid_wh.y);
    // vec2 translate_pix = dir_cart.xy *vel.x / gap;
    vec2 translate_pix = dir_cart.xy *vel.x ;

    vec2 coord_dest = vertTexCoord.st +translate_pix ;
    vec4 tex_colour = texture2D(texture, coord_dest);

    gl_FragColor = tex_colour;
  }
  // velocity
  if(mode == 1 ) {
    gl_FragColor = texture2D(vel_texture, vertTexCoord.st);;
  }
  // direction force field
  if(mode == 2) {
    gl_FragColor = texture2D(dir_texture, vertTexCoord.st);;
  }

}
</code></pre>

<p>Processing</p>

<pre><code>PImage tex_velocity, tex_direction ;
PShader warping;
PImage img ;
int grid_w, grid_h ;
void setup() {
  size(600,375,P2D);
  img = loadImage("pirate_small.jpg");
  grid_w = 60 ;
  grid_h = 37 ;
  tex_velocity = createImage(grid_w,grid_h,RGB);
  tex_direction = createImage(grid_w,grid_h,RGB);  
  warping = loadShader("shader/warp/rope_warp_fluid.glsl");
  noise_img(tex_velocity, 20, .1, .1); // max translate for the pixel
    noise_img(tex_direction, 360, .1, .1); // degree direction
}

void draw() {
    if(frameCount%60 == 0) {
        noise_img(tex_velocity, 20, .1, .1); // max translate for the pixel
        noise_img(tex_direction, 360, .1, .1); // degree direction
    }

    warping.set("mode", 0) ;
    warping.set("texture",img);
    warping.set("roof_component_colour",g.colorModeX);
    warping.set("grid_wh",grid_w,grid_h);

  warping.set("vel_texture",tex_velocity);
  warping.set("dir_texture",tex_direction);
  shader(warping);

  image(img,0,0);
  resetShader();
  image(tex_velocity,5,5);
  image(tex_direction,grid_w +15 ,5 );
}


float x_offset, y_offset ;
void noise_img(PImage dst, int max, float ratio_x, float ratio_y) {
    noiseSeed((int)random(10000));
    for(int x = 0 ; x &lt; dst.width ; x++) {
        x_offset += ratio_x ;
        for(int y = 0 ; y &lt; dst.height ; y++) {
            y_offset += ratio_y ;
            float v = map(noise(x_offset,y_offset),0,1,0,max);
            v = (int)map(v,0,max,0,g.colorModeX);
            int c = color(v,v,v,g.colorModeA) ;
            dst.set(x,y,c);
        }
    }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Why doesn't noise() function recalculate inside loops the same way random() does?</title>
      <link>https://forum.processing.org/two/discussion/22280/why-doesn-t-noise-function-recalculate-inside-loops-the-same-way-random-does</link>
      <pubDate>Sat, 29 Apr 2017 06:49:57 +0000</pubDate>
      <dc:creator>TonyRamirez</dc:creator>
      <guid isPermaLink="false">22280@/two/discussions</guid>
      <description><![CDATA[<p>If I you put x = random(y); into the draw() function, the function is recalculated for each frame while draw() runs. However x = noise(y); only seems to be calculated once each time the program is run. I checked this by printing the value of x in the console for each iteration of draw(). I don't understand how to use this function.</p>
]]></description>
   </item>
   <item>
      <title>How does noise remembers it's value.</title>
      <link>https://forum.processing.org/two/discussion/20607/how-does-noise-remembers-it-s-value</link>
      <pubDate>Thu, 02 Feb 2017 14:29:32 +0000</pubDate>
      <dc:creator>gperez</dc:creator>
      <guid isPermaLink="false">20607@/two/discussions</guid>
      <description><![CDATA[<p>I'm wondering why noise(0) will give me the same value everytime when I run my sketch. But it doesn't as soon as I run it again. Meaning, noise function must be storing my values somewhere. Is that true?</p>

<p>My tessting code is:</p>

<pre><code>float x;  
float y;

void setup() {
  size(800,600);  
  fill(255);
  noStroke();
  getRandom();
}  

void draw() {
  background(240,168,128);  
  ellipse(x, y, 20, 20);
}

void mouseClicked() {
  getRandom();
  println(x, y);
}

void getRandom() {
  x = noise(0) *200 + width/2;  
  y = noise(0) *200 + height/2; 
}
</code></pre>

<p>So, first time i run the sketh I get, let's say:</p>

<p>(565.2674, 465.2674)</p>

<p>And even clicking on screen the value stays the same. But as soon as I run the sketch again I get something else, like:</p>

<p>(494.57538, 394.57538)</p>

<p>Why is so?</p>
]]></description>
   </item>
   <item>
      <title>from processing to p5.js (conversion issue)</title>
      <link>https://forum.processing.org/two/discussion/14284/from-processing-to-p5-js-conversion-issue</link>
      <pubDate>Wed, 06 Jan 2016 02:02:41 +0000</pubDate>
      <dc:creator>faon</dc:creator>
      <guid isPermaLink="false">14284@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm trying to convert this code from processing on p5.js :</p>

<pre lang="javascript">
// *** Physical Map Generator (phmg_a2x1) by Atoro 
// *** Maps should look realistic with distinguishable geographic features, 
// *** such as mountains, valleys, lakes, seas, bays, peninsulas, etc.
// *** Whenever the keyboard button is pressed, the new map is generating.
color[] cp = {
  color(0, 126, 192), 
  color(24, 154, 208), 
  color(58, 168, 214), 
  color(94, 186, 220), 
  color(128, 199, 228), 
  color(163, 216, 235), 
  color(197, 229, 243), 
  color(232, 244, 250), 
  color(135, 209, 63), 
  color(203, 227, 107), 
  color(255, 227, 153), 
  color(255, 205, 127), 
  color(234, 136, 70), 
  color(209, 104, 47), 
  color(187, 76, 15), 
  color(148, 56, 0)
}; 
void setup() {
  size(1024, 768);
}
void draw() {
  noiseSeed(int(random(10000000))); 
  loadPixels(); 
  float d0 = random(100, 200);   
  float d1 = random(25, 75); 
  for (int j = 0; j &lt; height; j++) {
    for (int i = 0; i &lt; width; i++) {
      float n0 = noise(i/d0, j/d0, 0); 
      float n1 = noise(i/d1, j/d1, 10); 
      float n = 1 - (n0*0.75 + n1*0.25); 
      int k = int(n*cp.length); 
      pixels[j*width + i] = cp[k];
    }
  } 
  updatePixels();
  noLoop();
  // save("maps/Map_a2x1_ID" + int(random(10000000)) + ".png");
}
void keyPressed() {
  loop();
}
</pre>

<p>I wrote this :</p>

<pre lang="javascript">
var col = [],a,b,c,n0,n1,d0,d1,n,k ;


function preload() {
  background = loadImage("test.jpg");
}
function setup() {
  createCanvas(windowWidth, windowHeight);
  image(background, 0, 0,windowWidth,windowHeight);
  colorMode(RGB);
   alf = 128;
col [color(255,255,255,alf), color(197,193,185,alf),color(151,158,163,alf),color(87,103,116,alf),color(233,227,208,alf),color(200,170,111,alf),color(143,127,70,alf),color(86,95,37,200),color(47,66,16,200),color(8,8,56,200),color(255,255,255,0)];

  a=0;
  b=0;
}


function draw() {
   
 noiseSeed(int(random(10000000))); 
  loadPixels(); 
  d0 = random(100, 200);   
 d1 = random(25, 75); 
  for ( a = 0; b &lt; height; b++) {
    for ( a = 0; a &lt; width; b++) {
      n0 = noise(a/d0, b/d0, 0); 
      n1 = noise(a/d1, b/d1, 10); 
      n = 1 - (n0*0.75 + n1*0.25); 
      k = n*col.length; 
      pixels[b*width + a] = col[k];
    }
  } 
  updatePixels();
  noLoop();
  
}
</pre>

<p>The console shows nothing wrong but when I run the program, the window is frozen on the "loading" page and I have to force my computer to end the p5.js application.</p>

<p>Could you explain me why ?</p>

<p>I'm not a great programmer but I need to use this small part of code from processing in a bigger program that is in p5.js.</p>

<p>Thank you for your help</p>
]]></description>
   </item>
   <item>
      <title>Does noiseSeed work on JavaScript mode?</title>
      <link>https://forum.processing.org/two/discussion/8858/does-noiseseed-work-on-javascript-mode</link>
      <pubDate>Fri, 02 Jan 2015 12:40:37 +0000</pubDate>
      <dc:creator>BarbaraAlmeida</dc:creator>
      <guid isPermaLink="false">8858@/two/discussions</guid>
      <description><![CDATA[<p>I'm doing a sketch that generate patterns using noise and trigonometric equations. I change the noiseSeed when mouse is pressed, on Java mode each noiseSeed generates a different pattern.</p>

<p>On JavaScript mode, though, if I keep the same trigonometric equation, it will always generate the same pattern, independently of the noiseSeed.</p>

<p>I first thought that JavaScript doesn't allow changing noiseSeed while the sketch is running, but even setting the noiseSeed to a constant or not setting it and letting it be chosen randomly, it always generates the same pattern.</p>

<p>noiseSeed is documented on the Processing JS reference so I thought the pattern would change, even if noise doesn't look the same way on Java and JavaScript modes. Does anyone have an idea of why it isn't working?</p>

<p>Here a code example:</p>

<pre><code>int hue_;
int seed;

void setup()
{
  size(600, 600);
  colorMode(HSB);

  newPattern();  
}

void draw()
{  
  showPattern(); 
}


void mousePressed()
{
  newPattern();
}

void newPattern()  
{
  hue_ = (int) (random(255));  
  seed = (int) (random(10000));  
  noiseSeed(seed);
  println(seed);
}

void showPattern()
{
  loadPixels();
    float dx = 0;
    for(int x = 0; x &lt; width; x += 1)
    {
      float dy = 0;
      for(int y = 0; y &lt; height; y += 1)
      {
        float bright = noise(cos(dx), cos(dy));
        bright = map(bright, 0, 1, 0, 255);
        pixels[x + y*width] = color(hue_, 127, bright);
        dy += 0.02;
      }
      dx += 0.02;
    }
  updatePixels();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>1D array affecting 2D array</title>
      <link>https://forum.processing.org/two/discussion/6838/1d-array-affecting-2d-array</link>
      <pubDate>Wed, 20 Aug 2014 09:58:53 +0000</pubDate>
      <dc:creator>HowardCornwell</dc:creator>
      <guid isPermaLink="false">6838@/two/discussions</guid>
      <description><![CDATA[<p>I'm new to programming, and having trouble with a project.</p>

<p>Within an array of squares forming a grid, points passing through the individual squares are intended to change the square's colour (grid.highlight();). The x/y position of the points is used to determine wether they have passed through or not.</p>

<p>When a single point is used, the code works and the square it is passing through will change colour. I cannot, however, figure out how to make multiple points work.</p>

<pre><code>//Array of Boxes
Box[][] grid;
//Array of points
Point[] points;

void setup(){
  size(800,800);
  colorMode(HSB,360,100,100);

  //Initialise Points
  points = new Point[1]; //MORE THAN 1 DOES NOT WORK
  for (int i=0; i &lt; points.length; ++i){
    points[i] = new Point();
  }

  //Initialise Grid
  grid = new Box[20][20];
  for (int i=0; i&lt;grid.length; ++i){
    for (int j=0; j&lt;grid.length; ++j){
        grid[i][j] = new Box(i*(width/grid.length),
                             j*(width/grid.length),
                             (width/grid.length)-5);
          }
        }
}

void draw(){
  background(0);

  //Draw points
  for (int i=0; i&lt;points.length; ++i){
        points[i].move();
        points[i].colorcyc();
        points[i].display();
      }

  //Draw Grid
  for (int i=0; i&lt;grid.length; ++i){
    for (int j=0; j&lt;grid.length; ++j){

        //Check intersection -- PROBLEM ARISES HERE
        for (int k=0; k&lt;points.length; ++k){
            if (points[k].inside(grid[i][j])) {
              grid[i][j].highlight(points[k].col);
            } else {
              grid[i][j].highlight(0);
            }
          }

        //display grid
        grid[i][j].display();
      }
    }
}

//Individual box

class Box{
  float x,y,w;
  color c;

  Box (float x_, float y_, float w_) {
    x=x_; //X Location
    y=y_; //Y Location
    w=w_; //Size
  }

  //Color changer
  void highlight(color c_){
    c=c_;
  }


  void display() {
    stroke(255);
    fill(c);

    pushMatrix();
      translate(x,y);
      rect(0,0,w,w);
    popMatrix();
  }
}

// Random xy point

class Point{
  float x,y;
  float xoff;
  float yoff;
  float increment;

  int c;
  color col;

  Point(){
    x = width/2;
    y = height/2;

    xoff = random(10);
    yoff = random(10);
    increment = random(10)*0.01;
  }

  void move(){
        x += ( (noise(xoff)-0.5)*20 );
        y += ( (noise(yoff)-0.5)*20 );

        if (x &gt; width || x &lt; 0){
         x = width/2;
         y = height/2;
        }

        if (y &gt; height || y &lt; 0){
          x = width/2;
          y = height/2;
        }

        xoff += increment;
        yoff += increment;
  }

  //Cycle HSB colors
  void colorcyc(){
    c += 3;
        if (c &gt; 360){
          c = 0;
        }
    col = color(c,100,100);
  }

  void display(){
        noStroke();
        fill(col);

        ellipse(x,y,12,12);
  }

  //check if inside a box
  boolean inside(Box b) {
    if (x &gt; b.x &amp;&amp; x &lt; (b.x + b.w) &amp;&amp;
        y &gt; b.y &amp;&amp; y &lt; (b.y + b.w)) {
      return true;
    } else {
      return false;
    }
  }
}
</code></pre>

<p>The point.inside(grid[i][j]) call works for an array of 1 point, but not for multiple. Any help would be appreciated!</p>
]]></description>
   </item>
   </channel>
</rss>