Array question
in
Programming Questions
•
3 months ago
Hello,
a rectangle should be displayed at a specified position:
float[] xpos=new float[10];
float[] ypos=new float[10];
int boxh;
void setup() {
size(displayWidth, displayHeight);
boxh=width/20;
float[] xpos= {
width/10, width/10+boxh, width/10+boxh+boxh,
width/10+boxh+boxh+boxh, width/10+boxh+boxh+boxh+boxh, width/10+boxh+boxh+boxh+boxh+boxh,
width/10+boxh+boxh+boxh+boxh+boxh+boxh+boxh,
width/10+boxh+boxh+boxh+boxh+boxh+boxh+boxh+boxh,
width/10+boxh+boxh+boxh+boxh+boxh+boxh+boxh+boxh+boxh
};
float[] ypos= {
height*0.3, height*0.3+boxh, height*0.3+boxh+boxh,
height*0.3+boxh+boxh+boxh, height*0.3+boxh+boxh+boxh+boxh,
height*0.3+boxh+boxh+boxh+boxh+boxh, height*0.3+boxh+boxh+boxh+boxh+boxh+boxh,
height*0.3+boxh+boxh+boxh+boxh+boxh+boxh+boxh,
height*0.3+boxh+boxh+boxh+boxh+boxh+boxh+boxh+boxh,
height*0.3+boxh+boxh+boxh+boxh+boxh+boxh+boxh+boxh+boxh
};
}
void draw() {
rect(xpos[5], ypos[9], boxh, boxh);
}
The box is always on the top left corner (0.0,0.0).
1