Help with PShape are setTint() or setFill() working?

I do not know if this should go under "Questions about Code" or "Libraries" Are the setFill() and/or setTint() functionalities working within PShape. I am trying to use wither of the capabilities in the code below and seeing no changes. Am I missing something in my code? Does anybody have any code that uses this functionality? Thanks for all of the help.

void settrans(int trans) { 
  println("Setting TRANSPARENCY to "+trans+" *********************************");
  int braincells = brain.getChildCount();
    for (int cellnum = 0; cellnum < braincells; ++cellnum) {
      tempcell= brain.getChild(cellnum);
      for (int j = 0; j<6; j++) {
        tempface=tempcell.getChild(j);
        //tempface.setFill(quadBG[j]);
        tempface.setTint(trans);
    }}
  shape(brain);}      // Draw the brain

My tracing when I make the calls is : Setting TRANSPARENCY to 255 ********************************* Setting TRANSPARENCY to 88 ********************************* Setting TRANSPARENCY to 255 ********************************* Setting TRANSPARENCY to 88 *********************************

Answers

  • Updated code and removed questions that are no longer needed. Any help would be appreciated.

  • edited April 2014 Answer ✓

    I am also having this issue and am unable to figure it out. However, I do have a work around. Not sure if this solves your problem, but, it might get you closer to your goal.

    It's possible to not use the shape's style methods doing the following,

    color c = color(0xFF333333);
    pushStyle();
      a.disableStyle();
    
      strokeWeight(2);
      stroke(c, 32);
      fill(c, 32);
    
      shape(a);
    
      a.enableStyle();
    popStyle();
    

    Hope this helps. Will post back here if I find a solution.

  • I was never able to set the alpha/transparency, so I did the following work around. I created 2 arrays of colors, one with alpha=255 and another with alpha=88, then used the code below:

    void settrans(boolean trans) { 
      int braincells = brain.getChildCount();
        for (int cellnum = 0; cellnum < braincells; ++cellnum) {
          tempcell= brain.getChild(cellnum);
          for (int j = 0; j<6; j++) {
            tempface=tempcell.getChild(j);
            if (trans) { tempface.setFill(quadBGtinted[j]);}
            else { tempface.setFill(quadBG[j]);}}}
       shape(brain);}      // Draw the brain
    
  • hi, I would like to bump this thread. I cant find a way to get setFill() working either.

  • edited January 2015

    did you read the tutorial?

    i don't know about alpha, but setfill works, just use it with color explicitly.

  • I am sorry that I do not understand your solution.
    When you say use the color explicitly, what do you mean? quadBG and qadBGtinted are two different arrays with the color for the background, with tinted having a different alpha value. How do I do this using the color explicitly? Thanks for the help.

Sign In or Register to comment.