in _theProject

mycelium tectonics, a processing code.

My code has reached version 1.0 and here I am to explain some new features and change log.

 change.LOG:
 1.0 > select folder to upload substrate space >> cpSel_Sub()
       creation of run() and runSurface()
       title at the beginning
       agent_data no more > all agent information are stored in substrate_data/"subfolder"
       export CSV > add "name" and "frameCount"
       temporary info > sPrint: string to print & toPrint: boolean to activate print procedure 
 0.9 > export file image+mesh+parameters in a subfolder /export-data/YYYYMMDD

I found very usefull the possibility to choose different substrates at the beginning of the sketch, playing the simulation with some parameters and run again the sketch without changing them.
The controlP5 library and the class listBox let me the chance to look into a system folder and choose a different substrate at any time.

firstRun
Here some code add to setup

String Path = sketchPath("substrate_data/");
Path = Path.replace('\\', '/');    // reference 1 & 2
File dirToOpen = new File(Path); 
s = dirToOpen.list(); // s[] array of strings

The function cpSel_Sub() drawn until an item is choosen

void cpSel_Sub() {
  ListBox l;
  int cnt = 0;

  l = cpSel.addListBox("substrate_folder")
    .setPosition(width/2-150, height/2)
      .setSize(300, 150)
        .setItemHeight(15)
          .setBarHeight(20)
            .setColorBackground(color(140, 140, 140, 1))
              .setColorActive(color(140, 140, 240, 30))
                .setColorForeground(color(140, 140, 180, 80))
                  ;

  l.captionLabel().toUpperCase(true);
  l.captionLabel().setSize(10);
  l.captionLabel().set("choose a type of substrate");
  l.captionLabel().setColor(color(0, 0, 0));
  l.captionLabel().style().marginTop = 3;
  l.valueLabel().style().marginTop = 3;

  for (int i=0; i < s.length-1;i++) {
    l.addItem(s[i], i); // add every string s[i] to the listbox 
  }
}

And the controlEvent() called when the mouse choose a substrate from the listBox

void controlEvent(ControlEvent theEvent) {
  if (firstRUN) {  
    if (theEvent.isGroup()) {
      String myPath = "substrate_data/"+s[(int) theEvent.group().value()]+"/" ;
      println(theEvent.group().value()+" from "+theEvent.group());
    }
  }
}

myPath is the variable used in the rest of the sketch.

substrateTest
substrateTes01t

Write a Comment

Comment