alpha.js
No description.

File Location

/goog/color/alpha.js


Public Protected Private

Global Functions

goog.color.alpha.extractAlpha(colorWithAlpha) string
Gets the alpha color part of an alpha hex color. For example, from '#abcdef55' return '55'. The result is guaranteed to be two characters long.
Arguments:
colorWithAlpha : string
The alpha hex color to get the hex color from.
Returns: string  The hex color where the alpha part has been stripped off.
code »
goog.color.alpha.extractHexColor(colorWithAlpha) string
Gets the hex color part of an alpha hex color. For example, from '#abcdef55' return '#abcdef'.
Arguments:
colorWithAlpha : string
The alpha hex color to get the hex color from.
Returns: string  The hex color where the alpha part has been stripped off.
code »
goog.color.alpha.hexToRgba(hexColor) !Array
Converts an 8-hex representation of a color to RGBA.
Arguments:
hexColor : string
Color to convert.
Returns: !Array  array containing [r, g, b, a]. r, g, b are ints between 0 and 255, and a is a value between 0 and 1.
code »
goog.color.alpha.hexToRgbaStyle(hexColor) string
Converts a hex representation of a color to RGBA.
Arguments:
hexColor : string
Color to convert.
Returns: string  string of the form 'rgba(R,G,B,A)' which can be used in styles.
code »
goog.color.alpha.hslaArrayToHex(hsla) string
Converts a color from HSLA to hex representation.
Arguments:
hsla : Array.<number>
Array of [h, s, l, a], where h is an integer in [0, 360], s and l are integers in [0, 100], and a is in [0, 1].
Returns: string  hex representation of the color, such as '#af457eff'.
code »
goog.color.alpha.hslaArrayToRgbaStyle(hsla) string
Converts a color from HSLA to an RGBA style string.
Arguments:
hsla : Array.<number>
Array of [h, s, l, a], where h is and integer in [0, 360], s and l are integers in [0, 100], and a is in [0, 1].
Returns: string  An 'rgba(r,g,b,a)' string ready for use in a CSS rule.
code »
goog.color.alpha.hslaToHex(hsla) string
Converts a color from HSLA to hex representation.
Arguments:
h : number
Amount of hue, int between 0 and 360.
s : number
Amount of saturation, int between 0 and 100.
l : number
Amount of lightness, int between 0 and 100.
a : number
Amount of alpha, float between 0 and 1.
Returns: string  hex representation of the color.
code »
goog.color.alpha.hslaToRgba(hsla) !Array.<number>
Converts a color from HSLA color space to RGBA color space.
Arguments:
h : number
Amount of hue, int between 0 and 360.
s : number
Amount of saturation, int between 0 and 100.
l : number
Amount of lightness, int between 0 and 100.
a : number
Amount of alpha, float between 0 and 1.
Returns: !Array.<number>  [r, g, b, a] values for the color, where r, g, b are integers in [0, 255] and a is a float in [0, 1].
code »
goog.color.alpha.hslaToRgbaStyle(hsla) string
Converts a color from HSLA to an RGBA style string.
Arguments:
h : number
Amount of hue, int between 0 and 360.
s : number
Amount of saturation, int between 0 and 100.
l : number
Amount of lightness, int between 0 and 100.
a : number
Amount of alpha, float between 0 and 1.
Returns: string  An 'rgba(r,g,b,a)' string ready for use in a CSS rule. styles.
code »
goog.color.alpha.hsvaArrayToHex(hsva) string
Converts from an HSVA array to a hex string
Arguments:
hsva : Array
Array of [h, s, v, a] in [[0, 1], [0, 1], [0, 255], [0, 1]].
Returns: string  hex representation of the color.
code »
goog.color.alpha.hsvaToHex(hsva) string
Converts from h,s,v,a values to a hex string
Arguments:
h : number
Hue, in [0, 1].
s : number
Saturation, in [0, 1].
v : number
Value, in [0, 255].
a : number
Alpha, in [0, 1].
Returns: string  hex representation of the color.
code »
goog.color.alpha.isNormalizedAlphaHexColor_(str) boolean
Checks if a string is a normalized alpha hex color. We expect strings of the format #RRGGBBAA (ex: #1b3d5f5b) using only lowercase letters.
Arguments:
str : string
String to check.
Returns: boolean  Whether the string is a normalized hex color.
code »
goog.color.alpha.isValidAlphaHexColor_(str) boolean
Checks if a string is a valid alpha hex color. We expect strings of the format #RRGGBBAA (ex: #1b3d5f5b) or #RGBA (ex: #3CAF == #33CCAAFF).
Arguments:
str : string
String to check.
Returns: boolean  Whether the string is a valid alpha hex color.
code »
goog.color.alpha.isValidHslaColor_(str) !Array.<number>
Checks if a string is a valid hsla color. We expect strings of the format 'hsla(h, s, l, a)', where s in an int in [0, 360], s and l are percentages between 0 and 100 such as '50%' or '70%', and a is a float in [0, 1].
Arguments:
str : string
String to check.
Returns: !Array.<number>  the integers [h, s, l, a] for valid colors or the empty array for invalid colors.
code »
goog.color.alpha.isValidRgbaColor_(str) !Array.<number>
Checks if a string is a valid rgba color. We expect strings of the format '(r, g, b, a)', or 'rgba(r, g, b, a)', where r, g, b are ints in [0, 255] and a is a float in [0, 1].
Arguments:
str : string
String to check.
Returns: !Array.<number>  the integers [r, g, b, a] for valid colors or the empty array for invalid colors.
code »
goog.color.alpha.normalizeAlphaHex_(hexColor) string
Normalize a hex representation of an alpha color.
Arguments:
hexColor : string
an alpha hex color string.
Returns: string  hex color in the format '#rrggbbaa' with all lowercase literals.
code »
goog.color.alpha.parse(str) {hex: string, type: string
Parses an alpha color out of a string.
Arguments:
str : string
Color in some format.
Returns: {hex: string, type: string  } 'hex' is a string containing a hex representation of the color, and 'type' is a string containing the type of color format passed in ('hex', 'rgb', 'named').
code »
goog.color.alpha.rgbaArrayToHex(rgba) string
Converts a color from RGBA to hex representation.
Arguments:
rgba : Array.<number>
Array of [r, g, b, a], with r, g, b in [0, 255] and a in [0, 1].
Returns: string  hex representation of the color.
code »
goog.color.alpha.rgbaArrayToHsla(rgba) !Array.<number>
Converts a color from RGBA color space to HSLA color space.
Arguments:
rgba : Array.<number>
[r, g, b, a] values for the color, each in [0, 255].
Returns: !Array.<number>  [h, s, l, a] values for the color, with h in [0, 360] and s, l and a in [0, 1].
code »
goog.color.alpha.rgbaArrayToRgbaStyle(rgba) string
Converts a color from RGBA to an RGBA style string.
Arguments:
rgba : (Array.<number> | Float32Array)
Array of [r, g, b, a], with r, g, b in [0, 255] and a in [0, 1].
Returns: string  An 'rgba(r,g,b,a)' string ready for use in a CSS rule.
code »
goog.color.alpha.rgbaStyle_(rgba) string
Takes an array of [r, g, b, a] and converts it into a string appropriate for CSS styles. The alpha channel value is rounded to 3 decimal places to make sure the produced string is not too long.
Arguments:
rgba : Array.<number>
[r, g, b, a] with r, g, b in [0, 255] and a in [0, 1].
Returns: string  string of the form 'rgba(r,g,b,a)'.
code »
goog.color.alpha.rgbaToHex(rgba) string
Converts a color from RGBA to hex representation.
Arguments:
r : number
Amount of red, int between 0 and 255.
g : number
Amount of green, int between 0 and 255.
b : number
Amount of blue, int between 0 and 255.
a : number
Amount of alpha, float between 0 and 1.
Returns: string  hex representation of the color.
code »
goog.color.alpha.rgbaToHsla(rgba) !Array.<number>
Converts a color from RGBA color space to HSLA color space. Modified from http://en.wikipedia.org/wiki/HLS_color_space.
Arguments:
r : number
Value of red, in [0, 255].
g : number
Value of green, in [0, 255].
b : number
Value of blue, in [0, 255].
a : number
Value of alpha, in [0, 255].
Returns: !Array.<number>  [h, s, l, a] values for the color, with h an int in [0, 360] and s, l and a in [0, 1].
code »
goog.color.alpha.rgbaToRgbaStyle(rgba) string
Converts a color from RGBA to an RGBA style string.
Arguments:
r : number
Value of red, in [0, 255].
g : number
Value of green, in [0, 255].
b : number
Value of blue, in [0, 255].
a : number
Value of alpha, in [0, 1].
Returns: string  An 'rgba(r,g,b,a)' string ready for use in a CSS rule.
code »

Directory color

File Reference