Deren Guler- Project1(gauntlet)
int[] xvalues= new int[9]; int[] xvalues= new int[9]; int[] yvalues = new int[9]; int[] yoldvalues = new int[9]; float slope1 = 0; float slope2; int[] yfixed= new int[8]; float xoff = 0.05; int numCircles = 8; Circle[] circles = new Circle[numCircles]; void setup() { size(600, 600); for (int i=0; i<numCircles; i++) { circles[i] = new Circle(random(width),random(height)); // fill the array with circles at random positions } //pick first random y point xvalues[0] = 0; //define boundary for first point xvalues[1] = int(random(50, 100)); xvalues[8]=600;// so the last line goes to the end of the box yfixed[0] = int(random(50, 100)); //make grid of x and y points, first and last x point are set for (int i=2; i< 8; i++) { //make each new point within limits of the one before and divison xvalues[i] = int(random(xvalues[i-1] + 20, ((600 * i)/7))); //pick the next number between the a fraction of the space and the point before, but not too close } //first y point is constrained so that lines dont intersect for (int j=1; j< 8; j++) { yfixed[j] = int(random(yfixed[j-1] + 50, ((600 * j)/7)) ); } for (int j=0; j< 9; j++) { yoldvalues[j] =0; } } void draw() { background(255); //draw random circles for (int i=0; i<numCircles; i++) { circles[i].display(); // display all the circles } //cycle through fixed y grid for (int p=0; p < 8; p++){ // create array of points that deviate around grid yfixed for(int k=0; k<9; k++){ yvalues[k] = yfixed[p]+ int(random(-10 ,10)); } for (int l=0; l < 8; l++){ line(xvalues[l], yvalues[l] , xvalues[l+1], yvalues[l+1]); //draw bands row by row int tofillornot= int(random(3)); // fill some parts with lines, leave others blank if (tofillornot == 1 && l < 7) { //fill with vertical lines but not the first and last one since the slope of that is fixed slope1 = (float((yoldvalues[l+1]- yoldvalues[l]))/ float((xvalues[l+1] - xvalues[l]))); //slope between parts of the segment slope2 = (float((yvalues[l+1]- yvalues[l]))/ float((xvalues[l+1] - xvalues[l]))); //slope between parts of the segment int numvertlines = int(random(20)); //some number of vertical lines float ycepta= yoldvalues[l] - (slope1 * xvalues[l]); float yceptb= yvalues[l+1] - (slope2 * xvalues[l+1]); for (int m = 0; m < numvertlines; m ++){ //pick some x and y points and find their pairs using the slope of the bands int x1 = int(random(xvalues[l], xvalues[l+1])); float ycept1 = ycepta + (slope1 * x1); //y = mx+b float ycept2 = yceptb + (slope2 * x1); line(x1, ycept1,x1, ycept2); //draw vertical lines } } if (tofillornot == 2) { //fill with diagonal lines slope1 = (float((yoldvalues[l+1]- yoldvalues[l]))/ float((xvalues[l+1] - xvalues[l]))); //slope between parts of the segment slope2 = (float((yvalues[l+1]- yvalues[l]))/ float((xvalues[l+1] - xvalues[l]))); //slope between parts of the segment int numvertlines = int(random(20)); //some number of vertical lines float ycepta= yoldvalues[l] - (slope1 * xvalues[l]); //y intercepts for the different slopes float yceptb= yvalues[l+1] - (slope2 * xvalues[l+1]); for (int m = 0; m < numvertlines; m ++){ //pick some x and y points and find their pairs using the slope of the bands int x1 = int(random(xvalues[l], xvalues[l+1])); int x2 = int(random(xvalues[l], xvalues[l+1])); float ycept1 = ycepta + (slope1 * x1); //y = mx+b for top and bottom float ycept2 = yceptb + (slope2 * x2); line(x1, ycept1,x2, ycept2); //draw diagonal line } } } noLoop(); //don't repeat randoms for (int j=0; j< 9; j++) { yoldvalues[j] = yvalues[j]; } } //end of p loop } //call to draw circles class Circle { float x,y; // location float dim; // dimension Circle(float x, float y) { this.x = x; this.y = y; dim = random(20,90); //not too big, not too small } void display() { ellipse(x,y,dim,dim); // a circle at position xy } } |
Comments Off on Deren Guler- Project1(gauntlet)