# Nodes System coding in Processing

**URL:** https://discourse.processing.org/t/nodes-system-coding-in-processing/29736
**Category:** Coding Questions
**Tags:** homework
**Created:** [April 29, 2021, 9:42pm UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736 "2021-04-29T21:42:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![PokeAvi](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@PokeAvi](https://discourse.processing.org/u/PokeAvi)
#### Post date: [April 29, 2021, 9:42pm UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736/1 "2021-04-29T21:42:00Z")

</div>

> Hello world! I am developing a school project that asks me to implement a node system that can be used in the production of design objects. It has to be a functional application in some field of design (product, architecture, interactive design, illustration, fashion, etc…) and in ways of generating greater complexity (the relationship between various processes, their use to determine parameters additional to the position, etc…). I have these two code options:

```auto
class Nodo{
  float x,y;
  float r;
  float amp;
  float dx, dy;
   
  Nodo(float x_, float y_, float r_, float amp_){
    x = x_;
    y = y_;
    r = r_;
    amp = amp_;
    dx = random(-2,2);
    dy = random(-2,2);
  }
  
  void mover(){
    x+=dx;
    y += dy;
  }
}

class Cubo{
  float x,y,z;
  
  Cubo(float x_, float y_){
    x = x_;
    y = y_;
    z = 0;
  }
  
  void display(){
    pushMatrix();
    translate(x,y,z);
    noStroke();
    fill(255,0,0);
    box(tam);
    popMatrix();
  }
}

ArrayList <Nodo> nodos;
ArrayList <Cubo> cubos;
int tam = 10;;
void setup(){
  size(500,500,P3D);
  background(0);
  nodos = new ArrayList<Nodo>(); 
  cubos = new ArrayList <Cubo>();
  for(int i = 0 ; i<100; i++){
    nodos.add(new Nodo(random(-width/2,width/2),random(-height/2, height/2),random(30,150),random(40)));
  }
  for(int i = -width/2; i<width/2; i+= tam){
    for(int j = -height/2 ; j<height/2;j+= tam){
      cubos.add(new Cubo(i,j));
    }
  }
  
 
}

void draw(){
  background(0);
  lights();
  translate(width/2,height/2);
  rotateX(mouseX*0.03);
  rotateY(mouseY*0.03);
  for(Cubo c:cubos){
    c.display();
  }
  for(Nodo n:nodos){
    n.mover();
  }
  
  for (Cubo c:cubos){
    c.z = 0;
    for(Nodo n:nodos){
      float distancia = dist(c.x,c.y,n.x,n.y);
      if(distancia < n.r){
        c.z+=n.amp*map(distancia,0,n.r,1,0);
      }
    }
  }
}

```

```auto
class Nodo{
  float x,y;
  float r;
  float amp;
  float dx,dy;
  float ro,ve,az;
  
  Nodo(float x_, float y_, float r_, float amp_){
    x = x_;
    y = y_;
    r = r_;
    amp = amp_;
    dx = random(-2,2);
    dy = random(-2,2);
    ro = random(255);
    ve = random(255);
    az = random(255);
  }
  
  void mover(){
    x+=dx;
    y+=dy;
  }
  
  void display(){
    int centroH = floor(x);
    int centroV = floor(y);
    int radio = floor(r);
    int limiteizq = (centroH - radio >0)? centroH - radio:0 ;
    int limiteder = (centroH + radio<width)? centroH + radio : width;
    int limitesup = (centroV - radio> 0)? centroV - radio: 0;
    int limiteinf = (centroV + radio<height)? centroV + radio: height;
    
    for(int i = limiteizq; i< limiteder ; i++){
      for (int j = limitesup ; j< limiteinf; j++){
        float distancia = dist(x,y,i,j);
        if(distancia<r){
          int pix = j*width + i;
          color original = pixels[pix];
          float orojo = red(original);
          float overde = green(original);
          float oazul = blue(original);
          float cantidad = amp*map(distancia,0,r,1,0);
          orojo += cantidad*ro;
          overde += cantidad*ve;
          oazul += cantidad*az;
          color nuevo = color(orojo,overde,oazul);
          pixels[pix] = nuevo;
        }
      }
    }
  } 
}

ArrayList <Nodo> nodos;
void setup(){
  size(500,500);
  background(0);
  nodos = new ArrayList<Nodo>();
  for(int i = 0 ; i<100; i++){
    nodos.add(new Nodo(random(width),random(height),random(30,150),random(0.5)));
  }
  loadPixels();
  for(Nodo n:nodos){
      n.display();
  }
  updatePixels(); 
}

```

I’m not exactly good at programming and it’s as far as I got my creativity, I have the idea to implement something with sound recognition and nodes but I don’t know how to carry it out, if someone could advise me and/or help me it would be phenomenal 😃

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 29, 2021, 9:58pm UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736/2 "2021-04-29T21:58:30Z")

</div>

Look here [Looking for an old music app - #3 by Returningcustomer](https://discourse.processing.org/t/looking-for-an-old-music-app/29731/3)

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 30, 2021, 2:11am UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736/3 "2021-04-30T02:11:44Z")

</div>

Hello,

Please format your code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

You can use the edit button (looks like a pencil):  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/ea66ff565e030b0508baa76d9d76eeab272ae0d4.png)

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 2, 2021, 10:54am UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736/4 "2021-05-02T10:54:56Z")

</div>

> [@PokeAvi](#):
>
> sound recognition

Check out the sound library and the minim library

---

<div class="post-metadata">

### Author: ![PokeAvi](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@PokeAvi](https://discourse.processing.org/u/PokeAvi)
#### Post date: [May 4, 2021, 9:45pm UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736/5 "2021-05-04T21:45:59Z")

</div>

Yup, I’ve been checking it, but I have no idea how to implement it in the code and react to sound. I thought about using arduino but I don’t have the possibility to buy one for now ☹

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 4, 2021, 11:05pm UTC](https://discourse.processing.org/t/nodes-system-coding-in-processing/29736/6 "2021-05-04T23:05:41Z")

</div>

There is a microphone in minim library

No Arduino needed
