-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcut.html
67 lines (57 loc) · 1.75 KB
/
cut.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
<!-- vim: sw=2 ts=2 expandtab smartindent ft=javascript
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Canvas Demo</title>
<style> document, body { margin: 0px; padding: 0px; overflow: hidden; } </style>
</head>
<body>
<canvas id="glcanvas"></canvas>
<script>"use strict";
const canvas = document.getElementById("glcanvas");
const ctx = canvas.getContext('2d');
(window.onresize = () => {
canvas.width = window.innerWidth*window.devicePixelRatio;
canvas.height = window.innerHeight*window.devicePixelRatio;
canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';
})();
requestAnimationFrame(function render(now) {
requestAnimationFrame(render);
/* fill background */
ctx.fillStyle = '#555656';
ctx.fillRect(0, 0, canvas.width, canvas.height);
/* parameters for the cut */
const width = 500.0;
const height = 7.5;
const cut_taper = 100.0;
{
ctx.save();
ctx.translate(20, 20);
const gradient = ctx.createLinearGradient(0, 0, 0, height*2);
gradient.addColorStop(0.000, "#3d3d3d");
gradient.addColorStop(0.500, "#787878");
gradient.addColorStop(1.000, "#717171");
{
ctx.beginPath();
const l = 0 + (cut_taper / width);
const r = 1 - (cut_taper / width);
ctx.moveTo( l*width, 0.0*height);
ctx.lineTo(0.00*width, 0.5*height);
ctx.lineTo(1.00*width, 0.5*height);
ctx.lineTo( r*width, 0.0*height);
ctx.moveTo( l*width, 1.0*height);
ctx.lineTo(0.00*width, 0.5*height);
ctx.lineTo(1.00*width, 0.5*height);
ctx.lineTo( r*width, 1.0*height);
ctx.fillStyle = gradient;
ctx.fill();
}
ctx.restore();
}
})
</script>
</body>
</html>