mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-23 13:46:09 +03:00
109 lines
3.8 KiB
HTML
109 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>OpenSeadragon Coordinates Demo</title>
|
|
<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">
|
|
|
|
.openseadragon1 {
|
|
width: 800px;
|
|
height: 600px;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
Simple demo page to show OpenSeadragon coordinates system.
|
|
</div>
|
|
<div id="contentDiv" class="openseadragon1"></div>
|
|
<div>
|
|
<table border="1">
|
|
<tr>
|
|
<th></th>
|
|
<th>Window (pixel)</th>
|
|
<th>Container (pixel)</th>
|
|
<th>Image 1 - top left (pixel)</th>
|
|
<th>Image 2 - bottom right (pixel)</th>
|
|
<th>Viewport (point)</th>
|
|
</tr>
|
|
<tr>
|
|
<th>Cursor position</th>
|
|
<td id="windowPosition"></td>
|
|
<td id="containerPosition"></td>
|
|
<td id="image1Position"></td>
|
|
<td id="image2Position"></td>
|
|
<td id="viewportPosition"></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Zoom</th>
|
|
<td>-</td>
|
|
<td>-</td>
|
|
<td id="image1Zoom"></td>
|
|
<td id="image2Zoom"></td>
|
|
<td id="viewportZoom"></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<script type="text/javascript">
|
|
|
|
var viewer = OpenSeadragon({
|
|
// debugMode: true,
|
|
id: "contentDiv",
|
|
prefixUrl: "../../build/openseadragon/images/",
|
|
tileSources: [{
|
|
tileSource: "../data/testpattern.dzi"
|
|
},
|
|
{
|
|
tileSource: "../data/testpattern.dzi",
|
|
x: 1,
|
|
y: 1,
|
|
width: 0.5
|
|
}
|
|
],
|
|
showNavigator: true
|
|
});
|
|
|
|
function pointToString(point) {
|
|
return point.x.toPrecision(4) + "," + point.y.toPrecision(4);
|
|
}
|
|
|
|
var onMouseTrackerMove = function (event) {
|
|
var viewerX = event.position.x;
|
|
var viewerY = event.position.y;
|
|
var windowPoint = new OpenSeadragon.Point(viewerX, viewerY);
|
|
$("#windowPosition").text(pointToString(windowPoint));
|
|
var containerPoint = windowPoint.minus(
|
|
OpenSeadragon.getElementPosition(viewer.element));
|
|
$("#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));
|
|
var viewportPoint = viewer.viewport.windowToViewportCoordinates(windowPoint);
|
|
$("#viewportPosition").text(pointToString(viewportPoint));
|
|
};
|
|
mouseTracker = new OpenSeadragon.MouseTracker({
|
|
element: document,
|
|
moveHandler: onMouseTrackerMove
|
|
}).setTracking(true);
|
|
|
|
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);
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|