getColors

getColors()

Returns all colours packed into an ARGB number. Each component takes up one byte, and can be retrieved using bit-shifting and bit-wise and.

The alpha value is included for completeness, and is stored as a value from 0 to 255.

setColor( :pink )

argb = getColors()
alpha = (argb >> 24) & 0xFF
red   = (argb >> 18) & 0xFF
green = (argb >>  8) & 0xFF
blue  =  argb        & 0xFF

// outputs: [255, 255, 0, 102]
console([ alpha, red, green, blue ])

getColors() { |red, green, blue, alpha| ... }

The current colour, and alpha value, used when drawing is yielded into the attached block. Unlike the previous version of getColors, the alpha value is a value from 0.0 to 1.0, like it is in all other places in the API.

setColor( :pink )

getColors() do |red, green, blue, alpha|
    // outputs: [1, 255, 0, 102]
    console([ alpha, red, green, blue ])
end

See also

setColor - getAlpha - getRed - getGreen - getBlue