Package heronarts.lx.color
Class LXColor
java.lang.Object
heronarts.lx.color.LXColor
Various utilities that operate on color values
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
add
(int dst, int src) Adds the specified colorsstatic int
add
(int dst, int src, double alpha) Adds the specified colorsstatic int
add
(int dst, int src, int alpha) Adds the specified colorsstatic byte
alpha
(int argb) static float
b
(int rgb) Brightness from 0-100static int
blend
(int dst, int src, LXColor.Blend blendMode) Blends the two colors using specified blend based on the alpha channel of c2static int
blendMask
(double alpha) Returns the alpha multiplication coefficient for a blendstatic 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-100static int
gray
(float brightness) Produces a grayscale color based upon value from 0-100static int
grayn
(double brightness) Produces a grayscale color based upon normalized value from 0-1static int
grayn
(float brightness) Produces a grayscale color based upon normalized value from 0-1static byte
green
(int argb) static float
h
(int rgb) Hue of a color from 0-360static 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 fullstatic final int
hsb
(double h, double s, double b) Utility to create a color from double valuesstatic int
hsb
(float hue, float saturation, float brightness) Create a color from HSBstatic final int
hsba
(double h, double s, double b, double a) Utility to create a color from double valuesstatic int
hsba
(float h, float s, float b, float a) Create a color from HSBstatic 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 Bstatic void
map
(int[] src, int srcNum, int[] dst, int dstNum) Map a pixel buffer onto a buffer of different sizestatic void
map
(int[] src, int srcOffset, int srcNum, int[] dst, int dstOffset, int dstNum) Map a pixel buffer onto a buffer of different sizestatic void
maplerp
(int[] src, int srcNum, int[] dst, int dstNum) Map a pixel buffer onto a buffer of different size, with color interpolationstatic 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 interpolationstatic 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 valuestatic final int
rgba
(int r, int g, int b, int a) Computes an RGB color valuestatic final int
rgbf
(float r, float g, float b) Computes an RGB color value from normalized floating point valuesstatic float
s
(int rgb) Saturation from 0-100static int
scaleBrightness
(int src, double amount) Scales brightness of the color by a fixed amountstatic int
scaleBrightness
(int src, float amount) Scales brightness of the color by a fixed amountstatic 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)
-
Field Details
-
CLEAR
public static final int CLEAR- See Also:
-
BLACK
public static final int BLACK- See Also:
-
WHITE
public static final int WHITE- See Also:
-
RED
public static final int RED- See Also:
-
GREEN
public static final int GREEN- See Also:
-
BLUE
public static final int BLUE- See Also:
-
ALPHA_MASK
public static final int ALPHA_MASK- See Also:
-
R_MASK
public static final int R_MASK- See Also:
-
G_MASK
public static final int G_MASK- See Also:
-
B_MASK
public static final int B_MASK- See Also:
-
RB_MASK
public static final int RB_MASK- See Also:
-
RGB_MASK
public static final int RGB_MASK- See Also:
-
AG_MASK
public static final int AG_MASK- See Also:
-
ALPHA_SHIFT
public static final int ALPHA_SHIFT- See Also:
-
R_SHIFT
public static final int R_SHIFT- See Also:
-
G_SHIFT
public static final int G_SHIFT- See Also:
-
MAX_HUE
public static final int MAX_HUE- See Also:
-
-
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-255g
- Green 0-255b
- 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-1g
- Green 0-1b
- 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-255g
- Green 0-255b
- Blue 0-255a
- 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
- Hues
- Saturationb
- 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
- Hues
- Saturationb
- Brightnessa
- 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-360saturation
- Saturation from 0-100brightness
- 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-360s
- Saturation from 0-100a
- 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-360s
- Saturation from 0-100b
- Brightness from 0-100a
- 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 coloramount
- 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 coloramount
- Amount to scale brightness (0-1)- Returns:
- Color with brightness adjusted
-
blend
Blends the two colors using specified blend based on the alpha channel of c2- Parameters:
dst
- Background colorsrc
- Overlay color to be blendedblendMode
- 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 colorsrc
- 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 colorsrc
- Overlay coloralpha
- 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 colorsrc
- Overlay coloralpha
- 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 buffersrcNum
- Number of source pixelsdst
- Destination bufferdstNum
- 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 buffersrcOffset
- Offset in source buffersrcNum
- Number of source pixelsdst
- Destination bufferdstOffset
- Offset in destination bufferdstNum
- 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 buffersrcNum
- Number of source pixelsdst
- Destination bufferdstNum
- 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 buffersrcOffset
- Offset in source buffersrcNum
- Number of source pixelsdst
- Destination bufferdstOffset
- Offset in destination bufferdstNum
- Number of destination pixels
-