2013-10-05 18:21:12 +04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2015-06-02 23:41:37 +03:00
|
|
|
<title>OpenSeadragon Coordinates Demo</title>
|
2013-10-05 18:21:12 +04:00
|
|
|
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
|
|
|
<script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
|
|
|
|
<style type="text/css">
|
|
|
|
|
2015-06-02 23:41:37 +03:00
|
|
|
.openseadragon1 {
|
|
|
|
width: 800px;
|
|
|
|
height: 600px;
|
|
|
|
}
|
2013-10-05 18:21:12 +04:00
|
|
|
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div>
|
2015-06-02 23:41:37 +03:00
|
|
|
Simple demo page to show OpenSeadragon coordinates system.
|
2013-10-05 18:21:12 +04:00
|
|
|
</div>
|
|
|
|
<div id="contentDiv" class="openseadragon1"></div>
|
|
|
|
<div>
|
|
|
|
<table border="1">
|
|
|
|
<tr>
|
|
|
|
<th></th>
|
|
|
|
<th>Window (pixel)</th>
|
|
|
|
<th>Container (pixel)</th>
|
2015-06-02 23:41:37 +03:00
|
|
|
<th>Image 1 - top left (pixel)</th>
|
|
|
|
<th>Image 2 - bottom right (pixel)</th>
|
2013-10-05 18:21:12 +04:00
|
|
|
<th>Viewport (point)</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Cursor position</th>
|
|
|
|
<td id="windowPosition"></td>
|
|
|
|
<td id="containerPosition"></td>
|
2015-06-02 23:41:37 +03:00
|
|
|
<td id="image1Position"></td>
|
|
|
|
<td id="image2Position"></td>
|
2013-10-05 18:21:12 +04:00
|
|
|
<td id="viewportPosition"></td>
|
2015-06-02 23:41:37 +03:00
|
|
|
</tr>
|
2013-10-05 18:21:12 +04:00
|
|
|
<tr>
|
2015-06-02 23:41:37 +03:00
|
|
|
<th>Zoom</th>
|
|
|
|
<td>-</td>
|
|
|
|
<td>-</td>
|
|
|
|
<td id="image1Zoom"></td>
|
|
|
|
<td id="image2Zoom"></td>
|
|
|
|
<td id="viewportZoom"></td>
|
|
|
|
</tr>
|
2013-10-05 18:21:12 +04:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var viewer = OpenSeadragon({
|
|
|
|
// debugMode: true,
|
|
|
|
id: "contentDiv",
|
|
|
|
prefixUrl: "../../build/openseadragon/images/",
|
2015-06-02 23:41:37 +03:00
|
|
|
tileSources: [{
|
|
|
|
tileSource: "../data/testpattern.dzi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
tileSource: "../data/testpattern.dzi",
|
|
|
|
x: 1,
|
|
|
|
y: 1,
|
|
|
|
width: 0.5
|
|
|
|
}
|
|
|
|
],
|
|
|
|
showNavigator: true
|
2013-10-05 18:21:12 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
function pointToString(point) {
|
|
|
|
return point.x.toPrecision(4) + "," + point.y.toPrecision(4);
|
|
|
|
}
|
|
|
|
|
2015-06-02 23:41:37 +03:00
|
|
|
var onMouseTrackerMove = function (event) {
|
2015-05-09 19:49:32 +03:00
|
|
|
var viewerX = event.position.x;
|
|
|
|
var viewerY = event.position.y;
|
2013-10-05 18:21:12 +04:00
|
|
|
var windowPoint = new OpenSeadragon.Point(viewerX, viewerY);
|
2015-06-02 23:41:37 +03:00
|
|
|
$("#windowPosition").text(pointToString(windowPoint));
|
2013-10-05 18:21:12 +04:00
|
|
|
var containerPoint = windowPoint.minus(
|
|
|
|
OpenSeadragon.getElementPosition(viewer.element));
|
2015-06-02 23:41:37 +03:00
|
|
|
$("#containerPosition").text(pointToString(containerPoint));
|
|
|
|
var image1 = viewer.world.getItemAt(0);
|
|
|
|
var imagePoint = image1.windowToImageCoordinates(windowPoint);
|
|
|
|
$("#image1Position").text(pointToString(imagePoint));
|
|
|
|
var image2 = viewer.world.getItemAt(1);
|
|
|
|
var imagePoint = image2.windowToImageCoordinates(windowPoint);
|
|
|
|
$("#image2Position").text(pointToString(imagePoint));
|
2013-10-05 18:21:12 +04:00
|
|
|
var viewportPoint = viewer.viewport.windowToViewportCoordinates(windowPoint);
|
2015-06-02 23:41:37 +03:00
|
|
|
$("#viewportPosition").text(pointToString(viewportPoint));
|
2013-10-05 18:21:12 +04:00
|
|
|
};
|
|
|
|
mouseTracker = new OpenSeadragon.MouseTracker({
|
|
|
|
element: document,
|
|
|
|
moveHandler: onMouseTrackerMove
|
|
|
|
}).setTracking(true);
|
|
|
|
|
2015-06-02 23:41:37 +03:00
|
|
|
function onAnimation() {
|
|
|
|
var viewportZoom = viewer.viewport.getZoom(true);
|
|
|
|
$("#viewportZoom").text(viewportZoom.toFixed(3));
|
|
|
|
var image1 = viewer.world.getItemAt(0);
|
|
|
|
var image1Zoom = image1.viewportToImageZoom(viewportZoom);
|
|
|
|
$("#image1Zoom").text(image1Zoom.toFixed(3));
|
|
|
|
var image2 = viewer.world.getItemAt(1);
|
|
|
|
var image2Zoom = image2.viewportToImageZoom(viewportZoom);
|
|
|
|
$("#image2Zoom").text(image2Zoom.toFixed(3));
|
|
|
|
}
|
|
|
|
viewer.addHandler("animation", onAnimation);
|
|
|
|
|
2013-10-05 18:21:12 +04:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|