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

PShape s.scale not working in void draw!

$
0
0

Below is my current code:

import peasy.*;
import ddf.minim.*;

Minim minim;
AudioInput in;
PeasyCam cam;
PShape s;
void setup() {
  size(1000,600,P3D);

  cam = new PeasyCam(this, 500);
  cam.setMinimumDistance(500);
  cam.setMaximumDistance(500);

    minim = new Minim(this);
  in = minim.getLineIn();
  frameRate(60);

  s = loadShape("spike.obj");
  smooth();
  s.scale(0.2);
}
void draw() {
  background(0);

  s.setFill(color(255));

     for(int i = 0; i < in.bufferSize() - 1; i++){
       stroke(0);
       box(150 + in.right.get(i)*200);
       shape(s);
  }

}

If you run it without the shape (obj) and with all applicable libraries the box should move with your sound input amplitude. I have tried for the past 7 hours to get this snippet to work right under the box syntax:

s.scale(200 + in.right.get(i)*200);
shape(s);

This would make it so my obj that I have would pulse to the input amplitude exactly like the box. The problem is that every time I bring s.scale(int) into the void draw as apposed to where I have it now in the void setup.

If you would like to see a very simple UNWORKING snippet copy the below:

PShape obj;

void setup() {
  size(640,360,P2D);
  obj = createShape(RECT,200,200,100,100);

}

void draw () {
  background(255);

  obj.setFill(color(0));
  obj.scale(0.6);
  shape(obj);

}

Any help is much appreciated.


Viewing all articles
Browse latest Browse all 2896

Trending Articles