Convertion of an array of values to an int
in
Contributed Library Questions
•
11 months ago
Hello ! I'm new with processing and especially with the library TuioZones. I'm trying for hours to put my loop of values (xvalues and yvalues) into int to be able after this to call them into my zones.setZone("zone1", ..., ..., ..., ...);
I would like to be able to use my circle of ellipses as a zone...
Can someone help ?
Heres my code :
import tuioZones.*;
TUIOzoneCollection zones;
PImage b;
int xspacing = 17;
int w;
float theta = 0;
float amplitude ;
float period = 1200;
float dx;
float[] yvalues;
float[] xvalues;
float x = theta;
void setup(){
size(displayWidth,displayHeight);
// create a draggable, throwable, and scalable zone for a photo
zones=new TUIOzoneCollection(this);
zones.setZone("zone1",10,10,w/xspacing,w/xspacing);
zones.setZoneParameter("zone1","DRAGGABLE",true);
zones.setZoneParameter("zone1","THROWABLE",true);
zones.setZoneParameter("zone1","SCALABLE",true);
noFill();
smooth();
w = width;
amplitude = 300;
dx = (TWO_PI / period) * xspacing; // PI = LIGNE / TWO_PI = CERCLE
yvalues = new float[w/xspacing];
xvalues = new float[w/xspacing];
}
void draw(){
background(0);
// use the zone coordinates and size to display the image
zones.getZoneX("zone1");
zones.getZoneY("zone1");
zones.getZoneWidth("zone1");
zones.getZoneHeight("zone1");
// outline photo when pressed
if (zones.isZonePressed("zone1")) {
stroke(200,200,0);
strokeWeight(4);
renderWave();
}
}
calcWave();
renderWave();
}
void calcWave() {
theta += 0.02; // Incrémentation qui permet la rapidité du mouvement
for (int i = 0; i < yvalues.length; i++) {
yvalues[i] = sin(x)*amplitude;
xvalues[i] += sin(x)*4;
x+=dx;
}
}
void renderWave() {
stroke(255);
noFill();
strokeWeight(3);
for (int x = 0; x < yvalues.length; x++){
ellipse(height/2+xvalues[x], height/2+yvalues[x], 16, 16);
}
}
1