A gradient picker widget for jQuery.
A jQuery plugin to allow you to add gradient choosers to your website.
fillDirection
default: left. Can be any CSS3 supported direction for linear gradients. E.g., top, left, bottom, right, 45deg, etc.
type
default: linear. Options: linear or radial
controlPoints
color and position pairs used to set the initial state of the gradient picker. Written in the following form: controlPoints: ["green 0%", "orange 100%"]
change
the callback to call when the gradient has been updated / changed. Callbacks receive two parameters: points
and styles
. points
contains the information for each gradient control point. styles
contains the generate CSS. The first entry in the styles array is the CSS3 standard style. The second entry is the browser specific style (-moz,-webkit,-o,etc.)
generateStyles
default: true. Option to not generate styles and instead only pass back the points
array.
http://tantaman.github.com/jquery-gradient-picker/example_usage/gradientPicker.html
Ex 1
$("#ex1").gradientPicker({
change: function(points, styles) { // styles include standard style and browser-prefixed style
for (i = 0; i < styles.length; ++i) {
$left.css("background-image", styles[i]);
}
},
fillDirection: "bottom",
controlPoints: ["green 0%", "yellow 50%", "green 100%"]
});
Ex 2
$("#ex2").gradientPicker({
// points is an array of point objects containing the color and position of a graident control point.
change: function(points, styles) {
for (i = 0; i < styles.length; ++i) {
$right.css("background-image", styles[i]);
}
},
controlPoints: ["green 0%", "orange 100%"]
});
Ex 3
$("#ex3").gradientPicker({
type: "radial",
change: function(points, styles) {
for (i = 0; i < styles.length; ++i) {
$bottom.css("background-image", styles[i]);
}
},
controlPoints: ["blue 0%", "yellow 100%"]
});