Class LXColor

java.lang.Object
heronarts.lx.color.LXColor

public class LXColor extends Object
Various utilities that operate on color values
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Color blending modes
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    add(int dst, int src)
    Adds the specified colors
    static int
    add(int dst, int src, double alpha)
    Adds the specified colors
    static int
    add(int dst, int src, int alpha)
    Adds the specified colors
    static byte
    alpha(int argb)
     
    static float
    b(int rgb)
    Brightness from 0-100
    static int
    blend(int dst, int src, LXColor.Blend blendMode)
    Blends the two colors using specified blend based on the alpha channel of c2
    static int
    blendMask(double alpha)
    Returns the alpha multiplication coefficient for a blend
    static byte
    blue(int argb)
     
    static int
    burn(int dst, int src)
     
    static int
    burn(int dst, int src, double alpha)
     
    static int
    burn(int dst, int src, int alpha)
     
    static int
    darkest(int dst, int src)
     
    static int
    darkest(int dst, int src, double alpha)
     
    static int
    darkest(int dst, int src, int alpha)
     
    static int
    difference(int dst, int src)
     
    static int
    difference(int dst, int src, double alpha)
     
    static int
    difference(int dst, int src, int alpha)
     
    static int
    dodge(int dst, int src)
     
    static int
    dodge(int dst, int src, double alpha)
     
    static int
    dodge(int dst, int src, int alpha)
     
    static int
    gray(double brightness)
    Produces a grayscale color based upon value from 0-100
    static int
    gray(float brightness)
    Produces a grayscale color based upon value from 0-100
    static int
    grayn(double brightness)
    Produces a grayscale color based upon normalized value from 0-1
    static int
    grayn(float brightness)
    Produces a grayscale color based upon normalized value from 0-1
    static byte
    green(int argb)
     
    static float
    h(int rgb)
    Hue of a color from 0-360
    static int
    highlight(int dst, int src)
     
    static int
    highlight(int dst, int src, double alpha)
     
    static int
    highlight(int dst, int src, int alpha)
     
    static final int
    hsa(float h, float s, float a)
    Create a color from HSA, where brightness is always full
    static final int
    hsb(double h, double s, double b)
    Utility to create a color from double values
    static int
    hsb(float hue, float saturation, float brightness)
    Create a color from HSB
    static final int
    hsba(double h, double s, double b, double a)
    Utility to create a color from double values
    static int
    hsba(float h, float s, float b, float a)
    Create a color from HSB
    static int
    lerp(int dst, int src)
     
    static int
    lerp(int dst, int src, double alpha)
     
    static int
    lerp(int dst, int src, float alpha)
     
    static int
    lerp(int dst, int src, int alpha)
     
    static int
    lightest(int dst, int src)
     
    static int
    lightest(int dst, int src, double alpha)
     
    static int
    lightest(int dst, int src, int alpha)
     
    static float
    luminosity(int rgb)
    Luminosity from 0-100, using the quick approximated function: Y = 0.375 R + 0.5 G + 0.125 B
    static void
    map(int[] src, int srcNum, int[] dst, int dstNum)
    Map a pixel buffer onto a buffer of different size
    static void
    map(int[] src, int srcOffset, int srcNum, int[] dst, int dstOffset, int dstNum)
    Map a pixel buffer onto a buffer of different size
    static void
    maplerp(int[] src, int srcNum, int[] dst, int dstNum)
    Map a pixel buffer onto a buffer of different size, with color interpolation
    static void
    maplerp(int[] src, int srcOffset, int srcNum, int[] dst, int dstOffset, int dstNum)
    Map a pixel buffer onto a buffer of different size, with color interpolation
    static int
    multiply(int dst, int src)
     
    static int
    multiply(int dst, int src, double alpha)
     
    static int
    multiply(int dst, int src, int alpha)
     
    static byte
    red(int argb)
     
    static final int
    rgb(int r, int g, int b)
    Computes an RGB color value
    static final int
    rgba(int r, int g, int b, int a)
    Computes an RGB color value
    static final int
    rgbf(float r, float g, float b)
    Computes an RGB color value from normalized floating point values
    static float
    s(int rgb)
    Saturation from 0-100
    static int
    scaleBrightness(int src, double amount)
    Scales brightness of the color by a fixed amount
    static int
    scaleBrightness(int src, float amount)
    Scales brightness of the color by a fixed amount
    static int
    screen(int dst, int src)
     
    static int
    screen(int dst, int src, double alpha)
     
    static int
    screen(int dst, int src, int alpha)
     
    static int
    spotlight(int dst, int src)
     
    static int
    spotlight(int dst, int src, double alpha)
     
    static int
    spotlight(int dst, int src, int alpha)
     
    static int
    subtract(int dst, int src)
     
    static int
    subtract(int dst, int src, double alpha)
     
    static int
    subtract(int dst, int src, int alpha)
     
    static int
    toABGR(int argb)
     

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • LXColor

      public LXColor()
  • Method Details

    • alpha

      public static byte alpha(int argb)
    • red

      public static byte red(int argb)
    • green

      public static byte green(int argb)
    • blue

      public static byte blue(int argb)
    • toABGR

      public static int toABGR(int argb)
    • h

      public static float h(int rgb)
      Hue of a color from 0-360
      Parameters:
      rgb - Color value
      Returns:
      Hue value from 0-360
    • s

      public static float s(int rgb)
      Saturation from 0-100
      Parameters:
      rgb - Color value
      Returns:
      Saturation value from 0-100
    • b

      public static float b(int rgb)
      Brightness from 0-100
      Parameters:
      rgb - Color value
      Returns:
      Brightness from 0-100
    • luminosity

      public static float luminosity(int rgb)
      Luminosity from 0-100, using the quick approximated function: Y = 0.375 R + 0.5 G + 0.125 B
      Parameters:
      rgb - Color value
      Returns:
      Luminosity from 0-100
    • gray

      public static int gray(double brightness)
      Produces a grayscale color based upon value from 0-100
      Parameters:
      brightness - Brightness value from 0-100
      Returns:
      Gray
    • grayn

      public static int grayn(double brightness)
      Produces a grayscale color based upon normalized value from 0-1
      Parameters:
      brightness - Brightness value from 0-1
      Returns:
      Gray
    • gray

      public static int gray(float brightness)
      Produces a grayscale color based upon value from 0-100
      Parameters:
      brightness - Brightness value from 0-100
      Returns:
      Gray
    • grayn

      public static int grayn(float brightness)
      Produces a grayscale color based upon normalized value from 0-1
      Parameters:
      brightness - Brightness value from 0-1
      Returns:
      Gray
    • rgb

      public static final int rgb(int r, int g, int b)
      Computes an RGB color value
      Parameters:
      r - Red 0-255
      g - Green 0-255
      b - Blue 0-255
      Returns:
      Color
    • rgbf

      public static final int rgbf(float r, float g, float b)
      Computes an RGB color value from normalized floating point values
      Parameters:
      r - Red 0-1
      g - Green 0-1
      b - Blue 0-1
      Returns:
      Color
    • rgba

      public static final int rgba(int r, int g, int b, int a)
      Computes an RGB color value
      Parameters:
      r - Red 0-255
      g - Green 0-255
      b - Blue 0-255
      a - Alpha 0-255
      Returns:
      Color
    • hsb

      public static final int hsb(double h, double s, double b)
      Utility to create a color from double values
      Parameters:
      h - Hue
      s - Saturation
      b - Brightness
      Returns:
      Color value
    • hsba

      public static final int hsba(double h, double s, double b, double a)
      Utility to create a color from double values
      Parameters:
      h - Hue
      s - Saturation
      b - Brightness
      a - Alpha
      Returns:
      Color value
    • hsb

      public static int hsb(float hue, float saturation, float brightness)
      Create a color from HSB
      Parameters:
      hue - Hue from 0-360
      saturation - Saturation from 0-100
      brightness - Brightness from 0-100
      Returns:
      rgb color value
    • hsa

      public static final int hsa(float h, float s, float a)
      Create a color from HSA, where brightness is always full
      Parameters:
      h - Hue from 0-360
      s - Saturation from 0-100
      a - Alpha mask from 0-1
      Returns:
      argb color value
    • hsba

      public static int hsba(float h, float s, float b, float a)
      Create a color from HSB
      Parameters:
      h - Hue from 0-360
      s - Saturation from 0-100
      b - Brightness from 0-100
      a - Alpha from 0-1
      Returns:
      argb color value
    • blendMask

      public static int blendMask(double alpha)
      Returns the alpha multiplication coefficient for a blend
      Parameters:
      alpha - Alpha factor from 0-1
      Returns:
      Mask multiplication value from 0x00 to 0x100
    • scaleBrightness

      public static int scaleBrightness(int src, float amount)
      Scales brightness of the color by a fixed amount
      Parameters:
      src - Source color
      amount - Amount to scale brightness (0-1)
      Returns:
      Color with brightness adjusted
    • scaleBrightness

      public static int scaleBrightness(int src, double amount)
      Scales brightness of the color by a fixed amount
      Parameters:
      src - Source color
      amount - Amount to scale brightness (0-1)
      Returns:
      Color with brightness adjusted
    • blend

      public static int blend(int dst, int src, LXColor.Blend blendMode)
      Blends the two colors using specified blend based on the alpha channel of c2
      Parameters:
      dst - Background color
      src - Overlay color to be blended
      blendMode - Type of blending
      Returns:
      Blended color
    • lerp

      public static int lerp(int dst, int src)
    • lerp

      public static int lerp(int dst, int src, double alpha)
    • lerp

      public static int lerp(int dst, int src, float alpha)
    • lerp

      public static int lerp(int dst, int src, int alpha)
    • add

      public static int add(int dst, int src)
      Adds the specified colors
      Parameters:
      dst - Background color
      src - Overlay color
      Returns:
      Summed RGB channels with 255 clip
    • add

      public static int add(int dst, int src, double alpha)
      Adds the specified colors
      Parameters:
      dst - Background color
      src - Overlay color
      alpha - Level of blending from 0-1
      Returns:
      Summed RGB channels with 255 clip
    • add

      public static int add(int dst, int src, int alpha)
      Adds the specified colors
      Parameters:
      dst - Background color
      src - Overlay color
      alpha - Alpha adjustment (from 0x00 - 0x100)
      Returns:
      Summed RGB channels with 255 clip
    • subtract

      public static int subtract(int dst, int src)
    • subtract

      public static int subtract(int dst, int src, double alpha)
    • subtract

      public static int subtract(int dst, int src, int alpha)
    • multiply

      public static int multiply(int dst, int src)
    • multiply

      public static int multiply(int dst, int src, double alpha)
    • multiply

      public static int multiply(int dst, int src, int alpha)
    • screen

      public static int screen(int dst, int src)
    • screen

      public static int screen(int dst, int src, double alpha)
    • screen

      public static int screen(int dst, int src, int alpha)
    • lightest

      public static int lightest(int dst, int src)
    • lightest

      public static int lightest(int dst, int src, double alpha)
    • lightest

      public static int lightest(int dst, int src, int alpha)
    • darkest

      public static int darkest(int dst, int src)
    • darkest

      public static int darkest(int dst, int src, double alpha)
    • darkest

      public static int darkest(int dst, int src, int alpha)
    • difference

      public static int difference(int dst, int src)
    • difference

      public static int difference(int dst, int src, double alpha)
    • difference

      public static int difference(int dst, int src, int alpha)
    • dodge

      public static int dodge(int dst, int src)
    • dodge

      public static int dodge(int dst, int src, double alpha)
    • dodge

      public static int dodge(int dst, int src, int alpha)
    • burn

      public static int burn(int dst, int src)
    • burn

      public static int burn(int dst, int src, double alpha)
    • burn

      public static int burn(int dst, int src, int alpha)
    • highlight

      public static int highlight(int dst, int src)
    • highlight

      public static int highlight(int dst, int src, double alpha)
    • highlight

      public static int highlight(int dst, int src, int alpha)
    • spotlight

      public static int spotlight(int dst, int src)
    • spotlight

      public static int spotlight(int dst, int src, double alpha)
    • spotlight

      public static int spotlight(int dst, int src, int alpha)
    • map

      public static void map(int[] src, int srcNum, int[] dst, int dstNum)
      Map a pixel buffer onto a buffer of different size
      Parameters:
      src - Source buffer
      srcNum - Number of source pixels
      dst - Destination buffer
      dstNum - Number of destination pixels
    • map

      public static void map(int[] src, int srcOffset, int srcNum, int[] dst, int dstOffset, int dstNum)
      Map a pixel buffer onto a buffer of different size
      Parameters:
      src - Source buffer
      srcOffset - Offset in source buffer
      srcNum - Number of source pixels
      dst - Destination buffer
      dstOffset - Offset in destination buffer
      dstNum - Number of destination pixels
    • maplerp

      public static void maplerp(int[] src, int srcNum, int[] dst, int dstNum)
      Map a pixel buffer onto a buffer of different size, with color interpolation
      Parameters:
      src - Source buffer
      srcNum - Number of source pixels
      dst - Destination buffer
      dstNum - Number of destination pixels
    • maplerp

      public static void maplerp(int[] src, int srcOffset, int srcNum, int[] dst, int dstOffset, int dstNum)
      Map a pixel buffer onto a buffer of different size, with color interpolation
      Parameters:
      src - Source buffer
      srcOffset - Offset in source buffer
      srcNum - Number of source pixels
      dst - Destination buffer
      dstOffset - Offset in destination buffer
      dstNum - Number of destination pixels