mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
1540 Remove support for array for cropping
This commit is contained in:
parent
956c830f3e
commit
9d0c7bd9c9
@ -694,16 +694,11 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
var isArray = function(obj) {
|
var isArray = function(obj) {
|
||||||
return Object.prototype.toString.call(obj) === '[object Array]';
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
||||||
};
|
};
|
||||||
var isXYPair = function(obj) {
|
var objectToSimpleXYObject = function(objs) {
|
||||||
return obj && isArray(obj) && obj.length === 2;
|
|
||||||
};
|
|
||||||
var convertXYObjectsToArrayIfNeeded = function(objs) {
|
|
||||||
return objs.map(function(obj) {
|
return objs.map(function(obj) {
|
||||||
try {
|
try {
|
||||||
if (isXYObject(obj)) {
|
if (isXYObject(obj)) {
|
||||||
return [obj.x, obj.y];
|
return { x: obj.x, y: obj.y };
|
||||||
} else if (isXYPair(obj)) {
|
|
||||||
return obj;
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}
|
}
|
||||||
@ -718,7 +713,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
throw new Error('Provided cropping polygon is not an array');
|
throw new Error('Provided cropping polygon is not an array');
|
||||||
}
|
}
|
||||||
this._croppingPolygons = polygons.map(function(polygon){
|
this._croppingPolygons = polygons.map(function(polygon){
|
||||||
return convertXYObjectsToArrayIfNeeded(polygon);
|
return objectToSimpleXYObject(polygon);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$.console.error('[TiledImage.setCroppingPolygons] Cropping polygon format not supported');
|
$.console.error('[TiledImage.setCroppingPolygons] Cropping polygon format not supported');
|
||||||
@ -1997,9 +1992,9 @@ function drawTiles( tiledImage, lastDrawn ) {
|
|||||||
tiledImage._drawer.saveContext(useSketch);
|
tiledImage._drawer.saveContext(useSketch);
|
||||||
try {
|
try {
|
||||||
var polygons = tiledImage._croppingPolygons.map(function (polygon) {
|
var polygons = tiledImage._croppingPolygons.map(function (polygon) {
|
||||||
return polygon.map(function (pointPair) {
|
return polygon.map(function (coord) {
|
||||||
var point = tiledImage
|
var point = tiledImage
|
||||||
.imageToViewportCoordinates(pointPair[0], pointPair[1], true)
|
.imageToViewportCoordinates(coord.x, coord.y, true)
|
||||||
.rotate(-tiledImage.getRotation(true), tiledImage._getRotationPoint(true));
|
.rotate(-tiledImage.getRotation(true), tiledImage._getRotationPoint(true));
|
||||||
var clipPoint = tiledImage._drawer.viewportCoordToDrawerCoord(point);
|
var clipPoint = tiledImage._drawer.viewportCoordToDrawerCoord(point);
|
||||||
if (sketchScale) {
|
if (sketchScale) {
|
||||||
|
Loading…
Reference in New Issue
Block a user