forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbadge.html
More file actions
55 lines (55 loc) · 1.26 KB
/
badge.html
File metadata and controls
55 lines (55 loc) · 1.26 KB
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
<!DOCTYPE html>
<meta name="viewport" content="width=device-width">
<style>
a {
-webkit-clip-path: path("M 82 14 L 84 14 L 84 16 L 82 16 z");
text-decoration: none;
}
img {
width: 100px;
height: 100px;
}
</style>
<script>
window.addEventListener("load", () => {
const canvas = document.createElement("canvas");
canvas.width = 10;
canvas.height = 10;
const ctx = canvas.getContext("2d");
const images = document.querySelectorAll("img");
images.forEach(image => {
ctx.clearRect(0, 0, 10, 10);
const color = image.getAttribute("data-color");
ctx.fillStyle = color;
ctx.fillRect(0, 0, 10, 10);
image.src = canvas.toDataURL();
});
}, false);
</script>
<a href="/" rel="ar">
<img data-color="red">
</a>
<a href="/" rel="ar">
<img data-color="green">
</a>
<a href="/" rel="ar">
<img data-color="blue">
</a>
<a href="/" rel="ar">
<img data-color="cyan">
</a>
<a href="/" rel="ar">
<img data-color="#777777">
</a>
<a href="/" rel="ar">
<img data-color="rgba(255, 128, 0, 0.5)">
</a>
<a href="/" rel="ar">
<img data-color="white">
</a>
<a href="/" rel="ar">
<img data-color="black">
</a>
<a href="/" rel="ar">
<img data-color="rgba(0, 0, 0, 0.0)">
</a>