StackBlur/demo.html
2015-07-07 13:38:23 +02:00

65 lines
1.8 KiB
HTML

<!doctype html>
<html>
<head>
<title>StackBlur Demo</title>
<style>
html, body {
padding: 0;
margin: 0;
text-align: center;
background: #fff;
font-family: Arial, sans-serif;
color: #333;
}
canvas {
border: #fff solid 4px;
box-shadow: 0 0 10px rgba(0, 0, 0, .3);
vertical-align: middle;
}
div {
margin: 20px;
}
</style>
</head>
<body>
<h1>StackBlur Demo</h1>
<canvas id="canvas" width="200" height="200"></canvas>
<div>
<input type="range" min="0" max="50" value="0" id="slider" />
</div>
<script src="dist/stackblur.js"></script>
<script>
// Canvas
var canvas = document.getElementById("canvas");
var cctx = canvas.getContext("2d");
var buff = document.createElement("canvas");
buff.width = canvas.width;
buff.height = canvas.height;
var bctx = buff.getContext("2d");
bctx.fillStyle = "#eee";
bctx.fillRect(0, 0, canvas.width, canvas.height);
bctx.fillStyle = "#08f";
bctx.fillRect(30, 30, 120, 90);
bctx.fillStyle = "#f04";
bctx.beginPath();
bctx.arc(120, 120, 50, 0, 2*Math.PI);
bctx.fill();
cctx.drawImage(buff, 0, 0);
// Slider
var slider = document.getElementById("slider");
slider.addEventListener("change", function() {
cctx.drawImage(buff, 0, 0);
StackBlur.canvasRGB(canvas, 0, 0, canvas.width, canvas.height, slider.value);
}, false);
</script>
</body>
</html>