2013-04-08 23:32:30 +00:00
|
|
|
/*
|
|
|
|
* @provide pskl.drawingtools.ColorPicker
|
|
|
|
*
|
|
|
|
* @require pskl.utils
|
|
|
|
*/
|
|
|
|
(function() {
|
|
|
|
var ns = $.namespace("pskl.drawingtools");
|
|
|
|
|
|
|
|
ns.ColorPicker = function() {
|
|
|
|
this.toolId = "tool-colorpicker";
|
|
|
|
this.helpText = "Color picker";
|
|
|
|
};
|
|
|
|
|
|
|
|
pskl.utils.inherit(ns.ColorPicker, ns.BaseTool);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
2013-04-09 05:24:07 +00:00
|
|
|
ns.ColorPicker.prototype.applyToolAt = function(col, row, color, frame, overlay, context) {
|
2013-04-08 23:32:30 +00:00
|
|
|
if (frame.containsPixel(col, row)) {
|
|
|
|
var sampledColor = frame.getPixel(col, row);
|
2013-04-09 05:24:07 +00:00
|
|
|
if (context.button == Constants.LEFT_BUTTON) {
|
|
|
|
$.publish(Events.PRIMARY_COLOR_SELECTED, [sampledColor]);
|
|
|
|
} else if (context.button == Constants.RIGHT_BUTTON) {
|
|
|
|
$.publish(Events.SECONDARY_COLOR_SELECTED, [sampledColor]);
|
|
|
|
}
|
2013-04-08 23:32:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|