/* Chunk 46 - Line Pattern Generator Rosie Wood Msrch 2009 */ int numLines=20; int stepH=0; int stepW=0; int n=0; int x=0; int y=0; int rannum=3; int rannum2=0; int design=1; int patsPerPic=5; int count=0; int drawCount=0; boolean [] segments={false,false,false,false,false,false,false,false}; void setup(){ size(400, 400); //colorMode(HSB,230,1,200); stepH=height/numLines; stepW=width/numLines; strokeWeight(1); smooth(); frameRate(30); } void draw(){ patsPerPic=round(random(2,7)); background(0); count=0; n=0; int choice=0; boolean started=false; while(count50)drawCount=0; String fName="line"+drawCount+".gif"; save(fName); } void changeColour(){ stroke(random(255),random(255),random(255),random(255)); } //patterns void triangle1(){//3 choices if(rannum==0||rannum==2){ line(0,x,y,height); line(height,height-x,y,0); if(rannum==1||rannum==2){ line(width,y,height-x,height); line(0,y,x,0); } } } void stripes(){ if(rannum==0||rannum==2){ line(width,height-y,y,0);//stripes line(0,height-y,y,height); } if(rannum==0||rannum==2){ line(width-y,0,0,height-y);//stripes line(width,height-y,width-y,height); } } void stripes2(){ if(rannum==1||rannum==0){ line(x,y,width,y); } if(rannum==2||rannum==0){ line(x,height-y,x,0); } } void bowTie(){ if(rannum==1||rannum==0){ line(x,height,width-x,0);} if(rannum==2||rannum==0){ line(0,y,width,height-y);} } void bigArches(){ rannum=0; if(rannum==1||rannum==0){ line(x,0,width,x);//large mesh ur line(0,y,y,width);} if(rannum==2||rannum==0){ line(0,height-y,y,0);//large mesh u l line(width,height-y,y,height);} } void butterfly(){ if(rannum==1||rannum==0){ line(x,height-y,width-x,0); line(x,y,width-x,height);} if(rannum==2||rannum==0){ line(width,width-y,x,y);//butterfly r line(0,y,x,height-y);}} void inwards(){ line(0,0,height-y,y);//inwards l d line(width,height,y,height-y);//inwards r u line(0,height,y,y);//inwards l u line(width,0,y,y);//inwards r d } void tapestry(){ if(rannum==1||rannum==0) line(x,height,y,0); if(rannum==2||rannum==0) line(height,height-y,0,x);//tapestry } void triangle3(){ if(rannum==1||rannum==0){ line(0,0,y,height);//ray uld line(0,0,width,height-y);//ray ulr line(width-x,0,width,height);//ray d r u line(0,y,width,height);//ray d r l } if(rannum==2||rannum==0){ line(width,0,0,height-y);//ray u r l line(width,0,height-y,height);//ray u r d line(0,height,width-x,0);// dl u line(0,height,width,height-y);//ray d l r }} void oops(){ println(segments); if(segments[0]==true){ line(0,height-y,y,y);}//oopsleft down if(segments[1]==true){ line(width-x,0,x,x);}//oopsup right if(segments[2]==true){ line(x,0,width-x,x);}//oopsup left if(segments[3]==true){ line(width,y,y,height-y);}//oopsright down if(segments[4]==true){ line(width,height-y,y,y);}//oopsrightup if(segments[5]==true){ line(width-x,height,x,x);}//oopsdown left if(segments[6]==true){ line(x,height,width-x,x);}//oopsdown right if(segments[7]==true){ line(0,y,y,height-y);}//oopsleft up } void segs1(){ if(rannum==0||rannum==1){ line(0,height-y,y,y);//oopsleft down line(0,y,y,height-y);//oopsleft up line(width,height-y,y,y);//oopsrightup line(width,y,y,height-y);//oopsright down } if(rannum==0||rannum==2){ line(x,0,width-x,x);//oopsup left line(x,height,width-x,x);//oopsdown right line(width-x,0,x,x);//oopsup right line(width-x,height,x,x);//oopsdown left } } void segs2(){ if(rannum==0||rannum==1){ line(width,y,y,height-y);//oopsright down line(0,y,y,height-y);//oopsleft up line(x,0,width-x,x);//oopsup left line(x,height,width-x,x);//oopsdown right } if(rannum==0||rannum==2){ line(0,height-y,y,y);//oopsleft down line(width,height-y,y,y);//oopsrightup line(width-x,0,x,x);//oopsup right line(width-x,height,x,x);//oopsdown left }} void resetSegs(){ for(int n=0;n