Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

please help nub with arrays and for()

$
0
0
why i cant see diagonal line, instead i see only last rect (300,300)
this my code

Ring myRing;




void setup(){
  size (700, 400);
  background(0);
  myRing = new Ring();
}


void draw() {
myRing.Massive();
myRing.display();
}

class Ring {

 int numPoints; 
 float[] x;
 float[] y;
 float offset;

 Ring(){
 numPoints = 300;
 x = new float[numPoints];
 y = new float[numPoints];
 offset = 8;
 }
 
 void Massive() {
   for (int i = 0; i < x.length; i++) {
   x[i] = i;
   y[i] = i; 
   }
 } 

 void display() {
   for (int i = 0; i < x.length; i++){
   rect(x[i], y[i], 5, 5);
   }
 
 }

}

Viewing all articles
Browse latest Browse all 1768

Trending Articles