forked from flozz/StackBlur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
64 lines (56 loc) · 1.85 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!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>