blob: f5ffeee3c6fd558c509882cca1b15956bc95339a [file] [log] [blame]
<html>
<head>
<title>crosshair-sk demo</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="/res/common/js/common.js"></script>
<script src="/res/imp/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel=import href="canvas-layers.html">
<link rel=import href="crosshair.html">
<style type="text/css" media="screen">
canvas-layers-sk {
border: solid black 0.5px;
}
img {
border: solid red 0.5px;
}
canvas {
border: solid blue 0.5px;
}
</style>
</head>
<body>
<h1>Crosshair Demo</h1>
<button id=switch>Switch Image</button>
<h2>Click</h1>
<p>
<b>Event:</b> <code id=info></code>
</p>
<canvas-layers-sk layers='["clips", "crosshair"]'id=x>
<img id=img src="https://fiddle.skia.org/i/95552fd2a4b8acacc05a63825cca854e_raster.png"/>
</canvas-layers-sk>
<crosshair-sk id=xhair1 target=x name=crosshair update_on="click"></crosshair-sk>
<h2>Move</h1>
<p>
<b>Event:</b> <code id=info2></code>
</p>
<canvas-layers-sk layers='["clips", "crosshair"]' id=x2>
<img id=img2 src="https://fiddle.skia.org/i/95552fd2a4b8acacc05a63825cca854e_raster.png"/>
</canvas-layers-sk>
<crosshair-sk id=xhair2 target=x2 name=crosshair update_on=move></crosshair-sk>
<script type="text/javascript" charset="utf-8">
var index = 0;
var images = [
"https://fiddle.skia.org/i/95552fd2a4b8acacc05a63825cca854e_raster.png",
"https://fiddle.skia.org/i/5e3a921f4c7ddca081f922cbcc26dd67_raster.png",
];
$$$('#switch').addEventListener('click', function () {
index = (index+1) % 2;
$$$('#img').src = images[index];
$$$('#img2').src = images[index];
});
$$$('#x').addEventListener('canvas-update', function(e) {
$$$('#info').textContent = JSON.stringify(e.detail);
});
$$$('#xhair1').addEventListener('crosshair', function(e) {
$$$('#info').textContent = JSON.stringify(e.detail);
});
$$$('#xhair2').addEventListener('crosshair', function(e) {
$$$('#info2').textContent = JSON.stringify(e.detail);
});
</script>
</body>
</html>
<html>