Skip to content

Commit

Permalink
new option 'returnPixelCoordinates' - fix #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Petar Petrov committed Dec 2, 2015
1 parent c3c36cd commit 8a1f0ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Include `dist/openseadragonselection.js` after OpenSeadragon in your html. Then
toggleButton: null, // dom element to use as toggle button
showConfirmDenyButtons: true,
styleConfirmDenyButtons: true,
returnPixelCoordinates: true,
keyboardShortcut: 'c', // key to toggle selection mode
rect: null, // initial selection as an OpenSeadragon.SelectionRect object
startRotated: false, // alternative method for drawing the selection; useful for rotated crops
Expand Down
12 changes: 8 additions & 4 deletions src/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
showSelectionControl: true,
showConfirmDenyButtons: true,
styleConfirmDenyButtons: true,
returnPixelCoordinates: true,
keyboardShortcut: 'c',
rect: null,
startRotated: false, // useful for rotated crops
Expand Down Expand Up @@ -293,10 +294,13 @@
confirm: function() {
if (this.rect) {
var result = this.rect.normalize();
var real = this.viewer.viewport.viewportToImageRectangle(result);
real = $.SelectionRect.fromRect(real).round();
real.rotation = result.rotation;
this.viewer.raiseEvent('selection', real);
if (this.returnPixelCoordinates) {
var real = this.viewer.viewport.viewportToImageRectangle(result);
real = $.SelectionRect.fromRect(real).round();
real.rotation = result.rotation;
result = real;
}
this.viewer.raiseEvent('selection', result);
this.undraw();
}
return this;
Expand Down

0 comments on commit 8a1f0ef

Please sign in to comment.