Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Parenting one object to another

$
0
0

Hi, im new to processing and was wondering if someone could help me with a bit of code. Basically i want the ellipse to surround the zigzag and have the ellipse follow where ever the zigzag jumps to.

Thanks in advance

code:

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
import processing.sound.*;
Amplitude amp;
AudioIn in;

void setup(){
   size(500,500);
   background(230,230,230);
   amp = new Amplitude(this);
   in = new AudioIn(this, 0);
   in.start();
   amp.input(in);
  }

void draw (){
  if(amp.analyze() > 0.02) {
  clear();
  zigzag();
  }
}
void zigzag(){
  float xPosition=random(height);
  float yPosition=random(height);
  float zPosition=random(height);

  float newXPosition=0;
  float newYPosition=0;

  float theDistance=15;
  float theRange=50;
  rotate(PI*random(720));

  for(int i=0; i<4; i++){
    stroke(126,213,242);
    strokeWeight(1);
    newXPosition = xPosition + theDistance;
    newYPosition = yPosition + theRange / 2 - (i % 2) * theRange;
    line(xPosition,yPosition,newXPosition,newYPosition);
    xPosition = newXPosition;
    yPosition = newYPosition;
    noFill();
    stroke(100,100,242);{
    ellipse(100,100,100,100);
  }
   }

}

void lines(){
  float x = random(width);
  float y = random(height);
  float r = random(height);
  stroke(255,0,0);
  strokeWeight(3);
  line(x, amp.analyze() * 100, y, 500);
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles