-
Notifications
You must be signed in to change notification settings - Fork 1
/
cameraFilters.html
88 lines (84 loc) · 2.67 KB
/
cameraFilters.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Camera Filters</title>
<link rel="stylesheet" href="css/BlackBerry-JQM-all.min.css" />
<script src="js/BlackBerry-JQM-all.min.js"></script>
<script src="local:///chrome/webworks.js" type="text/javascript"></script>
<style>
.grayscale {
-webkit-filter: grayscale(1);
}
.sepia {
-webkit-filter: sepia(1);
}
.blur {
-webkit-filter: blur(3px);
}
.brightness {
-webkit-filter:brightness(5);
}
.contrast {
-webkit-filter:contrast(8);
}
.hue-rotate {
-webkit-filter:hue-rotate(90deg);
}
.hue-rotate2 {
-webkit-filter:hue-rotate(180deg);
}
.hue-rotate3 {
-webkit-filter:hue-rotate(270deg);
}
.saturate {
-webkit-filter:saturate(10);
}
.invert {
-webkit-filter: invert(1);
}
</style>
</head>
<body>
<div data-role="page">
<div data-role="header" data-position="fixed">
<h1>Camera Filters</h1>
</div>
<div data-role="content">
<video autoplay></video>
<input type="button" id="filter" value="Change Filter" />
<script>
var idx = 0;
var filters = ['grayscale', 'sepia', 'blur', 'brightness', 'contrast', 'hue-rotate',
'hue-rotate2', 'hue-rotate3', 'saturate', 'invert', ''];
$('#filter').click(function changeFilter() {
var video = document.querySelector('video');
video.className = '';
var effect = filters[idx++ % filters.length]; // loop through filters.
if (effect) {
video.classList.add(effect);
}
});
function onFailSoHard(ex) {
console.log(ex);
}
navigator.getUserMedia = navigator.getUserMedia||navigator.webkitGetUserMedia||false;
if(!!navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: true}, function(stream) {
var video = document.querySelector('video');
video.src = ('webkitURL' in window)?window.webkitURL.createObjectURL(stream):stream;
}, onFailSoHard);
} else {
alert("not supported"); // fallback.
}
</script>
</div>
<!--/content-->
<div data-role="footer" data-position="fixed">
<div id="action-bar-area" data-role="actionbar">
<div data-role="back"></div>
</div>
</div>
</div>
</body>
</html>