How do you use the tint(0,0,0); command?

edited January 2018 in How To...

I'm trying to create a little effect in my game and i need to use the tint command for it.

What I want to know is how to create a pulse from 50% opacity to 100% opacity.

Can somebody help me?

Tagged:

Answers

  • Answer ✓

    For reference on using opacity see the second example for the tint command: https://processing.org/reference/tint_.html

    As for making the opacity pulse, how about using the system variable "frameCount" (https://processing.org/reference/frameCount.html) in your draw() loop. For example:

    PImage img;
    
    void setup() {
      size(600,600);
      img = loadImage("https://upload.wikimedia.org/wikipedia/en/7/78/Small_scream.png");
      frameRate(20);
    }
    
    void draw() {
      noTint(); // No tint and no transparency
      image(img, 0, 0);
    
      tint(0, 153, 204, (frameCount % 15) * 17);  // Tint blue and set transparency
      image(img, 200, 200);
    }
    
  • Thank you so much for your reply, but when I do that, the whole screen and every image turns transparent. How do I set all the other images to full opacity, but my main image that I want to put that effect on, transparent?

    -DeTjomas

  • edited January 2018

    For any change you want to do to one element or a selected element, like:

    • color one thing
    • tint one thing
    • scale one thing
    • rotate one thing

    There are a few ways to do this. Here are two:

    1. Use pushStyle / popStyle for e.g. color/tint, use pushMatrix / popMatrix for scale/rotation.
    2. Set the tint before you draw your thing, then set it back to what it was before after.

    These have the same effect. popStyle automatically sets the tint back to whatever it was before you called pushStyle.

Sign In or Register to comment.