Enhancement : shape tool + shift : now constrained to minimum

This commit is contained in:
jdescottes
2014-04-12 09:49:29 +02:00
parent 4804477498
commit ee3285089a

View File

@@ -74,14 +74,16 @@
* @return {Object} {row : Number, col : Number} * @return {Object} {row : Number, col : Number}
*/ */
ns.ShapeTool.prototype.getScaledCoordinates_ = function(col, row) { ns.ShapeTool.prototype.getScaledCoordinates_ = function(col, row) {
var sign; var dX = this.startCol - col;
if (Math.abs(this.startCol - col) > Math.abs(this.startRow - row)) { var absX = Math.abs(dX);
sign = row > this.startRow ? 1 : -1;
row = this.startRow + (sign * Math.abs(this.startCol - col)); var dY = this.startRow - row;
} else { var absY = Math.abs(dY);
sign = col > this.startCol ? 1 : -1;
col = this.startCol + (sign * Math.abs(this.startRow - row)); var delta = Math.min(absX, absY);
} row = this.startRow - ((dY/absY)*delta);
col = this.startCol - ((dX/absX)*delta);
return { return {
col : col, col : col,
row : row row : row