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>
|
|
|
|
<th>Viewport (point)</th>
|
2015-12-12 03:07:23 +03:00
|
|
|
<th>Big Image (pixel)</th>
|
|
|
|
<th>Small Image (pixel)</th>
|
2013-10-05 18:21:12 +04:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Cursor position</th>
|
2015-12-12 03:07:23 +03:00
|
|
|
<td id="cursorWindowPosition"></td>
|
|
|
|
<td id="cursorContainerPosition"></td>
|
|
|
|
<td id="cursorViewportPosition"></td>
|
|
|
|
<td id="cursorImage1Position"></td>
|
|
|
|
<td id="cursorImage2Position"></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Big Image top left position</th>
|
|
|
|
<td id="image1WindowPosition"></td>
|
|
|
|
<td id="image1ContainerPosition"></td>
|
|
|
|
<td id="image1ViewportPosition"></td>
|
|
|
|
<td id="image1Image1Position"></td>
|
|
|
|
<td id="image1Image2Position"></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Small Image top left position</th>
|
|
|
|
<td id="image2WindowPosition"></td>
|
|
|
|
<td id="image2ContainerPosition"></td>
|
|
|
|
<td id="image2ViewportPosition"></td>
|
|
|
|
<td id="image2Image1Position"></td>
|
|
|
|
<td id="image2Image2Position"></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>
|
2015-12-12 03:07:23 +03:00
|
|
|
<td id="viewportZoom"></td>
|
2015-06-02 23:41:37 +03:00
|
|
|
<td id="image1Zoom"></td>
|
|
|
|
<td id="image2Zoom"></td>
|
|
|
|
</tr>
|
2013-10-05 18:21:12 +04:00
|
|
|
</table>
|
|
|
|
</div>
|
2015-12-12 03:07:23 +03:00
|
|
|
<button onclick="rotate();">Rotate</button>
|
2013-10-05 18:21:12 +04:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var viewer = OpenSeadragon({
|
2015-12-12 03:07:23 +03:00
|
|
|
debugMode: true,
|
2013-10-05 18:21:12 +04:00
|
|
|
id: "contentDiv",
|
|
|
|
prefixUrl: "../../build/openseadragon/images/",
|
2015-06-02 23:41:37 +03:00
|
|
|
tileSources: [{
|
2015-12-12 03:07:23 +03:00
|
|
|
tileSource: "../data/testpattern.dzi",
|
|
|
|
clip: new OpenSeadragon.Rect(0, 0, 500, 1000)
|
|
|
|
}, {
|
2015-06-02 23:41:37 +03:00
|
|
|
tileSource: "../data/testpattern.dzi",
|
|
|
|
x: 1,
|
|
|
|
y: 1,
|
|
|
|
width: 0.5
|
|
|
|
}
|
|
|
|
],
|
|
|
|
showNavigator: true
|
2013-10-05 18:21:12 +04:00
|
|
|
});
|
2015-12-12 03:07:23 +03:00
|
|
|
viewer.addHandler("open", onAnimation);
|
2013-10-05 18:21:12 +04:00
|
|
|
|
|
|
|
function pointToString(point) {
|
|
|
|
return point.x.toPrecision(4) + "," + point.y.toPrecision(4);
|
|
|
|
}
|
|
|
|
|
2015-12-12 03:07:23 +03:00
|
|
|
function onMouseTrackerMove(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-12-12 03:07:23 +03:00
|
|
|
$("#cursorWindowPosition").text(pointToString(windowPoint));
|
2013-10-05 18:21:12 +04:00
|
|
|
var containerPoint = windowPoint.minus(
|
|
|
|
OpenSeadragon.getElementPosition(viewer.element));
|
2015-12-12 03:07:23 +03:00
|
|
|
$("#cursorContainerPosition").text(pointToString(containerPoint));
|
2015-06-02 23:41:37 +03:00
|
|
|
var image1 = viewer.world.getItemAt(0);
|
|
|
|
var imagePoint = image1.windowToImageCoordinates(windowPoint);
|
2015-12-12 03:07:23 +03:00
|
|
|
$("#cursorImage1Position").text(pointToString(imagePoint));
|
2015-06-02 23:41:37 +03:00
|
|
|
var image2 = viewer.world.getItemAt(1);
|
|
|
|
var imagePoint = image2.windowToImageCoordinates(windowPoint);
|
2015-12-12 03:07:23 +03:00
|
|
|
$("#cursorImage2Position").text(pointToString(imagePoint));
|
2013-10-05 18:21:12 +04:00
|
|
|
var viewportPoint = viewer.viewport.windowToViewportCoordinates(windowPoint);
|
2015-12-12 03:07:23 +03:00
|
|
|
$("#cursorViewportPosition").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));
|
2015-12-12 03:07:23 +03:00
|
|
|
|
|
|
|
var origin = new OpenSeadragon.Point(0, 0);
|
|
|
|
var image1WindowPoint = image1.imageToWindowCoordinates(origin);
|
|
|
|
$("#image1WindowPosition").text(pointToString(image1WindowPoint));
|
|
|
|
var image1ContainerPoint = image1.imageToViewerElementCoordinates(origin);
|
|
|
|
$("#image1ContainerPosition").text(pointToString(image1ContainerPoint));
|
|
|
|
var image1Image1Position = image1.viewportToImageCoordinates(
|
|
|
|
image1.getBounds(true).getTopLeft());
|
|
|
|
$("#image1Image1Position").text(pointToString(image1Image1Position));
|
|
|
|
var image1Image2Position = image1.viewportToImageCoordinates(
|
|
|
|
image2.getBounds(true).getTopLeft());
|
|
|
|
$("#image1Image2Position").text(pointToString(image1Image2Position));
|
|
|
|
var image1ViewportPoint = image1.imageToViewportCoordinates(origin);
|
|
|
|
$("#image1ViewportPosition").text(pointToString(image1ViewportPoint));
|
|
|
|
|
|
|
|
var image2WindowPoint = image2.imageToWindowCoordinates(origin);
|
|
|
|
$("#image2WindowPosition").text(pointToString(image2WindowPoint));
|
|
|
|
var image2ContainerPoint = image2.imageToViewerElementCoordinates(origin);
|
|
|
|
$("#image2ContainerPosition").text(pointToString(image2ContainerPoint));
|
|
|
|
var image2Image1Position = image2.viewportToImageCoordinates(
|
|
|
|
image1.getBounds(true).getTopLeft());
|
|
|
|
$("#image2Image1Position").text(pointToString(image2Image1Position));
|
|
|
|
var image2Image2Position = image2.viewportToImageCoordinates(
|
|
|
|
image2.getBounds(true).getTopLeft());
|
|
|
|
$("#image2Image2Position").text(pointToString(image2Image2Position));
|
|
|
|
var image2ViewportPoint = image2.imageToViewportCoordinates(origin);
|
|
|
|
$("#image2ViewportPosition").text(pointToString(image2ViewportPoint));
|
2015-06-02 23:41:37 +03:00
|
|
|
}
|
|
|
|
viewer.addHandler("animation", onAnimation);
|
|
|
|
|
2015-12-12 03:07:23 +03:00
|
|
|
function rotate() {
|
|
|
|
viewer.viewport.setRotation(viewer.viewport.getRotation() + 45);
|
|
|
|
onAnimation();
|
|
|
|
}
|
2013-10-05 18:21:12 +04:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|