Creates a linear gradient value from a string representation.
The format of the string representation is based on JavaFX CSS specification for linear gradient which is
linear-gradient( [ [from <point> to <point>| [ to <side-or-corner>], ]? [ [ repeat | reflect ], ]? <color-stop>[, <color-stop>]+)where
<side-or-corner> = [left | right] || [top | bottom] <point> = [ [ <length> <length> ] | [ <percentage> | <percentage> ] ] <color-stop> = [ <color> [ <percentage> | <length>]? ]
Currently length can be only specified in px, the specification of unit can be omited.
Format of color representation is the one used in Color.web(String color)
.
The linear-gradient keyword can be omited.
For additional information about the format of string representation, see the
CSS Reference Guide.
LinearGradient g
= LinearGradient.valueOf("linear-gradient(from 0% 0% to 100% 100%, red 0% , blue 30%, black 100%)");
LinearGradient g
= LinearGradient.valueOf("from 0% 0% to 100% 100%, red 0% , blue 30%, black 100%");
LinearGradient g
= LinearGradient.valueOf("linear-gradient(from 0px 0px to 200px 0px, #00ff00 0%, 0xff0000 50%, 0x1122ff40 100%)");
LinearGradient g
= LinearGradient.valueOf("from 0px 0px to 200px 0px, #00ff00 0%, 0xff0000 50%, 0x1122ff40 100%");
value | the string to convert |
LinearGradient
object holding the value represented
by the string argument.
NullPointerException | if the value is null | |
IllegalArgumentException | if the value cannot be parsed |
Diagram: Paint