Example
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com

// Example 1-4: Alpha Transparency
size(200,200);
background(0);
noStroke();

// No fourth argument means 100% opacity.
fill(0,0,255);
rect(0,0,100,200);

// 255 means 100% opacity.
fill(255,0,0,255);
rect(0,0,200,40);

// 75% opacity.
fill(255,0,0,191);
rect(0,50,200,40);

// 55% opacity.
fill(255,0,0,127);
rect(0,100,200,40);

// 25% opacity.
fill(255,0,0,63);
rect(0,150,200,40);
  • temb

    By 55%, you mean 50% right? (Or actually 49.8?)

  • Steven Zajac

    Hello,

    Per the fill() reference page ( http://processing.org/reference/fill_.html ), we have the option of using fill() a few different ways, including fill( rgb ) and fill( rgb, alpha ).

    We have the option of entering rgb as a #RRGGBB number or a 0xAARRGGBB value. Now, with hex, the first two values (after x) represent the alpha. If we use hexadecimal “rgb” in the fill(rgb, alpha) form of fill(), what happens?

    Does the hex alpha override the 2nd parameter, or vice versa?

    I answered my own question. With the form, fill( rgb, alpha ), entering rbg as hex, fill() will ignore the alpha defined in the hex value, but process the alpha defined as the second parameter. Just posting for reference if anyone else stumbles across this.