FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Beyond Categories
(Moderator: REAS)
   Blossom
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Blossom  (Read 1082 times)
swannodette

swannodette WWW
Blossom
« on: Dec 7th, 2003, 7:53am »

Just throwing something out there.  A very simple branch algorithm.  Was originally annoyingly fractal so I added flowers.
 
link to http://www.onager.org/~dnolen/masha-arbor.jpg to see the image.
 
comments/criticism/suggestions welcome.
 
benelek

35160983516098 WWW Email
Re: Blossom
« Reply #1 on: Dec 7th, 2003, 10:54pm »

nice use of colour.
 
swannodette

swannodette WWW
Re: Blossom
« Reply #2 on: Dec 8th, 2003, 7:27am »

Thanks, the color is what I'm happiest about- just trying to express the familiar in an (hopefully) elegant fashion.   Apologies, I just linked the final image.  Here is the source:
 
//globals
boolean done=false, grabbed=false, base=true, lastone=true;
float rvalue = 60, gvalue = 30;
float ginc1, ginc2, rinc;
int counter=0, counter2=0;
float xsize=30;
float ysize=100;
float ratio=1.25;
float grain=20;
float flstart=((ysize-grain)/3)+grain;
 
void setup() {
  //noFill();
  noStroke();
  smooth();
  float tempsize = ysize;
   
  size(1152, 76;
   
  for(int i=0; tempsize > grain; i++) {
    counter++;
    tempsize/=ratio;
  }
  println(counter);
  rinc = (170-60)/(counter/2.0);
  ginc1 = (80-30)/(counter/2.0);
  ginc2 = (220-80)/(counter/2.0);
  //println(rinc + " " + ginc1 + " " + ginc2);
  background(255, 255, 110);
}
 
void loop() {
    if(!done)
   drawArbor(xsize, ysize, 0, rvalue, gvalue);
    else if(!grabbed) {
   grabbed = true;
   saveFrame();
    } else
   ;
}
 
void drawArbor(float rectxSize, float rectySize, float angle, float rval, float gval) {
    float ny, lefta, righta;
 
    if(base) {
   translate(width-(width/2), height-(height/);
   rotateZ(PI);
   base = false;
    }
    if(rectySize>grain) {
     
   //stroke(rval, gval, 0);
   fill(rval, gval, 0);
   //println(rval + " " + gval);    
   
   if((rval+rinc) < 170) {    //set branch color
     rval += rinc;
     gval += ginc1;
     //println("adding ginc1");
   }
   else if((gval+ginc2) < 220) {
     gval += ginc2;
     //println("adding ginc2");
   }
   
   rectMode(CENTER_DIAMETER);
   
   //translate(x,y);
   rotate(angle);   //rotate at pivot
   ny = (ysize*.95)/2;
   /*if(rectySize>1
     ny = rectySize*.95;
   else
     ny = (ysize*.95)/2;*/
   //println(x + " " + ny + " " + rectxSize + " " + rectySize);
   rect(0, ny, rectxSize, rectySize);  //draw rect
   translate(0, ny);
   
   //flower variation for masha
   /*if(rectySize < flstart) {
  float myRan;
   
  myRan = random(0, 10);
  if(myRan>=9.0) {
      push();
      drawBlossom(rectySize, ny);
      pop();
  }
   }*/
   
   lefta = random(-PI/4, 0);  //set angles for next two branches
   righta = random(0, PI/4);
   push();     //I am very afraid
   drawArbor(rectxSize/ratio, rectySize/ratio, lefta, rval, gval);
   pop();
   push();
   drawArbor(rectxSize/ratio, rectySize/ratio, righta, rval, gval);
   pop();
    } else
   done = true;
}
 
void drawBlossom(float rysize, float center) {
    //float petal1ang, petal2ang, petal3ang, petal4ang, petal5ang;
    float randang, gran;
     
    for(int i=0; i<6; i++) {
 gran = random(60, 200);
 fill(255, (int)gran, 210);
 randang = random(-PI, PI);
 rotateZ(randang);
 rect(0, 0, rysize*.8, rysize*1.5);
    }
}
 
 
 
 
Pages: 1 

« Previous topic | Next topic »