Class ColourUtils

java.lang.Object
org.pepsoft.util.ColourUtils

public final class ColourUtils extends Object
Utility methods for working with int 0xrrggbb encoded colour values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isGreyScale(int colour)
     
    static int
    mix(int colour1, int colour2)
    Mix two colours by mixing their red, green and blue components exactly equally.
    static int
    mix(int colour1, int colour2, int alpha)
    Mix two colours by mixing their red, green and blue components according to an alpha value between 0 and 256 (inclusive), where an alpha of 0 results in just colour1 and 256 in just colour2.
    static int
    multiply(int colour, int amount)
    Multiplies each of component of colour with amount and divides the result by 256.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • mix

      public static int mix(int colour1, int colour2)
      Mix two colours by mixing their red, green and blue components exactly equally. This is a convenience method for calling mix(colour1, colour2, 128).
    • mix

      public static int mix(int colour1, int colour2, int alpha)
      Mix two colours by mixing their red, green and blue components according to an alpha value between 0 and 256 (inclusive), where an alpha of 0 results in just colour1 and 256 in just colour2.
    • multiply

      public static int multiply(int colour, int amount)
      Multiplies each of component of colour with amount and divides the result by 256.
      Parameters:
      colour - The RGB colour to multiply.
      amount - The amount to multiply each colour band with, where 256 leaves the colour unchanged.
      Returns:
      The multiplied colour.
    • isGreyScale

      public static boolean isGreyScale(int colour)