// defines the attributes of a section // class Attributes { Attributes parent; color fillColor; color c1, c2; float maxW; // maxwidth String s; String stringArray []; String type; ///// Define colours ///// // use color LUT ??? float unitLength;// how long (in time) each F section of the segment is float sineLength; // how long the sine curve is for each line (degrees) float deviation; float angle;// = 90; // (spin); / default valuel boolean blur = false; //////////////////////////////////////////////////////////// // additional elements ////// int petalNum;//= 15; float petalAngle;// = 45; float lo ; // random (200); float hi ;//random (200); float sineStart; float minWidth; float shapeNoise; // distortion of sine wave //////////////////////////////////////////////////////////////// int arrayPosition; // keeps track of where this Attribute is within an array or arraylist boolean followParentColor; ///////////////////////////// float flowerDeviation; //// // float aliveTime; //float leafWidthDeviation; /// PARENT ATTRIBUTE (flower and branch) //////// Attributes (String t, String [] s_, color c1_, color c2_, int pNum, float pAngle, float lo_, float hi_, float mw, float fL, boolean spin) { type= t; stringArray = s_; c1 = c1_; c2 = c2_; petalNum = pNum; petalAngle = pAngle; hi = hi_; lo = lo_; //////////// maxW = mw; // needed for branch parent unitLength = fL; // needed for branch parent ///// /////////// sineStart = stemSineStart; // default for branch sineLength = stemSineLength; // default for branch minWidth = .5; // default for branch deviation = 0; // defaulf for branch ///////////////////////////////////////// fillColor = colorBlend (c1, c2, random (1)); //println ("new fillColor " + type); // println ("arrayPos for " + type + " = " + arrayPosition); //angle = spinAngle; if (spin) { angle = 30;//random (30, 100); } else { angle = 90; // flat } getData(); shapeNoise = 0; ////// add alive time ?? //aliveTime = aRandomNumber; } /// CHILD ATTRIBUTE ///// Attributes (Attributes p, String t, String [] s_, float sStart, float sL, float minW, float maxW_, float dev, float sn, float Flength) { parent = p; // find parent attribute /// inherited attributes //////// c1 = p.c1; c2 = p.c2; lo = p.lo; hi = p.hi; fillColor = p.fillColor; // println ("lo = " + lo); petalNum = p.petalNum; petalAngle = p.petalAngle; ////////////////////////////// angle = p.angle; /////////////////////////// type = t; stringArray = s_; sineStart = sStart; sineLength = sL; minWidth = minW; maxW = maxW_; deviation = dev; unitLength = Flength; //angle= 30; //angle = 30; getData(); shapeNoise = sn; /// //aliveTime = aRandomNumber; } ////////////////////////////////////// Attributes () { } //////////////////////////////////// void setFLength (float factor ) { unitLength *= .95; //sineLength = 90; //s = "FFFFFFFFF*"; } /////////////////////////////////////////////////////////////// void setValues () { if (type == "stem") { } if (type == "leaf") { //followParentColor = } if (type == "branch") { } if (type == "flower") { } if (type == "petal") { } } ///////////////////////////////////// color colorBlend (color c1_, color c2_, float fract) { // take 2 colours and blend them /// get r, g, b ///////// float r1 = red (c1_); float g1 = green (c1_); float b1 = blue (c1_); //////////////////// float r2 = red (c2_); float g2 = green (c2_); float b2 = blue (c2_); //////////////////////// r2 = (r2 - r1); g2 = (g2 - g1); b2 = (b2 - b1); return color(r1 + r2 * fract, g1 + g2 * fract, b1 + b2 * fract); } ////////////////////////////////////////////////// void getData ( ) { if (printdata) { dataOutput.println (type + " attributes"); if (parent != null) { dataOutput.println ("parent: " + parent.type); } else { dataOutput.println ("parent: " + parent);// outputs "parent: null" } for (int i=0; i