piskel/js/drawingtools/selectiontools/ShapeSelect.js

35 lines
992 B
JavaScript
Raw Normal View History

2012-09-14 22:12:21 +04:00
/*
* @provide pskl.drawingtools.ShapeSelect
*
* @require pskl.utils
*/
(function() {
var ns = $.namespace("pskl.drawingtools");
ns.ShapeSelect = function() {
this.toolId = "tool-shape-select";
2012-09-15 22:25:45 +04:00
this.helpText = "Shape selection tool";
2012-09-14 22:12:21 +04:00
ns.BaseSelect.call(this);
};
pskl.utils.inherit(ns.ShapeSelect, ns.BaseSelect);
2012-09-14 22:12:21 +04:00
/**
* For the shape select tool, you just need to click one time to create a selection.
* So we jsut need to implement onSelectStart_ (no need for onSelect_ & onSelectEnd_)
2012-09-14 22:12:21 +04:00
* @override
*/
ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, color, frame, overlay) {
// Clean previous selection:
$.publish(Events.SELECTION_DISMISSED);
2012-09-14 22:12:21 +04:00
// From the pixel cliked, get shape using an algorithm similar to the paintbucket one:
var pixels = pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(frame, col, row);
var selection = new pskl.selection.ShapeSelection(pixels);
$.publish(Events.SELECTION_CREATED, [selection]);
2012-09-14 22:12:21 +04:00
};
})();