Define recursive functions: Creates a set of nested shapes - gradient in size, brightness
Include Logic to determine changing brightness, changing size for each layered shape.
posRecursivePattern( float len, color c1, color c2)
negRecursivePattern( float len, color c1, color c2)
Define Positive, Negative Pattern Functions
Define functions: Creates 1 pattern - at current mouse position, Gradients in color and size across the positive region
positivePattern( float balancePoint, int mX )
negativePattern( float balancePoint, int mX)
Example Code
float minSize, maxSize;float balancePoint;voidsetup(){size( 600,600);colorMode( HSB,360,100,100,100);background(0);//only set one time minSize =10; maxSize =60; balancePoint = width/2; //start at middle of canvas}voiddraw(){if(mousePressed){translate( mouseX, mouseY);//translate origin to mouse positionfor( int angle =0; angle<360; angle +=45){rotate( radians( angle));positivePattern( balancePoint, mouseX); } //end forresetMatrix(); } //end if-mousePressed}//end of draw//determine current size, color: gradients across the positive regionvoidpositivePattern( float balancePoint,int mX){ color cPos1 =color( 280,100,100); //purple color cPos2 =color( 80,100,100); //lime//define curColor based on mX relative to balancePointfloat fraction =map( mX, balancePoint, width,0.0,1.0); color curColor =lerpColor( cPos2, cPos1, fraction); //fraction varies beteween 0.0, 1.0float curSize =map( mX, balancePoint, width, minSize, maxSize );posRecursivePattern( curSize, curColor);}//Draws a single motif - nested size and color gradientvoidposRecursivePattern( float size, color c1){//termination testif(size < minSize){return; }//taskfloat fraction =map( size, minSize, maxSize,0.2,1.0); //may want to customize color curColor =color( hue(c1), saturation( c1), brightness(c1)*fraction);PShape s1 =customPosShape( size, curColor); //test the shapeshape(s1,0,0); //render the shape at the origin//recursive callposRecursivePattern( size *0.8, c1); //task - with reversed stacking - mirror across originpushMatrix();scale( -1,-1);//mirror across the x, y axis (origin)shape( s1,0,0);popMatrix();}//Draws a single shapePShapecustomPosShape( float len, color c1){PShape s; //declare our first object-type variable //heap - object memoryfill( c1);//attempt to set color for the shape s =createShape( );//initialize our shapes.beginShape();s.vertex( 0,0 ); //1 x, y pointss.vertex(.5* len ,0 ); //2s.vertex(len ,.5* len ); //3s.vertex(.5* len , len );//4s.vertex( 0,.5* len ); //5s.vertex( 0,0 ); //6s.beginContour(); //make internal cutout s.vertex( len*.25,len*.45); //inner cutouts - point 5s.vertex(len*.6, len*.6); // s.vertex( len*.45, len*.25); // s.vertex(0,0);s.endContour(); //end internal cutouts.endShape();//shape( s, 0,0); //render to the canvasreturn s; //return the PShape}