-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpage-1.html
84 lines (77 loc) · 2.45 KB
/
page-1.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Canvas Layered Watermark Example</title>
<link rel="stylesheet" href="src/styles.css" />
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden; /* Prevent scrollbars */
}
.content {
position: relative;
z-index: 1; /* Ensure content is above watermark */
padding: 20px;
}
canvas {
position: fixed; /* Fixed position to cover the entire viewport */
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none; /* Allows interaction with elements below canvas */
z-index: 0; /* Ensure canvas is behind content */
}
</style>
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/page-1.html" aria-current="page">加码</a>
<a href="/page-2.html">解码</a>
<a href="/page-3.html">提取内容</a>
</nav>
<canvas id="watermarkCanvas"></canvas>
<div class="content">
<h1>Example Content</h1>
<p>
This is an example of a webpage with layered transparent watermarks
using Canvas.
</p>
<!-- <img src="example.jpg" alt="Example Image" /> -->
</div>
<script>
function drawWatermark(text = 'user 123', opacity = 0.005) {
const canvas = document.getElementById('watermarkCanvas');
const ctx = canvas.getContext('2d');
const width = window.innerWidth;
const height = window.innerHeight;
canvas.width = width;
canvas.height = height;
ctx.clearRect(0, 0, width, height);
ctx.font = '4em Arial';
ctx.fillStyle = `rgba(0, 0, 0, ${opacity})`; // Semi-transparent color
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.globalCompositeOperation = 'source-over'; // Default
// Draw multiple layers of watermark
for (let y = 0; y < height; y += 150) {
for (let x = 0; x < width; x += 150) {
ctx.save();
ctx.translate(x, y);
ctx.rotate((-30 * Math.PI) / 180); // Rotate for better effect
ctx.fillText(text, 0, 0);
ctx.restore();
}
}
}
window.addEventListener('resize', drawWatermark);
drawWatermark(); // Initial draw
</script>
</body>
</html>