Steven Barrett Steven Barrett - 2 months ago 11
jQuery Question

change value of colour picker based on variable onclick

On my program here:
http://www.taffatech.com/Paint.html

I want to add an eyedropper tool. Now this much I feel I can implement by clicking the dropper icon then clicking somewhere on canvas, and then saving the hex value to a variable.
What I need help with is how to change the colour picker value I have with this variable?
This is the code for the colour picker and you can see it on the link provided.

$('#colorpickerHolder').ColorPicker({
flat: true,
onChange: function (hsb, hex, rgb) { brushColour = "#" + hex; },
});


I plan on using this eyedropper: http://palebluepixel.org/2011/11/16/html5-canvas-eyedropper/

Answer

Presumably this is http://www.eyecon.ro/colorpicker/ ?

It looks like you can just do:

$('#colorpickerHolder').ColorPickerSetColor('#0000ff');
Comments