<?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 noise() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=noise%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:50:37 +0000</pubDate>
         <description>Tagged with noise() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggednoise%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>How to switch from one text (using Geomerative) to an other according to a changing duration timer?!</title>
      <link>https://forum.processing.org/two/discussion/28062/how-to-switch-from-one-text-using-geomerative-to-an-other-according-to-a-changing-duration-timer</link>
      <pubDate>Tue, 19 Jun 2018 08:46:44 +0000</pubDate>
      <dc:creator>lolonulu</dc:creator>
      <guid isPermaLink="false">28062@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I asked a very close question brillantly answered by <a href="/two/profile/jeremydouglas">@jeremydouglas</a> few time ago, now I'd like to have a different duration for each text. In the sketch below the changePhraseTimer() works, but not the changePhraseTimerN(), we don't see the last text and it doesn't loop properly. Could someone help me with this issue please ?!
Thanks a lot in advance. L</p>

<pre><code>import generativedesign.*;
import geomerative.*;
// List of a list of points. 1rst the numbre of phrases: 4,  the 2nd indicate the number of points
RPoint[][] myPoints = new RPoint[5][0];
RFont font;
PFont f;
Attractor attractor;

String [][] phraseSets = new String [4][0];
String [] FR1 = {
  "On me dit de te haïr et je m'y efforce", 
  "Je t'imagine cruel, violent, implacable", 
  "Mais à te voir je n'ai bientôt plus de force", 
  "Et de te blesser je suis bien incapable", 
};
String [] FR2 = {
  "Tous mes camarades combattent avec rage", 
  "Et pleurent la nuit au souvenir des supplices", 
  "Infligés à leurs frères qui sont du même âge", 
  "Et rêvent comme eux de toucher une peau lisse"
};
String [] FR3 =
  {"Et de pouvoir enfin caresser des obus", 
  "Autres que ceux produits par le pouvoir obtus", 
  "Je rêve de quitter ces boyaux infernaux"
};
String [] FR4 = {
  "De laisser ces furieux des deux bords du Rhin", 
  "Et de pouvoir embrasser ta chute de rein", 
  "Et porter notre amour sur les fonts baptismaux"
};

//TEXT
final color textColor = color(245);
int fontSize;

// TIME
int startTime;
int initTime;
int lineSpacing;
int index;
int state;
float duration;
int dur1;

//----------------SETUP---------------------------------------------------------------------------------------

void setup() {
  size(1920, 1080, JAVA2D);
  //add phrases to list
  phraseSets[0]=FR1;
  phraseSets[1]=FR2;
  phraseSets[2]=FR3;
  phraseSets[3]=FR4;

  smooth();
  RG.init(this);
  font = new RFont("FreeSans.ttf", 86, CENTER);
  stroke(textColor);
  strokeWeight(0.05);
  //INIT
  drawPhrases(phraseSets[0]);

   // TIME
  startTime=millis();
  initTime=millis();
  index=0;
  lineSpacing =150;
}

//----------------DRAW----------------------------------------------------------------------------------

void draw() {
  background(255);
  state =0;


  // TEXTS
  // draw on the center of the screen
  translate(width/2, height/2);
  // draw phrases vertically centered by moving the top up by half the line spaces
  translate(0, -1.0*lineSpacing*(phraseSets[index].length-1)/2.0);
  // loop through lines
  for (int i=0; i&lt; myPoints.length; i++) {
    // draw a line
    for (int j=0; j&lt; myPoints[i].length-1; j++) {
      pushMatrix(); 
      translate(myPoints[i][j].x, myPoints[i][j].y);
      noFill();
      stroke(0, 200);
      strokeWeight(0.25);
      float angle = TWO_PI*10;
      rotate(j/angle);
      bezier(-2*(noise(10)), 10, 25*(noise(10)), -5, 2*noise(5), -15, 10, -3);
      //bezier(-10*(noise(20))+mouseX/15, 30+mouseY/10, -10*(noise(10))+mouseX/15, 20+mouseY/15, -20*noise(20)+mouseX/15, -20+mouseY/5, 10+mouseX/15, -10+mouseY/15);
      popMatrix();
    }
    // move to the next line
    translate(0, lineSpacing);
  }
  //check Timer and redraw phrases if time has passed

  changePhraseTimerN();
  //changePhraseTimer(duration*4, phraseSets);

}

//----------------INITIALIZE----------------------------------------------------------------------------------------------------------------------------------------
void drawPhrases(String [] phrases) {
  myPoints = new RPoint[phrases.length][0];
  for (int j=0; j&lt;phrases.length; j++) {
    RGroup myGroup = font.toGroup(phrases[j]);
    myGroup = myGroup.toPolygonGroup();
    myPoints[j] = myGroup.getPoints();
  }
}

//----------------TIMER----------------------------------------------------------------------------------------------------------------------------------------

/*void changePhraseTimer( float duration, String [][] phraseSets) {
 duration = sounds[0].length()-150;
 if (millis()-startTime &gt; duration*4) {
 index =(index+1) % phraseSets.length; 
 //drawPhrases(phraseSets[index]);
 //startTime = millis();
 }
 }*/

void changePhraseTimerN() {
  dur1=11500;

  if (millis()-startTime &gt; dur1+1400) {
    index =(index+1) % phraseSets[1].length; 
    drawPhrases(phraseSets[index]);
    startTime= millis();
  } else if (millis()-startTime &gt; dur1-800) {
    index =(index+1) % phraseSets[2].length; 
    drawPhrases(phraseSets[index]);
    startTime= millis();
  } else if (millis()-startTime &gt; dur1+1000) {
    index =(index+1) % phraseSets[3].length; 
    drawPhrases(phraseSets[index]);
    startTime= millis();
  } else if (millis()-startTime &gt; dur1*2-8000) {
    drawPhrases(phraseSets[0]);
    startTime= millis();
  }
}


//----------------TEXT ATTRACTOR INIT----------------------------------------------------------------------------------------------------------------------------------------
void initAttractor(int i) {
  if (i&gt;=4 &amp;&amp; i&lt;8) {
    i-=4;
  } else if (i&gt;=8 &amp;&amp; i&lt;11) {
    i-=8;
  } else if (i&gt;=11 &amp;&amp; i&lt;14) { 
    i-=11;
  } else if (i&gt;14) {
    i=0;
  }

  float x = 0;
  float y =-50; 
  // println(i); 
  attractor = new Attractor(x, y, myPoints[i]);
}


class Attractor {

  float force_radious = 100;
  float maxForce = 15;
  RPoint position;
  RPoint[] points;

  Attractor(float x, float y, RPoint[] p) {
    points = p;
    position = new RPoint(x, y);
  }

  void attract() {

    for (int i =0; i &lt; points.length; i++) {

      float d= points[i].dist(position);
     // println ("d : "+d);
      if (d &lt; force_radious) {   
        RPoint desired = new RPoint(points[i]);
        //points[i]= new RPoint(points[i]);
        //println( "avant x : "+ points[i].x +" y: "+points[i].y);
        desired.sub(position);
        desired.normalize();
        desired.scale(map(d, 0, force_radious, maxForce, 0));
        points[i].add(desired);
         //println( "après x : "+ points[i].x +" y: "+points[i].y);
      }
    }
  }
  void display () {
    stroke(0);
   strokeWeight(2);
  // ellipse (position.x, position.y-750, 30, 30);
  }
  void moveTo(float x, float y){
    position.x=x;
    position.y=y;

  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to save a PDF on key press from a 3D scene in this example?</title>
      <link>https://forum.processing.org/two/discussion/27992/how-to-save-a-pdf-on-key-press-from-a-3d-scene-in-this-example</link>
      <pubDate>Thu, 17 May 2018 14:22:33 +0000</pubDate>
      <dc:creator>Urahara</dc:creator>
      <guid isPermaLink="false">27992@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to add code for saving PDFs on key press, what is the correct way of doing it? 
Currently saving code doesn't work:</p>

<pre><code>`
//Stuff for saving stage
import processing.pdf.*;
boolean record = false;


int cols, rows;
int scl = 20;
int w = 2000;
int h = 1600;


float flying = 0;

float[][] terrain;

void setup() {
  size(600, 600, P3D);
  cols = w / scl;
  rows = h/ scl;
  terrain = new float[cols][rows];
}

void draw() {
  flying -= 0.1;


  float yoff = flying;
  for (int y = 0; y &lt; rows; y++) {
    float xoff = 0;
    for (int x = 0; x &lt; cols; x++) {
      terrain[x][y] = map(noise(xoff, yoff), 0, 1, 0,100);
      xoff += 0.2;
    }
    yoff += 0.2;
  }



  background(220);
  stroke(255);
  noFill();

  translate(width/2, height/2+50);
  rotateX(PI/3);
  translate(-w/2, -h/2);
  for (int y = 0; y &lt; rows-1; y++) {
    beginShape(TRIANGLE_STRIP);
    for (int x = 0; x &lt; cols; x++) {
      vertex(x*scl, y*scl, terrain[x][y]);
      vertex(x*scl, (y+1)*scl, terrain[x][y+1]);
    }
    endShape();
  }
}


// Trying to save a PDF
void draw() {
  PGraphics tmp = null;

  if (record) {
    tmp = beginRecord(PDF, "render-######.pdf");
  }

  if (tmp == null) {
    H.drawStage();
  } else {
    PGraphics g = tmp;
    boolean uses3D = false;
    float alpha = 1;
    H.stage().paintAll(g, uses3D, alpha);
  }

  if (record) {
    endRecord();
    record = false;
  }
}

void keyPressed() {
  if (key == 's') {
    record = true;
    draw();
  }
}
`
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to correctly apply Perlin noise to a sphere ?</title>
      <link>https://forum.processing.org/two/discussion/26718/how-to-correctly-apply-perlin-noise-to-a-sphere</link>
      <pubDate>Thu, 08 Mar 2018 17:15:49 +0000</pubDate>
      <dc:creator>solub</dc:creator>
      <guid isPermaLink="false">26718@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm trying to add Perlin noise to an icoSphere (icosahedron / geodesic sphere) but for some reason the terrain (noise) generated is too "homogeneous":  "peaks" are allocated almost evenly and heights (vertices heights) don't vary much.</p>

<p><img src="https://i.imgur.com/rvdUSpa.png" alt="" /></p>

<p>Ideally I'd like to be able to adjust the noise so as to get real random values (heterogeneous distribution and heights) like in the following pictures.</p>

<p><img src="https://i.imgur.com/AepUCem.png" alt="" /> <img src="https://i.imgur.com/EWbOdlB.png" alt="" /></p>

<p>The vertices positions are stored in array list (here named "knots") and all I do is adding a variable (named "r") to the x, y, z position of each vertex:</p>

<pre><code>for e in knots:
        r = noise(random(1))
        for i, f in enumerate(e):
            particles[e[i]] = Particle(particles[e[i]].x() + particles[e[i]].x() * r  , particles[e[i]].y() + particles[e[i]].y() * r, particles[e[i]].z() + particles[e[i]].z() * r)
</code></pre>

<p>I guess this is not an appropriate way to apply Perlin noise and would love some help to tweak the snippet above.
Any tip, idea, code (<strong>both Java or Python</strong>) is welcomed !</p>

<p>EDIT: This question is a "programming question". Even though the code is in Python, the question is about Perlin noise programmation. Answers or suggestions in Java are totally fine !</p>

<p>full code:</p>

<pre><code>add_library('peasycam')
from particle import Particle

def setup():
    global ICOSUBDIVISION, vdata, tindices,  particles
    size(800, 600, OPENGL)
    smooth(10)

    cam = PeasyCam(this, 450)


    particles = []
    ICOSUBDIVISION = 0
    X, Z = 0.525731112119133606, 0.850650808352039932
    vdata = [[-X, 0, Z], [X, 0, Z], [-X, 0, -Z], 
             [X, 0, -Z], [0, Z, X], [0, Z, -X], 
             [0, -Z, X], [0, -Z, -X], [Z, X, 0], 
             [-Z, X, 0], [Z, -X, 0], [-Z, -X, 0]]
    tindices = [[0, 4, 1], [0, 9, 4], [9, 5, 4], [4, 5, 8],
                [4, 8, 1], [8, 10, 1], [8, 3, 10], [5, 3, 8],
                [5, 2, 3], [2, 7, 3], [7, 10, 3], [7, 6, 10],
                [7, 11, 6], [11, 0, 6], [ 0, 1, 6], [ 6, 1, 10],
                [ 9, 0, 11], [ 9, 11, 2], [ 9, 2, 5], [ 7, 2, 11 ]]

    Icosahedron()

def draw():
    background(360)
    lights()

    f1, f2, f3 = PVector(), PVector(), PVector()

    for e in range(0, len(particles), 3):
        f1.x, f1.y, f1.z = particles[e].x(), particles[e].y(), particles[e].z()
        f2.x, f2.y, f2.z = particles[e+1].x(), particles[e+1].y(), particles[e+1].z()
        f3.x, f3.y, f3.z = particles[e+2].x(), particles[e+2].y(), particles[e+2].z()

        noStroke()
        colorMode(HSB, 360, 105, 100)
        fill(abs(f1.x), abs(f1.y), abs(f1.z))
        beginShape()
        vertex( f1.x, f1.y, f1.z )
        vertex( f2.x, f2.y, f2.z )
        vertex( f3.x, f3.y, f3.z )
        endShape( CLOSE )

def keyPressed():
    global ICOSUBDIVISION, particles
    if keyCode == UP:
        if ICOSUBDIVISION == 5:
            return 
        ICOSUBDIVISION += 1
        particles = []
        Icosahedron()
    elif keyCode == DOWN:
        if ICOSUBDIVISION == 0:
            return
        ICOSUBDIVISION -= 1
        particles = []
        Icosahedron() 

def Icosahedron():
    global vertexList

    vertexList =  []

    [subdivide(vdata[tindices[e][0]], vdata[tindices[e][1]], vdata[tindices[e][2]], ICOSUBDIVISION) for e in range(20)]

    for e in range(0, len(vertexList), 3):
        x, y, z = 0, 1, 2
        p = Particle(vertexList[e+x]* 200, vertexList[e+y]* 200, vertexList[e+z]* 200)
        particles.append(p)

    VertPos = set(particles)
    knots = [[] for e in VertPos]

    for i, v in enumerate(VertPos):
        for j, p in enumerate(particles):
            if p == v:
                knots[i].append(j)

    for e in knots:
        r = noise(random(1))
        for i, f in enumerate(e):
            particles[e[i]] = Particle(particles[e[i]].x() + particles[e[i]].x() * r  , particles[e[i]].y() + particles[e[i]].y() * r, particles[e[i]].z() + particles[e[i]].z() * r)

def norme(v):
    ln = 0
    for e in range(3):
        ln += (v[e] * v[e])

    ln = sqrt(ln)
    for e in range(3):
        v[e] /= ln

def addi(v):
    for e in range(3):
        vertexList.append(v[e])

def subdivide(v1, v2, v3, depth):
    if depth == 0:
        addi(v1)
        addi(v2)
        addi(v3)
        return

    v12, v23, v31 = [0,0,0], [0,0,0], [0,0,0]

    for e in range(3):
        v12[e] = (v1[e] + v2[e]) / 2
        v23[e] = (v2[e] + v3[e]) / 2
        v31[e] = (v3[e] + v1[e]) / 2

    norme(v12)
    norme(v23)
    norme(v31)

    subdivide(v1, v12, v31, depth - 1)
    subdivide(v2, v23, v12, depth - 1)
    subdivide(v3, v31, v23, depth - 1)
subdivide(v12, v23, v31, depth - 1)
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to control tint of image in Processing with audio output volume</title>
      <link>https://forum.processing.org/two/discussion/17803/how-to-control-tint-of-image-in-processing-with-audio-output-volume</link>
      <pubDate>Tue, 09 Aug 2016 21:18:54 +0000</pubDate>
      <dc:creator>elf</dc:creator>
      <guid isPermaLink="false">17803@/two/discussions</guid>
      <description><![CDATA[<p>Ok, so I'd like to project a few pictures to the wall. I'd like the tint to change gradually, depending on the volume of audio output. 
The audio is coming from audio samples (so not MIDI instruments, if that makes any difference) in Ableton Live Suite, which I'm controlling in real-time.
Any codes/links would be super helpful - stressed postgrad student :)
Thank you!</p>
]]></description>
   </item>
   <item>
      <title>How do I make one perlin noise wave join another one underneath it, using points?</title>
      <link>https://forum.processing.org/two/discussion/27902/how-do-i-make-one-perlin-noise-wave-join-another-one-underneath-it-using-points</link>
      <pubDate>Wed, 02 May 2018 11:57:27 +0000</pubDate>
      <dc:creator>rimai</dc:creator>
      <guid isPermaLink="false">27902@/two/discussions</guid>
      <description><![CDATA[<p>So I have a noise wave, and I have used a for loop to make points that travel under it, and I want them to stop at another perlin noise wave. Btw my code is really bad because I'm just a beginner :'(</p>

<p>This is my code:</p>

<pre><code>float inc = 0.04;

void setup() {
  size(640, 500);
}

void draw() {
  background(255);

  float xoff=0;
  float xoff2=0;

  xoff2 += inc;

  stroke(245, 10, 100);
  strokeWeight(1.5);

  for (float x = 0; x &lt; width; x++) {

    float y = noise(xoff) * 200;
    point(x, y);

    float t = noise(xoff2) * 400;

    //i+=5 = the space between the points vertically
    for (float i = y; i &lt; t; i+=5) {
      point(x, i);
    }

    xoff += inc;
    x = x + xoff + 4;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Getting perlin noise values around a bunch of predefined values.</title>
      <link>https://forum.processing.org/two/discussion/27739/getting-perlin-noise-values-around-a-bunch-of-predefined-values</link>
      <pubDate>Wed, 11 Apr 2018 09:42:20 +0000</pubDate>
      <dc:creator>SuyashN</dc:creator>
      <guid isPermaLink="false">27739@/two/discussions</guid>
      <description><![CDATA[<p>Hi community,</p>

<p>I am working on this project which requires perlin noise values around arbitrary values so that the the resulting sequences of perlin noise values have those values at their predefined locations and generate smooth transitions when visualized.
Here is the code :</p>

<pre><code>import peasy.PeasyCam;

PeasyCam cam;
float rotAngle = 0;
float frame = 0;

void setup() {
  size(480, 640, P3D);
  background(255);
  frameRate(120);
  cam = new PeasyCam(this, 1000);
}

void draw() {
  background(255);
  stroke(0);
  translate(0, -height/2, 0);
  float yoff = 0;
  for (int i = 0; i &lt; 14; i++) {
    pushMatrix();
    yoff = 50*i;
    translate(0, yoff, 0);
    rotAngle = map(noise(yoff/500, frame), 0, 1, -PI/3, PI/3);
    rotateZ(rotAngle);
    line(-200, 0, 200, 0);
    popMatrix();
  }
  frame += .001;
}
</code></pre>

<p><img src="https://image.ibb.co/i2sjXH/lines_harmony.png" alt="" /></p>

<p>This creates a column of horizontal lines which are rotated  PI/3 radians clockwise to PI/3 radians anticlockwise, mapped by the 2D Perlin noise values generated using frame number and y location of line as inputs.</p>

<p>What if, say,  the problem is to have the center line to be always perfectly horizontal and the other lines rotating around it with a smooth transition in harmony with that constant horizontal line in the center.
I need a solution which allows me to give more than one arbitrary values and get perlin noise around those values.</p>

<p>Thanks !!</p>
]]></description>
   </item>
   <item>
      <title>Looping perlin noise</title>
      <link>https://forum.processing.org/two/discussion/27719/looping-perlin-noise</link>
      <pubDate>Sun, 08 Apr 2018 06:22:17 +0000</pubDate>
      <dc:creator>SuyashN</dc:creator>
      <guid isPermaLink="false">27719@/two/discussions</guid>
      <description><![CDATA[<p>Hi Everyone!
What would be the most simple way of  fetching looping perlin noise values so that the first and last values are also related and is put around a circle gives a smooth transition.
Say I need 100 values then the 1st and 100th values are related.
Thanks Community. :)</p>
]]></description>
   </item>
   <item>
      <title>Displaying an array of points using Perlin noise</title>
      <link>https://forum.processing.org/two/discussion/27138/displaying-an-array-of-points-using-perlin-noise</link>
      <pubDate>Fri, 23 Mar 2018 20:26:47 +0000</pubDate>
      <dc:creator>solub</dc:creator>
      <guid isPermaLink="false">27138@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys,</p>

<p>I'm having a hard time trying to display points pseudo-randomly on the screen using Perlin noise.
Ideally I would like those points to form small clusters as they get close to each other (higher density). Quite like the dark areas of a texture generated by noise.</p>

<p><img src="https://i.imgur.com/cnbWKBa.png" alt="" />
<img src="https://i.imgur.com/58JUDR0.png" alt="" />
<img src="https://i.imgur.com/xJr50h4.png" alt="" /></p>

<p>Do you have an idea how I could do that ?</p>

<p>My failed attempt:</p>

<pre><code>def setup():
    size(800, 600)
    background(255)

    t = 0


    for x in range(0, width, 10):
        for y in range(0, height, 10):
            t += .001
            p = PVector(x, y)
            n = map(noise(p.x + t, p.y + t), 0, 1, 0, 10)
            p.mult(n)
            strokeWeight(2)
            point(p.x, p.y)
</code></pre>

<p>Please note that I'm writing in Python here but the question is open to everyone and any help (ideas, suggestions, Java code) is welcomed.</p>
]]></description>
   </item>
   <item>
      <title>Jittery Rotation</title>
      <link>https://forum.processing.org/two/discussion/26954/jittery-rotation</link>
      <pubDate>Wed, 21 Mar 2018 08:58:08 +0000</pubDate>
      <dc:creator>Henning</dc:creator>
      <guid isPermaLink="false">26954@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I have translated this p5.js code From the Coding Train into processing so that I can export PDFs easily. It works fine except the rotation is very jittery. it seems like the lines can only rotate in fixed increments. It also shows when I'm exporting single frames. What am I missing here? Is it perhaps something with float rounding? Can you guys help me?</p>

<pre><code>import processing.pdf.*;

float inc = 0.05;
float scl= 20;
int cols, rows;
float zoff = 0;
PVector[] flowField;

void setup(){
  //size(1020,600, PDF, "mesh.pdf");
  size(1020,600);
  cols = floor(width/scl);
  rows = floor(height/scl);
  flowField = new PVector[cols * rows];
}

void draw(){
  background(255);
  float yoff = 0;
  for (int y = 0; y &lt; rows; y++){
    float xoff = 0;
    for (int x = 0; x &lt; cols; x++){
      float angle = noise(xoff, yoff, zoff) * TWO_PI;
      PVector v = PVector.fromAngle(angle);
      xoff += inc;
      stroke(0);
      strokeWeight(3);
      pushMatrix();
      translate(x * scl +(scl/2), y * scl+(scl/2));
      rotate(v.heading());
      line(-scl/3.5, 0, scl/3.5, 0);
      popMatrix();
    }
    yoff += inc;
    zoff += 0.0002;
  }
  //exit();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to close a "noisy" circular shape?</title>
      <link>https://forum.processing.org/two/discussion/26962/how-to-close-a-noisy-circular-shape</link>
      <pubDate>Wed, 21 Mar 2018 13:26:52 +0000</pubDate>
      <dc:creator>solub</dc:creator>
      <guid isPermaLink="false">26962@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone !</p>

<p>When trying to draw a noisy circle I'm facing the following problem: the last vertex and the first vertex don't share the same position (due to the applied noise) so "closing" the circle becomes impossible:</p>

<p><img src="https://i.imgur.com/AkHcdzK.png" alt="" /></p>

<p>How can I fix this ?</p>

<pre><code>def setup():
    size(600, 600)

def draw():
    background(255)

    n_points = 300
    angle = radians(360) / n_points
    radius = 300

    beginShape()
    strokeWeight(4)
    for e in range(n_points):
        n = noise(map(e, 0, n_points, 0, 3))
        x = cos(angle * e) * radius * n
        y = sin(angle * e) * radius * n
        vertex(width / 2 + x, height / 2 + y)
    endShape(CLOSE)
</code></pre>
]]></description>
   </item>
   <item>
      <title>Using React with p5.js (ES6+ support)</title>
      <link>https://forum.processing.org/two/discussion/26322/using-react-with-p5-js-es6-support</link>
      <pubDate>Mon, 12 Feb 2018 20:54:24 +0000</pubDate>
      <dc:creator>atoro</dc:creator>
      <guid isPermaLink="false">26322@/two/discussions</guid>
      <description><![CDATA[<p><img src="https://forum.processing.org/two/uploads/imageupload/868/CURLOSY55G8G.png" alt="screeshot" title="screeshot" /></p>

<p>Check the <strong>online</strong> version <a rel="nofollow" href="http://fractal-tree-simulator.surge.sh/">here: http://fractal-tree-simulator.surge.sh/</a><br />
<strong>Source code</strong> is available <a rel="nofollow" href="https://github.com/atorov/fractal-tree-simulator">here: https://github.com/atorov/fractal-tree-simulator</a></p>

<h2>Using React with p5.js</h2>

<p>This project demonstrates the possibility of combining React, Bootstrap, p5.js and other modern technologies.<br />
<strong>React</strong> is one of the most popular JavaScript libraries for creating single page applications.<br />
<strong>Bootstrap</strong> is an open source toolkit for developing with HTML, CSS, and JS.</p>

<p>The basic idea is that the p5.js sketch is wrapped in a React component. The data that comes into the sketch is passed on to this component as props. Callbacks are used to return information back from the sketch to the application.</p>

<h3>ES6+ Support</h3>

<p>This project supports a superset of the latest JavaScript standard. In addition to <strong>ES6 syntax</strong> features, it also supports:<br />
  - Exponentiation Operator (ES2016).<br />
  - Async/await (ES2017).<br />
  - Object Rest/Spread Properties (stage 3 proposal).<br />
  - Dynamic import() (stage 3 proposal)<br />
  - Class Fields and Static Properties (part of stage 3 proposal).<br />
  -- JSX and Flow syntax.<br />
  - Syntax Highlighting and Displaying Lint Output in the Editor<br />
  - Тhe most popular editors should be covered and your editor should report the linting warnings.<br />
  - Code Splitting - allows you to split your code into small chunks which you can then load on demand. Supports code splitting via dynamic import().<br /></p>

<h3>Adding a Router and Redux</h3>

<p>React Router is the most popular option. Redux is a predictable state container for JavaScript apps. React Router and Redux can easily be added to the project.</p>

<h3>Running Tests</h3>

<p>Jest is a Node-based runner. While Jest provides browser globals such as window thanks to jsdom, they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks.</p>

<h3>p5.js sketch</h3>

<ul>
<li>p5.Graphics for creating a graphics buffer;<br /></li>
<li>p5.Vector for describing a two dimensional vectors;<br /></li>
<li>p5.noise() - Perlin noise random sequence generator that produces a more natural ordered, harmonic succession of numbers compared to the standard random() function;<br /></li>
<li>p5.colorMode() - both RGB and HSB color spaces;<br /></li>
<li>p5.translate() and p5.rotate() matrix transformations, etc.<br /></li>
</ul>
]]></description>
   </item>
   <item>
      <title>How to give individual particles a repulsion force using toxiclibs ?</title>
      <link>https://forum.processing.org/two/discussion/26484/how-to-give-individual-particles-a-repulsion-force-using-toxiclibs</link>
      <pubDate>Thu, 22 Feb 2018 18:50:33 +0000</pubDate>
      <dc:creator>solub</dc:creator>
      <guid isPermaLink="false">26484@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I would like to give particles a repulsion force from each other that is proportionnal to distance (inverted gravity) using toxiclibs. How can I do so ?</p>

<p>Consider the code below:</p>

<pre><code>add_library('toxiclibscore')
add_library('verletphysics')

from toxi.physics2d import VerletPhysics2D

from particle import Particle


def setup():
    global particules, n_particle, physics
    size(800, 600)


    physics = VerletPhysics2D()
    particules = []
    n_particle = 10


    for e in range(n_particle):
        radius = 100
        angle = TWO_PI  / n_particle
        x = radius * sin(angle * e) + map(noise(random(-20, 20)), 0, 1, -20, 120) 
        y = radius * cos(angle * e) 
        particules.append(Particle(width / 2 + x, height / 2 + y))

    for e in particules:
        physics.addParticle(e) 

    for e in range(n_particle - 1):
        a = particules[e]
        b = particules[e+1]
        s = VerletSpring2D(a, b, 40, .2)
        physics.addSpring(s)

    a = particules[-1]   //// connect the last particle to the first making a loop
    b = particules[0]
    s = VerletSpring2D(a, b, 40, .2)
    physics.addSpring(s)




def draw():
    global particules
    background(0)


    for e in particules:
        e.display()

    physics.update()
</code></pre>

<p>In setup() if I add something like:</p>

<pre><code>for e in particules:
    for f in particules:
        if e != f:
            force = PVector.sub(e.location, f.location)
            distance = force.mag()
            physics.addBehavior(AttractionBehavior(f, 10, -1 / distance ))
</code></pre>

<p>... the behavior will be fixed and won't change over time. What I need is a repulsive force that <strong>constantly changes depending on the varying distance between 2 particles</strong>. I tried to put that snippet in draw() but the forces kept accumulating and I couldn't figure out how to cancel them at each iteration.</p>

<p>Any idea how I can implement this kind of adaptative behavior with toxiclibs ?</p>
]]></description>
   </item>
   <item>
      <title>Heart clock :D</title>
      <link>https://forum.processing.org/two/discussion/26538/heart-clock-d</link>
      <pubDate>Mon, 26 Feb 2018 15:48:44 +0000</pubDate>
      <dc:creator>GeorgeJava</dc:creator>
      <guid isPermaLink="false">26538@/two/discussions</guid>
      <description><![CDATA[<p>Look what i made (FOR FUN) is you heart OK ? Test it ! :)</p>

<pre><code>int x;
float pn;
float xoff = 0.0;
void setup(){
  size(500,500);
  background(0);
}
void draw() {
  xoff = xoff + .02;
  float n = noise(xoff);
  if(xoff&gt;=2){
    xoff=0;
  }
  println(n + " " + xoff);
  n *= height;
  stroke(255);
  line(x,pn,x,n);
  pn = n;
  x++;
  if(x&gt;=width){
    x=0;
    background(0);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Pixel arrays?</title>
      <link>https://forum.processing.org/two/discussion/26442/pixel-arrays</link>
      <pubDate>Tue, 20 Feb 2018 03:01:12 +0000</pubDate>
      <dc:creator>Scott06</dc:creator>
      <guid isPermaLink="false">26442@/two/discussions</guid>
      <description><![CDATA[<p>Hello community, I am in need of your assistance; I've been working on a project for school, here's the code;</p>

<pre><code>float x;
float y;
float[][] points;
float amplitude = 150.0;
int num_waves = 15;
int[][] grid;
float increment = 0.02;


void setup()
{
  size(640,640);
}

void draw()
{
  background(0);
  float yoff=0.0;
  loadPixels();
  for(int y=0; y&lt;height; y++)
  {
    float xoff = 0.0;
    for (int x=0; x&lt;width; x++)
    {
      int index = (x+y*width);
      float r = noise(xoff,yoff)*100;
      pixels[index]= color(r,0,r,140);
      xoff+=.01;
    }
    yoff+=.01;
  }
  updatePixels();
  noLoop();
  println(randomGaussian()*pixels.length);

    float b=0;
  while (b &lt; width)
  {
    point(b, height*noise(b));
    b=b+1;
  }

translate(0,height/2);

for(int j=0; j&lt;num_waves; j++)
{
  strokeWeight(1);
  stroke(0,120,120);
  translate(-2,4);
  sineWave();
}
}

float[][] Points()
{
  points = new float[width*3][2];
  x = 0.0;
  for(int j=0; j&lt;points.length; j++)
  {
    y = amplitude*pow(sin(.015*x),5)*cos(.015*x);
    for(int i=0; i&lt;2; i++)
    {
      switch(i)
      {
        case 0:
        points[j][i]=x;
        break;
        case 1:
        points[j][i]=y;
        break;
      }
    }
    x+=PI/4;
  }
  return(points);
}


void sineWave()
{
  float[][] points = Points();
  beginShape();
  vertex(0,0);
  noFill();
  for(int n=0; n&lt;points.length; n++)
  {
    vertex(points[n][0],points[n][1]);
  }

  endShape();
}
</code></pre>

<p>Sorry that it's not the cleanest of code, I need to go back and clean it up later. But anyway, inside of the draw function, I've used the noise function to create a simple purple and black texture that fits the whole screen. What I would like to do is have the texture only take up a specified shape within the screen, such as in this image:</p>

<p><a href="https://cnet4.cbsistatic.com/img/p2JgkXzoNDuAakOloAly3fIdYl4=/fit-in/970x0/2013/05/09/8d21444e-cc2e-11e2-9a4a-0291187b029a/sine_1.jpg" target="_blank" rel="nofollow">https://cnet4.cbsistatic.com/img/p2JgkXzoNDuAakOloAly3fIdYl4=/fit-in/970x0/2013/05/09/8d21444e-cc2e-11e2-9a4a-0291187b029a/sine_1.jpg</a></p>

<p><img src="https://cnet4.cbsistatic.com/img/p2JgkXzoNDuAakOloAly3fIdYl4=/fit-in/970x0/2013/05/09/8d21444e-cc2e-11e2-9a4a-0291187b029a/sine_1.jpg" alt="" /></p>

<p>(For example in this image the noise is not really applied in any of the four corners of the image) I think I might be able to accomplish this by first drawing the shape that I want with bezier vertices, and then choose a fill color such as white, and then go through each of the pixels and testing to see if the color of the pixel is white, and then if so then apply the noise function to those pixels. I'm not sure if that would work though, and even if it does, it seems like it would be extremely tedious. Also an added bonus would be to be able to make the outer edges of the noise have a lower color saturation but that's not my primary concern.</p>

<p>Thanks for the help!</p>
]]></description>
   </item>
   <item>
      <title>Perlin Noise Terrain Lightning Problem</title>
      <link>https://forum.processing.org/two/discussion/26406/perlin-noise-terrain-lightning-problem</link>
      <pubDate>Sat, 17 Feb 2018 17:33:42 +0000</pubDate>
      <dc:creator>Case23</dc:creator>
      <guid isPermaLink="false">26406@/two/discussions</guid>
      <description><![CDATA[<p>Hello Everybody.</p>

<p>I just tried to alter Shiffmans Perlin Noise Terrain Example in P5.js and add Material and Lightning.</p>

<p>What i experience are some weird Stripes on the Terrain.</p>

<p><a rel="nofollow" href="https://video.twimg.com/tweet_video/DWPOIgKX4AExqIH.mp4">video</a></p>

<p>Anybody has an idea why this happens?</p>

<p>Can it be related to the order the vertex are created?</p>

<p>I hope you can help me! :)</p>

<p>Shiffmans Example:
<a href="https://github.com/CodingTrain/website/tree/master/CodingChallenges/CC_11_PerlinNoiseTerrain_p5.js" target="_blank" rel="nofollow">https://github.com/CodingTrain/website/tree/master/CodingChallenges/CC_11_PerlinNoiseTerrain_p5.js</a></p>

<pre><code>var cols;
var rows;
var scl = 20;
var w = 560;
var h = 560;
var terrain = [];
var flying = 0;
var img;

function setup() {
  createCanvas(560,560, WEBGL);

  cols = w/scl;
  rows = h/scl;

  for (var x = 0; x &lt; cols; x++) {
    terrain[x] = [];
    for (var y = 0; y &lt; rows; y++) {
      terrain[x][y] = 0;
    }
  }
}

function draw() {
  background(255);
  var locX = mouseX - width / 2;
  var locY = mouseY - height / 2;
  pointLight(250, 250, 250, locX, locY, 50);
  ambientMaterial(250);

  translate(0,0,-240);
  rotateX(PI/3);
  translate(-width/2,-height/2,0);



  flying -= 0.005;
  var yoff = flying;

  for (var y = 0; y &lt; rows; y++) {
    var xoff = 0;
    for (var x = 0; x &lt; cols; x++) {
      terrain[x][y] = map(noise(xoff, yoff), 0, 1, -80, 80);
      xoff += 0.2;
    }
    yoff += 0.2;
  }


  stroke(0,0);

  for (var y = 0; y &lt; rows-1; y++) {
    beginShape(TRIANGLE_STRIP);
    for (var x = 0; x &lt; cols; x++) {
      push();
        vertex(x*scl, y*scl, terrain[x][y]);
        vertex(x*scl, (y+1)*scl, terrain[x][y+1]);
        pop();
    }
    endShape(CLOSE);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I remove a pattern in a perlin slope field?</title>
      <link>https://forum.processing.org/two/discussion/26340/how-can-i-remove-a-pattern-in-a-perlin-slope-field</link>
      <pubDate>Tue, 13 Feb 2018 19:57:55 +0000</pubDate>
      <dc:creator>Dinoswarleafs</dc:creator>
      <guid isPermaLink="false">26340@/two/discussions</guid>
      <description><![CDATA[<p>Hey! I learned about slope fields a while back in Calculus and wanted to make one of those in Processing, but instead have the slopes randomly change according to perlin noise. This way it has a cool field effect where the slopes around one are similar but not exactly the same and smoothy transition to other spots. I got most of it working with this :</p>

<pre><code>float[][] vectorSlopes;
float xOff, yOff, slope, speed, speedi;
float xOffi, yOffi;
float wGap = 30;
float hGap = 30;
float space = 5;

void setup() {
  size(1200, 800);
  speed = .1;
  speedi = .01;
  vectorSlopes = new float[(int)(width/wGap)][(int)(height/hGap)];
  rectMode(CENTER);
  xOff = random(10000);
  yOff = random(10000);
  xOffi = xOff;
  yOffi = yOff;
}

void draw() {
  xOffi += speedi;
  xOff = xOffi;
  background(110);
  yOffi += speedi;  
  for (int x = 0; x &lt; vectorSlopes.length; x++) {
    xOff += speed;
    yOff = yOffi;
    for (int y = 0; y &lt; vectorSlopes[x].length; y++) {      
      yOff += speed;        
      float xPos = x * wGap;
      float yPos = y * hGap;
      float lwidth = (wGap - space)/2;
      float lheight = (hGap - space)/2;  
      slope = map(noise(xOff, yOff), 0, 1, -lheight / 2, lheight / 2);
      line(xPos - lwidth, yPos + (slope * lwidth), xPos + lwidth, yPos - (slope * lwidth));
    }
  }
}
</code></pre>

<p>There's an issue where the slopes from the botton right becme the slopes of the top left, probably as a consequence of my x and y off initial variables that I used. It kinda ruins the randomness of it, and if you zoom out by setting the wGap and hGap to like 5 with a space of 1 or 2 it becomes really obvious and annoying to look at. Any help is appreciated. Thanks!</p>
]]></description>
   </item>
   <item>
      <title>perlin noise looping</title>
      <link>https://forum.processing.org/two/discussion/25845/perlin-noise-looping</link>
      <pubDate>Sat, 06 Jan 2018 02:06:47 +0000</pubDate>
      <dc:creator>kellen</dc:creator>
      <guid isPermaLink="false">25845@/two/discussions</guid>
      <description><![CDATA[<p>What is the range of unique results for noise(x)? I need to make it loop and transition smoothly.</p>
]]></description>
   </item>
   <item>
      <title>Mouse click event in 3d - WEBGL</title>
      <link>https://forum.processing.org/two/discussion/25255/mouse-click-event-in-3d-webgl</link>
      <pubDate>Tue, 28 Nov 2017 18:13:33 +0000</pubDate>
      <dc:creator>yanivasaf</dc:creator>
      <guid isPermaLink="false">25255@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>I created a box out of planes. I'm trying to find a way to click on each plane (creating like a cube navigation).</p>

<p>How do i do it while using translate for location?
Thanks</p>

<p>`let moveX;
let moveY;
let varx;
let vary;
let varinc;</p>

<p>function setup() { 
  createCanvas(windowWidth, windowHeight, WEBGL);</p>

<p>}</p>

<p>function moveCube(){
  moveX= map(mouseX, 0,width, 0,360);
    moveY= map(mouseY,0,height,0,360);
    rot();
  thebox();</p>

<p>}</p>

<p>function rot(){
    rotateX(-moveY * 0.01);
  rotateY(-moveX * 0.01);
  rotateZ(frameCount*0.007);
}</p>

<p>function cubeNoise(){
  varx = map(noise(varinc),0,1,-150,150);
  vary = map(noise(varinc),0,1,-150,150);</p>

<p>varinc+=0.003;</p>

<p>}</p>

<p>function draw() { 
  background(250);
    orbitControl();</p>

<p>//cubeNoise();
  push();
  //translate(varx,vary);
  moveCube();
  pop();
}</p>

<p>function thebox(){
    fill(250,0,0);//red
    plane(250);</p>

<pre><code>push();
translate(-125,0,-125);
rotateY(radians(90));
fill(0,250,0);//green
plane(250);
pop();

push();
translate(125,0,-125);
rotateY(radians(90));
fill(0,0,250);//blue
plane(250);
pop();

push();
translate(0,-125,-125);
rotateX(radians(90));
fill(200,50,200);//pink
plane(250);
pop();

push();
translate(0,-125,-125);
rotateX(radians(90));
fill(200,50,200);//pink
plane(250);
pop();
</code></pre>

<p>push();
    translate(0,125,-125);
    rotateX(radians(90));
    fill(150,150,150);//gray
    plane(250);
    pop();</p>

<p>push();
    translate(0,0,-250);</p>

<pre><code>fill(0);//gray
plane(250);
pop();
</code></pre>

<p>}</p>

<p>function screens{
  var trx;
  var try;
  translate(-width/2, -height/2);
  for (var i = 0; i&lt;9; i++){
    push();
    translate(</p>

<p>`</p>
]]></description>
   </item>
   <item>
      <title>Why does it seem the noise() method is negatively biased?</title>
      <link>https://forum.processing.org/two/discussion/24879/why-does-it-seem-the-noise-method-is-negatively-biased</link>
      <pubDate>Sun, 05 Nov 2017 17:19:44 +0000</pubDate>
      <dc:creator>shawnlau</dc:creator>
      <guid isPermaLink="false">24879@/two/discussions</guid>
      <description><![CDATA[<p>I just started reading Daniel Shiffman's Nature of code and going through his videos.  I started playing with the Perlin noise method and it seems if you map it to  -1,1 it has a distinct negative bias.</p>

<p>Below is the Random Walker code from the book  altered to use Perlin noise for the movements. No matter how I fiddle with the time, it seems the walker always heads to the top left, i.e, it generally moves  -x and -y. Is there some bug in this code or does the noise method have some sort of bias?</p>

<pre><code>// Daniel Shiffman
// The Nature of Code
// <a href="http://www.shiffman.net/" target="_blank" rel="nofollow">http://www.shiffman.net/</a>

Walker w;

void setup() {
  size(600,600);
  // Create a walker object
  w = new Walker();
  background(255);
}

void draw() {
  // Run the walker object
  w.step();
  w.render();
}
// A random walker object!
class Walker {
  float x,y,time,timeInc;


  Walker() {
    x = width/2;
    y = height/2;
    time = 0;
    timeInc = 20;

  }

  void render() {
    stroke(0);
    point(x,y);
  }

  // Randomly move to any neighboring pixel (or stay in the same spot)
  void step() {
    float stepX = noise(time);
//    stepX = stepX * 2 -1;
    stepX = map(stepX,0,1,-1,1);    
    time+=timeInc;
    float stepY = noise(time);
//    stepY =stepY *2 -1;
    stepY = map(stepY,0,1,-1,1);
    time+=timeInc;
    x += stepX;
    y += stepY;
    x = constrain(x,0,width-1);
    y = constrain(y,0,height-1);
  }
}
</code></pre>

<p>I'm thinking there's something I'm not seeing in the code because this short test shows no bias:</p>

<pre><code>void setup(){
     for(int i = 0;i &lt;20;i++){
          float x = (float)noise(i);
          x = map(x,0,1,-1,1);
          println(x);
     }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to save a sketch as a high-res image</title>
      <link>https://forum.processing.org/two/discussion/24646/how-to-save-a-sketch-as-a-high-res-image</link>
      <pubDate>Thu, 19 Oct 2017 23:57:18 +0000</pubDate>
      <dc:creator>annika</dc:creator>
      <guid isPermaLink="false">24646@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I want to print my sketch as a somewhat large poster (11x17in). What's the best way to save it so it won't get pixelated?</p>

<p>I tried adding the pdf library but when I search for it in libraries it doesn't show up.
I also tried taking a screenshot and changing the ppi to 300 but that made the image too small.</p>

<p>Thanks a lot,
Annika</p>
]]></description>
   </item>
   <item>
      <title>Can you explain me what is these? (point, map, noise)</title>
      <link>https://forum.processing.org/two/discussion/24658/can-you-explain-me-what-is-these-point-map-noise</link>
      <pubDate>Fri, 20 Oct 2017 17:16:36 +0000</pubDate>
      <dc:creator>bb34</dc:creator>
      <guid isPermaLink="false">24658@/two/discussions</guid>
      <description><![CDATA[<pre><code>point(x, y + map(noise(x/150, y/150, z), 0, 1, -100, 100)) ;
</code></pre>
]]></description>
   </item>
   <item>
      <title>Perlin Noise random walker driving to top left?</title>
      <link>https://forum.processing.org/two/discussion/24426/perlin-noise-random-walker-driving-to-top-left</link>
      <pubDate>Sat, 07 Oct 2017 06:23:56 +0000</pubDate>
      <dc:creator>mahela007</dc:creator>
      <guid isPermaLink="false">24426@/two/discussions</guid>
      <description><![CDATA[<p>Hi all.. 
I  attempted to make a perlin noise based random walker (after watching Daniel Schiffmans Youtube videos). However, my walker always seems to end up at the top right of the screen. Why is this? 
I googled for this same problem and found that it can happen because of casting between int and floats in processing.. however, I'm only using  floats throughout my sketch. 
Thanks. :)</p>

<p>Here's my sketch</p>

<pre><code>ArrayList&lt;Walker&gt; walkers;

int NUMWALKERS = 10;
Walker a;
import processing.pdf.*;
float steps = 0;
boolean record = false;

void setup(){
  a = new Walker();
  size(500,500);
  background(255);
  textSize(32);
  beginRecord(PDF, "PerlinNoiseWalker-####.pdf");

}

void draw(){
  fill(255);
  noStroke();
  fill(0, 102, 153, 60);
    a.walkPerl();
    a.render();
}

void mousePressed(){
  record = true;
  endRecord();
  println("Saving PDF");
}
</code></pre>

<p>And the walker class
    }`</p>

<pre><code>class Walker{
  private float x = width/2;
  private float y = height/2;
  public static final float step = 10.0;

  float t = 0;
  float t2 = 0;

  public Walker(){
    //give each walker a random 'seed' for the perlin noise;
    t = 0.01;
    t2 = t+10;
  }

  public void walkPerl(){
    t += 0.01;
    t2 += 0.01;
    float xN = noise(t);
    xN = map(xN,0,1,-step,+step);
    x += xN;
    x = constrain(x,0,width);

    float yN = noise(t2);
    yN = map(yN,0,1,-step,+step);
    y += yN;
    y = constrain(y,0,height);
  }

  public void render(){
    //stroke(#9E07E0);
    //point(x,y);
    ellipse(x,y,5,5);
  }
}
</code></pre>

<p>The effect is somewhat subtle but it's there:</p>
]]></description>
   </item>
   <item>
      <title>Is perlin noise suposed to repeat itself?</title>
      <link>https://forum.processing.org/two/discussion/23417/is-perlin-noise-suposed-to-repeat-itself</link>
      <pubDate>Wed, 12 Jul 2017 17:02:00 +0000</pubDate>
      <dc:creator>Alvaro314</dc:creator>
      <guid isPermaLink="false">23417@/two/discussions</guid>
      <description><![CDATA[<p>I just made a little program messing arround with pixels, and it occurred to me to use 2D perlin noise to set the color of each pixel in the screen, and in doing this I noticed that there are clearly repeating patterns, when I thought that perlin noise did't do that. Is there anything that I'm missing in the code or is it just that perlin noise does actually repeat and I didn't know it?</p>

<pre><code>float zOff = 0;

void setup() {
  colorMode(HSB);
  size(700, 500);
}

void draw() {
  loadPixels();
  float yOff = 0;
  for (int y = 0; y &lt; height; y ++) {
    float xOff = 0;
    for (int x = 0; x &lt; width; x ++) {
      int index = y * width + x;
      pixels[index] = color(map(noise(xOff, yOff, zOff), 0, 1, -50, 300), 255, 255);
      xOff += 0.15;
    }
    yOff += 0.15;
  }
  updatePixels();
  zOff += 0.01;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Problems PDF export</title>
      <link>https://forum.processing.org/two/discussion/23332/problems-pdf-export</link>
      <pubDate>Thu, 06 Jul 2017 13:13:23 +0000</pubDate>
      <dc:creator>Tanguy</dc:creator>
      <guid isPermaLink="false">23332@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone !</p>

<p>I'm trying to export some PDF pictures from this code :</p>

<pre><code>import processing.pdf.*;

boolean record;
int cols, rows;
int scale = 15;
int w = 1200; 
int h = 900;

float flying = 0;
float[][] terrain;


//-------------------------------------------------------//


void setup() {

  size(600, 600, P3D);
  cols = w / scale; 
  rows = h / scale;
  terrain = new float[cols][rows];
}


//-------------------------------------------------------//


void draw() {
  if(record) {
    beginRecord(PDF, "Visuel-####.pdf");
  }

  flying -= 0.005;

  float yoff = flying;
  for (int y = 0; y &lt; rows; y++) {
    float xoff = 0;
    for (int x = 0; x &lt; cols; x++) {
      terrain[x][y] = map(noise(xoff, yoff), 0, 1, -50, 50);
      xoff += 0.1;
    }
    yoff += 0.1;
  }

  background(255); 
  stroke(0);
  noFill();

  translate(width/2, height/2);
  rotateX(PI/2.05);
  translate(-w/2, -h/2);

  for (int y = 0; y &lt; rows-1; y++) {
    beginShape(TRIANGLE_STRIP);
    for (int x = 0; x &lt; cols; x++) {
      vertex(x*scale, y*scale, terrain[x][y]);
      vertex(x*scale, (y+1)*scale, terrain[x][y+1]);
    }
    endShape();
  }
  if(record) {
    endRecord();
    record=false;
  }
}

void mousePressed() {
  record = true;
}
</code></pre>

<p>But I have some problems : the files are created but they are empty white pictures !
Is this link to the fact the code is including P3D ? 
Someone can help ?</p>

<p>Thanks !</p>

<p>Tanguy</p>
]]></description>
   </item>
   <item>
      <title>Class making program really slow</title>
      <link>https://forum.processing.org/two/discussion/23214/class-making-program-really-slow</link>
      <pubDate>Mon, 26 Jun 2017 13:27:00 +0000</pubDate>
      <dc:creator>niekboersen</dc:creator>
      <guid isPermaLink="false">23214@/two/discussions</guid>
      <description><![CDATA[<p>Hello forum users,</p>

<p>Today am I working on a file where I have to create mountains using the noise function. I made this finally work but now am I struggeling with the fact that the class is slowing my program down a lot.</p>

<pre><code>Mountains mountains = new Mountains();

void setup(){
 mountains.drawMountain();
size(1200,800);

void draw(){

 mountains.drawMountains();
}


class Mountains {
  float m[] = new float[1200];
  float yoff = 0;
  float yincrement = 0.005;
  float noiseVar = 1;
  color mountaincolor = color(51, 153, 51);


  Mountains() {
  }

  void drawMountain() {

    for (int i=0; i&lt;width; i++) {
      m[i] = noise(yoff)*height;
      yoff += yincrement;
    }
  }

  void drawMountains() {
    for (int i=0; i&lt;width; i++) {
      stroke(mountaincolor);
      fill(mountaincolor);
      line(i, m[i], i, height);
    }
  }
}
</code></pre>

<p>Is there a way to get rid of this?</p>

<p>Greetings Niek Boersen</p>
]]></description>
   </item>
   <item>
      <title>Heat Map Color Resolution</title>
      <link>https://forum.processing.org/two/discussion/20004/heat-map-color-resolution</link>
      <pubDate>Sat, 31 Dec 2016 00:42:38 +0000</pubDate>
      <dc:creator>Reefhermit</dc:creator>
      <guid isPermaLink="false">20004@/two/discussions</guid>
      <description><![CDATA[<p>The code below is my answer to getting "finer" color resolution on the heat Map, ie., adding more colors to choose from.</p>

<p>Is there a more elegant and/or more efficient solution in Processing to do this? Hues, saturation ??</p>

<p>Thanks,</p>

<p>Ken</p>

<pre><code>void applyColor() {  // Generate the heat map

  color c1 = color(0, 0, 255);      // Blue color
  color c2 = color(0, 255, 255);    // color Cyan
  color c3 = color(0, 255, 0);      // Green color
  color c4 = color(255, 255, 0);    // Yellow color
  color c5 = color(240, 150, 5);   // Orange color
  color c6 = color(255, 0, 0);      // Red color

  loadPixels();
  int p = 0;
  color c;
  float fraction;

  for (int i = 0; i &lt; rows; i++) {
    for (int j = 0; j &lt; cols; j++) {
      float value = interp_array[i][j];

      if (value&gt;= 25 &amp;&amp; value&lt;26) {
        fraction = value;
        c = lerpColor(c1, c2, fraction);
      } else if (value&gt;=26 &amp;&amp; value&lt;27) {
        fraction = value;
        c = lerpColor(c2, c3, fraction);
      } else if (value&gt;=27 &amp;&amp; value&lt;28) {
        fraction = value;
        c = lerpColor(c3, c4, fraction);
      } else if (value&gt;=28 &amp;&amp; value&lt;29) {
        fraction = value;
        c = lerpColor(c4, c5, fraction);
      } else if (value&gt;=29 &amp;&amp; value&lt;30) {
        fraction = value;
        c = lerpColor(c5, c6, fraction);
      } else
        c = c6;
      pixels[p++] = c;
    }
  }
  updatePixels();
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to "project" or "map" 2D shapes or images on 3D terrain</title>
      <link>https://forum.processing.org/two/discussion/23133/how-to-project-or-map-2d-shapes-or-images-on-3d-terrain</link>
      <pubDate>Mon, 19 Jun 2017 14:30:16 +0000</pubDate>
      <dc:creator>datatrash</dc:creator>
      <guid isPermaLink="false">23133@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>a while ago I followed this Coding Challenge video by Daniel Shiffman to create a moving 3D terrain:</p>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-IKB1hWWedMk"><span class="VideoPreview"><a href="http://youtube.com/watch?v=IKB1hWWedMk"><img src="http://img.youtube.com/vi/IKB1hWWedMk/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>I now want to map a 2D shape onto the terrain. 
Unfortunately I am a complete noob to programming and have no idea how to do this so I would really appreciate some help.</p>

<p>Can someone please point me in the right direction? :)</p>

<p>Many thanks and best regards!</p>
]]></description>
   </item>
   <item>
      <title>Hello, in the code below I try to give a random value to textSize in the sphere class, but it copies</title>
      <link>https://forum.processing.org/two/discussion/16839/hello-in-the-code-below-i-try-to-give-a-random-value-to-textsize-in-the-sphere-class-but-it-copies</link>
      <pubDate>Thu, 26 May 2016 09:42:19 +0000</pubDate>
      <dc:creator>lolonulu</dc:creator>
      <guid isPermaLink="false">16839@/two/discussions</guid>
      <description><![CDATA[<p>[see below for code]</p>
]]></description>
   </item>
   <item>
      <title>What could be causing 'array.array assignment index out of range' error?</title>
      <link>https://forum.processing.org/two/discussion/22563/what-could-be-causing-array-array-assignment-index-out-of-range-error</link>
      <pubDate>Sat, 13 May 2017 15:41:48 +0000</pubDate>
      <dc:creator>dallas_borealis</dc:creator>
      <guid isPermaLink="false">22563@/two/discussions</guid>
      <description><![CDATA[<p>I'm attempting to do Dan Shiffman's Pixel Array in Python but get the error after just a few iterations. Here's the code:</p>

<pre><code>inc = 0.01
def setup():
    size(6, 5)

def draw():
    # background(50)
    global inc
    yoff = 0
    loadPixels()
    for y in range(height-1):
        xoff = 0
        for x in range(width):
            idx = (x + y * width) * 4
            r = noise(xoff, yoff) * 255
            pixels[idx+0] = r
            pixels[idx+1] = r
            pixels[idx+2] = r
            pixels[idx+3] = 255
            xoff += inc
        yoff += inc
    updatePixels()
</code></pre>

<p>The error appears here: <code>pixels[idx+2] = r</code></p>

<p>Thanks for any help!</p>

<p>~dallas_borealis</p>
]]></description>
   </item>
   </channel>
</rss>