Simple color picker with a focus on good ux for the average user, that works on android, ios, and desktop. to be bundled with drawr.
View on github
//Code for Example 1
html
<input type="text" id ="picker" />
js
$("#picker").drawrpalette();
//Code for Example 2: alpha channel
<input type="text" id="picker_alpha" value="#3366ffcc" />
<input type="text" id="picker_rgba" value="#33cc3380" />
$("#picker_alpha").drawrpalette({ enable_alpha: true }); //outputs "#rrggbbaa"
$("#picker_rgba" ).drawrpalette({ enable_alpha: true, format: "rgba" }); //outputs "rgba(...)"
//Code for Example 2
html
<input type="text" id ="picker" value="#770033" />
js
function debug(test){
$("#debuglog").html($("#debuglog").html() + test + "
");
$("#debuglog")[0].scrollTop = $("#debuglog")[0].scrollHeight;
}
$("#picker").drawrpalette().on("preview.drawrpalette",function(event,hexcolor){
debug("preview: " + hexcolor);
}).on("cancel.drawrpalette",function(event,hexcolor){
debug("cancel: " + hexcolor);
}).on("choose.drawrpalette",function(event,hexcolor){
debug("choose: " + hexcolor);
}).on("open.drawrpalette",function(){
debug("open");
}).on("close.drawrpalette",function(){
debug("close");
});
//to destroy and restore original input:
$("#picker").drawrpalette("destroy");
Features