Code:import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
int[][] a;
boolean hide;
Object[] oba;
void setup(){
size(800,600);
//frameRate(1);
smooth();
strokeWeight(10);
oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("127.0.0.1",12000);
}
int[] yourIntArray;
void oscEvent(OscMessage theOscMessage) {
if(theOscMessage.checkAddrPattern("/test")==true) {
yourIntArray = new int[theOscMessage.arguments().length];
for(int i=0;i<theOscMessage.arguments().length;i++) {
yourIntArray[i] = theOscMessage.get(i).intValue();
}
}
}
void draw(){
background(100);
osc2();
if(hide){
groad();
}
}
void osc2(){
a = new int[yourIntArray.length][];
for(int i=0;i<yourIntArray.length;i++) {
a[i] = yourIntArray[i];}
}
void keyPressed(){
if (key == 'h' || key =='H') {
hide = !hide;
println("switch box");
}
}
void groad(){
for(int i=0;i<a.length;i++){
//中点++++++++++++++++++++++++++++++++++++++++++
int pointX2 = a[i][0] + a[i][2]/2;
int pointY2 = a[i][1] + a[i][3]/2;
println(a[i][3]);
//点面积++++++++++++++++++++++++++++++++++++++++++
int totalLenght=a[i][2]+a[i][3];
if(totalLenght >= 250){
totalLenght = 250;
}
if(totalLenght <= 20){
totalLenght = 20;
}
//边框++++++++++++++++++++++++++++++++++++++++++
if(hide){
stroke(255,0,0);
rect(a[i][0], a[i][1], a[i][2], a[i][3]);
}
//线条++++++++++++++++++++++++++++++++++++++++++
if(i!=0){
int totalLenght1=a[i-1][2]+a[i-1][3];
if(totalLenght1>=70 && totalLenght>=70){
int pointX1 = a[i-1][0] + a[i-1][2]/2;
int pointY1 = a[i-1][1] + a[i-1][3]/2;
int val=1;
int step=6;
for(int j=0;j<step;j++){
int lineWidth=val*j;
int alpha=100-100/step*j;
stroke(50,150,255,alpha);
line( pointX1+lineWidth,pointY1-lineWidth,pointX2+lineWidth, pointY2-lineWidth);
line( pointX1-lineWidth,pointY1+lineWidth,pointX2-lineWidth, pointY2+lineWidth);
}
}
}
//圆形++++++++++++++++++++++++++++++++++++++++++
int dia=totalLenght/4;
int val2=6;
int step2=totalLenght/5;
noStroke();
fill(255,255-255/dia*2);
ellipse(pointX2, pointY2,dia, dia);
for(int j=0;j<step2;j++){
noFill();
int diameter=dia+val2*j;
int alpha=150-150/step2*j;
stroke(0, 150, 255,alpha);
ellipse(pointX2, pointY2, diameter, diameter);
}
}
}
thanks sojamo first
void osc2(){
a = new int[yourIntArray.length][];
for(int i=0;i<yourIntArray.length;i++) {
a[i] = yourIntArray[i];}
}
but I want to get the int[][]
osc message come from
globBoxes()
returns a list of bounding boxes for each glob.
this is a list of rects.
Lingo: [rect,rect,rect]
Java: int[][4]
you can use this like int[][] a= m.globBoxes();
it can works on void groad();
now It get int[]
how I can bulid the int[][];
void osc2(){
a = new int[yourIntArray.length][];
for(int i=0;i<yourIntArray.length;i++) {
a[i] = yourIntArray[i];}
}
this is not working
void osc2(){
a = new int[yourIntArray.length][4];
for(int i=0;i<yourIntArray.length;i++) {
for(int j=0; j<4;j++){
a[i][j] = yourIntArray[i];}
}
}
this is working but the result is not like int[][] a= m.globBoxes();
@_@b