Class GssFunctions.AdjustBrightness
- java.lang.Object
-
- com.google.common.css.compiler.gssfunctions.GssFunctions.AdjustBrightness
-
- All Implemented Interfaces:
GssFunction
- Enclosing class:
- GssFunctions
public static class GssFunctions.AdjustBrightness extends java.lang.Object implements GssFunction
Implementation of the adjustBrightness GSS function. This generates a slightly differentiated color suitable for hover styling. Takes the color to modify as the first argument, and the requested brightness difference as a second argument (between 0 and 100). This function will always ensure that the returned color is different from the input, e.g. attempting to "brighten" white will return a light grey instead of white, but if it isn't possible to find a color that matches the request difference (e.g. asking to brighten by 100 from a medium bright color), the returned value will be a color with a difference from the input color as close as possible to what is being requested. See the unit test for some examples.
-
-
Constructor Summary
Constructors Constructor Description AdjustBrightness()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringadjustBrightness(java.lang.String originalColorStr, java.lang.String brightnessStr)java.util.List<CssValueNode>getCallResultNodes(java.util.List<CssValueNode> args, ErrorManager errorManager)Returns the hover color corresponding to the argument documented inGssFunctions.AdjustBrightness.java.lang.StringgetCallResultString(java.util.List<java.lang.String> args)Processes a list of strings as function arguments and returns a string result.java.lang.IntegergetNumExpectedArguments()Returns the number of expected arguments of this GSS function.
-
-
-
Method Detail
-
getNumExpectedArguments
public java.lang.Integer getNumExpectedArguments()
Returns the number of expected arguments of this GSS function.- Specified by:
getNumExpectedArgumentsin interfaceGssFunction- Returns:
- Number of expected arguments
-
getCallResultNodes
public java.util.List<CssValueNode> getCallResultNodes(java.util.List<CssValueNode> args, ErrorManager errorManager)
Returns the hover color corresponding to the argument documented inGssFunctions.AdjustBrightness.- Specified by:
getCallResultNodesin interfaceGssFunction- Parameters:
args- The list of arguments.- Returns:
- The generated hover color.
-
adjustBrightness
protected java.lang.String adjustBrightness(java.lang.String originalColorStr, java.lang.String brightnessStr)
-
getCallResultString
public java.lang.String getCallResultString(java.util.List<java.lang.String> args)
Description copied from interface:GssFunctionProcesses a list of strings as function arguments and returns a string result. Errors are reported by throwingGssFunctionException.- Specified by:
getCallResultStringin interfaceGssFunction
-
-