forked from brianium/watermarkjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pooling.html
110 lines (100 loc) · 3.02 KB
/
pooling.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>watermark.js - canvas pooling</title>
<script src="/scripts/watermark.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Josefin+Slab|Maven+Pro' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="/css/style.css" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css">
</head>
<body>
<div class="container" id="pooling-example">
<h1 class="text-center"><a href="/">watermark.js</a></h1>
<nav>
<ul>
<li><a href="images.html">images</a></li>
<li class="separator">-</li>
<li><a href="text.html">text</a></li>
<li class="separator">-</li>
<li><a href="uploading.html">uploading</a></li>
<li class="separator">-</li>
<li><a href="pooling.html">pooling</a></li>
<li class="separator">-</li>
<li><a href="docs.html">documentation</a></li>
</ul>
</nav>
<p class="lead">
watermark.js leverages canvas pooling so canvases are reused when possible
</p>
<div class="row">
<div class="col-md-4" id="image-1"></div>
<div class="col-md-4" id="image-2"></div>
<div class="col-md-4" id="image-3"></div>
</div>
<div class="row">
<div class="col-md-4" id="image-4"></div>
<div class="col-md-4" id="image-5"></div>
<div class="col-md-4" id="image-6"></div>
</div>
<div class="row">
<div class="col-md-4" id="image-7"></div>
<div class="col-md-4" id="image-8"></div>
<div class="col-md-4" id="image-9"></div>
</div>
<div class="row">
<div class="col-md-12 example">
<pre>
<code class="javascript">
/**
* Place a watermark
*/
function placeMark(i) {
watermark(['/img/shepherd.jpg', '/img/logo.png'])
.image(watermark.image.lowerRight())
.then(function (img) {
var container = document.getElementById('image-' + (i + 1));
container.appendChild(img);
});
}
/**
* Queue up a bunch of async watermark operations
*/
for(var i = 0; i < 9; i++) {
setTimeout((function(index) {
return function() {
placeMark(index);
};
})(i), 10);
}
</code>
</pre>
</div>
</div>
</div>
<script>
function placeMark(i) {
watermark(['/img/shepherd.jpg', '/img/logo.png'])
.image(watermark.image.lowerRight())
.then(function (img) {
var container = document.getElementById('image-' + (i + 1));
container.appendChild(img);
});
}
/**
* Queue up a bunch of async watermark operations
*/
for(var i = 0; i < 9; i++) {
setTimeout((function(index) {
return function() {
placeMark(index);
};
})(i), 10);
}
</script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>