mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-23 05:36:09 +03:00
fixes from review of drawerbase.js
This commit is contained in:
parent
2d8c6fe4c3
commit
3f7e7141b9
@ -1,5 +1,5 @@
|
||||
Copyright (C) 2009 CodePlex Foundation
|
||||
Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Button
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - ButtonGroup
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - CanvasDrawer
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2022 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -347,7 +347,7 @@ class CanvasDrawer extends $.DrawerBase{
|
||||
var point = tiledImage
|
||||
.imageToViewportCoordinates(coord.x, coord.y, true)
|
||||
.rotate(-tiledImage.getRotation(true), tiledImage._getRotationPoint(true));
|
||||
var clipPoint = self._viewportCoordToDrawerCoord(point);
|
||||
var clipPoint = self.viewportCoordToDrawerCoord(point);
|
||||
if (sketchScale) {
|
||||
clipPoint = clipPoint.times(sketchScale);
|
||||
}
|
||||
@ -500,23 +500,6 @@ class CanvasDrawer extends $.DrawerBase{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function converts the given point from to the drawer coordinate by
|
||||
* multiplying it with the pixel density.
|
||||
* This function does not take rotation into account, thus assuming provided
|
||||
* point is at 0 degree.
|
||||
* @private
|
||||
* @param {OpenSeadragon.Point} point - the pixel point to convert
|
||||
* @returns {OpenSeadragon.Point} Point in drawer coordinate system.
|
||||
*/
|
||||
_viewportCoordToDrawerCoord(point) {
|
||||
var vpPoint = this.viewport.pixelFromPointNoRotate(point, true);
|
||||
return new $.Point(
|
||||
vpPoint.x * $.pixelDensityRatio,
|
||||
vpPoint.y * $.pixelDensityRatio
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws special debug information for a TiledImage if in debug mode.
|
||||
* @private
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Control
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - ControlDock
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - DisplayRect
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - DrawerBase
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -34,16 +34,6 @@
|
||||
|
||||
(function( $ ){
|
||||
|
||||
$.DrawerOptions = class DrawerOptions{
|
||||
constructor(options){}
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {Object} Point
|
||||
* @property {number} x
|
||||
* @property {number} y
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class DrawerBase
|
||||
* @memberof OpenSeadragon
|
||||
@ -90,16 +80,14 @@ $.DrawerBase = class DrawerBase{
|
||||
*/
|
||||
this.container = $.getElement( options.element );
|
||||
|
||||
// We force our container to ltr because our drawing math doesn't work in rtl.
|
||||
// This issue only affects our canvas renderer, but we do it always for consistency.
|
||||
// Note that this means overlays you want to be rtl need to be explicitly set to rtl.
|
||||
this.container.dir = 'ltr';
|
||||
this._renderingTarget = this._createDrawingElement();
|
||||
|
||||
|
||||
// the first time this.canvas is accessed, implementations will create it
|
||||
this.canvas.style.width = "100%";
|
||||
this.canvas.style.height = "100%";
|
||||
this.canvas.style.position = "absolute";
|
||||
$.setElementOpacity( this.canvas, this.viewer.opacity, true ); // set
|
||||
this.canvas.style.left = "0";
|
||||
$.setElementOpacity( this.canvas, this.viewer.opacity, true );
|
||||
|
||||
// Allow pointer events to pass through the canvas element so implicit
|
||||
// pointer capture works on touch devices
|
||||
@ -113,10 +101,8 @@ $.DrawerBase = class DrawerBase{
|
||||
this._checkForAPIOverrides();
|
||||
}
|
||||
|
||||
// protect the canvas member with a getter
|
||||
get canvas(){
|
||||
if(!this._renderingTarget){
|
||||
this._renderingTarget = this._createDrawingElement();
|
||||
}
|
||||
return this._renderingTarget;
|
||||
}
|
||||
get element(){
|
||||
@ -125,9 +111,10 @@ $.DrawerBase = class DrawerBase{
|
||||
}
|
||||
|
||||
/**
|
||||
* @property {String|undefined} type What type of drawer this is. Implementations should override this property.
|
||||
* @returns {String|undefined} What type of drawer this is.
|
||||
*/
|
||||
getType(){
|
||||
$.console.error('Drawer.getType must be implemented by child class');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -206,26 +193,25 @@ $.DrawerBase = class DrawerBase{
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* Ensures that child classes have provided implementations for public API methods
|
||||
* draw, canRotate, destroy, and setImageSmoothinEnabled. Throws an exception if the original
|
||||
* placeholder methods are still in place.
|
||||
*/
|
||||
_checkForAPIOverrides(){
|
||||
if(this._createDrawingElement === $.DrawerBase.prototype._createDrawingElement){
|
||||
throw("[drawer]._createDrawingElement must be implemented by child class");
|
||||
throw(new Error("[drawer]._createDrawingElement must be implemented by child class"));
|
||||
}
|
||||
if(this.draw === $.DrawerBase.prototype.draw){
|
||||
throw("[drawer].draw must be implemented by child class");
|
||||
throw(new Error("[drawer].draw must be implemented by child class"));
|
||||
}
|
||||
if(this.canRotate === $.DrawerBase.prototype.canRotate){
|
||||
throw("[drawer].canRotate must be implemented by child class");
|
||||
throw(new Error("[drawer].canRotate must be implemented by child class"));
|
||||
}
|
||||
if(this.destroy === $.DrawerBase.prototype.destroy){
|
||||
throw("[drawer].destroy must be implemented by child class");
|
||||
throw(new Error("[drawer].destroy must be implemented by child class"));
|
||||
}
|
||||
if(this.setImageSmoothingEnabled === $.DrawerBase.prototype.setImageSmoothingEnabled){
|
||||
throw("[drawer].setImageSmoothingEnabled must be implemented by child class");
|
||||
throw(new Error("[drawer].setImageSmoothingEnabled must be implemented by child class"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,19 +257,14 @@ $.DrawerBase = class DrawerBase{
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* Calculate width and height of the canvas based on viewport dimensions
|
||||
* and pixelDensityRatio
|
||||
* @returns {Point} {x, y} size of the canvas
|
||||
* @returns {OpenSeadragon.Point} {x, y} size of the canvas
|
||||
*/
|
||||
_calculateCanvasSize() {
|
||||
var pixelDensityRatio = $.pixelDensityRatio;
|
||||
var viewportSize = this.viewport.getContainerSize();
|
||||
return {
|
||||
// canvas width and height are integers
|
||||
x: Math.round(viewportSize.x * pixelDensityRatio),
|
||||
y: Math.round(viewportSize.y * pixelDensityRatio)
|
||||
};
|
||||
return new OpenSeadragon.Point( Math.round(viewportSize.x * pixelDensityRatio), Math.round(viewportSize.y * pixelDensityRatio));
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - DziTileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - EventSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - full-screen support functions
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - HTMLDrawer
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -130,7 +130,6 @@ class HTMLDrawer extends $.DrawerBase{
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* Clears the Drawer so it's ready to draw another frame.
|
||||
*
|
||||
*/
|
||||
@ -140,7 +139,6 @@ class HTMLDrawer extends $.DrawerBase{
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* Draws a TiledImage.
|
||||
*
|
||||
*/
|
||||
@ -179,7 +177,6 @@ class HTMLDrawer extends $.DrawerBase{
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* Draws the given tile.
|
||||
* @param {OpenSeadragon.Tile} tile - The tile to draw.
|
||||
* @param {Function} drawingHandler - Method for firing the drawing event if using canvas.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - IIIFTileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - ImageLoader
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - ImageTileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - LegacyTileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Mat3
|
||||
*
|
||||
* Modified from https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
||||
* Copyright (C) 2010-2023 webglfundamentals.org and OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 webglfundamentals.org and OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - MouseTracker
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Navigator
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - OsmTileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Overlay
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* OpenSeadragon - Placement
|
||||
*
|
||||
* Copyright (C) 2010-2016 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Point
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Profiler
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Rect
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - ReferenceStrip
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Spring
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - getString/setString
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Tile
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - TileCache
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - TiledImage
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - TileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - TileSourceCollection
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - TmsTileSource
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Viewer
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - Viewport
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -3,7 +3,7 @@
|
||||
* OpenSeadragon - WebGLDrawer
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -875,7 +875,6 @@
|
||||
this._clippingContext.clip();
|
||||
}
|
||||
_renderToClippingCanvas(item){
|
||||
let _this = this;
|
||||
|
||||
this._clippingContext.clearRect(0, 0, this._clippingCanvas.width, this._clippingCanvas.height);
|
||||
this._clippingContext.save();
|
||||
@ -886,18 +885,18 @@
|
||||
this._setClip(rect);
|
||||
}
|
||||
if(item._croppingPolygons){
|
||||
let polygons = item._croppingPolygons.map(function (polygon) {
|
||||
return polygon.map(function (coord) {
|
||||
let polygons = item._croppingPolygons.map(polygon => {
|
||||
return polygon.map(coord => {
|
||||
let point = item.imageToViewportCoordinates(coord.x, coord.y, true)
|
||||
.rotate(_this.viewer.viewport.getRotation(true), _this.viewer.viewport.getCenter(true));
|
||||
let clipPoint = _this._viewportCoordToDrawerCoord(point);
|
||||
.rotate(this.viewer.viewport.getRotation(true), this.viewer.viewport.getCenter(true));
|
||||
let clipPoint = this.viewportCoordToDrawerCoord(point);
|
||||
return clipPoint;
|
||||
});
|
||||
});
|
||||
this._clippingContext.beginPath();
|
||||
polygons.forEach(function (polygon) {
|
||||
polygon.forEach(function (coord, i) {
|
||||
_this._clippingContext[i === 0 ? 'moveTo' : 'lineTo'](coord.x, coord.y);
|
||||
polygons.forEach(polygon => {
|
||||
polygon.forEach( (coord, i) => {
|
||||
this._clippingContext[i === 0 ? 'moveTo' : 'lineTo'](coord.x, coord.y);
|
||||
});
|
||||
});
|
||||
this._clippingContext.clip();
|
||||
@ -927,25 +926,6 @@
|
||||
context.translate(-point.x, -point.y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* This function converts the given point from to the drawer coordinate by
|
||||
* multiplying it with the pixel density.
|
||||
* This function does not take rotation into account, thus assuming provided
|
||||
* point is at 0 degree.
|
||||
* @param {OpenSeadragon.Point} point - the pixel point to convert
|
||||
* @returns {OpenSeadragon.Point} Point in drawer coordinate system.
|
||||
*/
|
||||
_viewportCoordToDrawerCoord(point) {
|
||||
var vpPoint = this.viewport.pixelFromPointNoRotate(point, true);
|
||||
return new $.Point(
|
||||
vpPoint.x * $.pixelDensityRatio,
|
||||
vpPoint.y * $.pixelDensityRatio
|
||||
);
|
||||
}
|
||||
|
||||
// private
|
||||
_drawDebugInfo( tilesToDraw, tiledImage, stroke, fill ) {
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* OpenSeadragon - World
|
||||
*
|
||||
* Copyright (C) 2009 CodePlex Foundation
|
||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
||||
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
Loading…
Reference in New Issue
Block a user