-
Notifications
You must be signed in to change notification settings - Fork 0
/
labs.html
132 lines (125 loc) · 4.79 KB
/
labs.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="stylesheet" href="css/bootstrap.min.css?1" />
<link rel="stylesheet" href="css/common.css?1" />
<script type="text/javascript" src="js/jquery.min.js?1"></script>
<script type="text/javascript" src="js/bootstrap.min.js?1"></script>
<script type="text/javascript" src="js/common.js?2"></script>
<script type="text/javascript" src="js/classes.js?1"></script>
<style type="text/css">
body {
background-color: #ddd;
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript">
var imgBack = new Image();
var cvPrincipal = null;
var ctxPrincipal = null;
var cvBackward = null;
var ctxBackward = null;
$(document).ready(() => {
cvPrincipal = $("#canvasPrincipal")[0];
ctxPrincipal = cvPrincipal.getContext("2d");
cvBackward = $("#canvasBackward")[0];
ctxBackward = cvBackward.getContext("2d");
imgBack.src = "img/large_octagon_room_4.jpg";
imgBack.onload = function () {
requestAnimationFrame(RenderLights);
//Render();
};
});
function RenderLights() {
//requestAnimationFrame(RenderLights);
//ligthen(ctxPrincipal, 100, 100, 100, "red");
//ligthenGradient(ctxPrincipal, 100, 100, 100);
}
function ligthen(ctx, x, y, radius, color) {
ctx.save();
var rnd = 0.03 * Math.sin(1.1 * Date.now() / 1000000);
radius = radius * (1 + rnd);
ctx.globalCompositeOperation = 'lighter';
ctx.fillStyle = '#0B0B00';
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y, radius * 0.90 + rnd, 0, 2 * Math.PI);
ctx.fill();
ctx.beginPath();
ctx.arc(x, y, radius * 0.4 + rnd, 0, 2 * Math.PI);
ctx.fill();
ctx.restore();
}
function ligthenGradient(ctx, x, y, radius) {
ctx.save();
ctx.globalCompositeOperation = 'lighter';
var rnd = 0.05 * Math.sin(1.1 * Date.now() / 1000);
radius = radius * (1 + rnd);
var radialGradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
radialGradient.addColorStop(0.0, '#BB9');
radialGradient.addColorStop(0.2 + rnd, '#AA8');
radialGradient.addColorStop(0.7 + rnd, '#330');
radialGradient.addColorStop(0.90, '#110');
radialGradient.addColorStop(1, '#000');
ctx.fillStyle = radialGradient;
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI);
ctx.fill();
ctx.restore();
}
function Render() {
with (ctxBackward) {
fillStyle = `rgba(0, 0, 0, 0.5)`;
fillRect(0, 0, 300, 300);
//beginPath();
//moveTo(90, 89);
//lineTo(161, 89);
//quadraticCurveTo(200, 89, 200, 127);
//quadraticCurveTo(200, 166, 148, 166);
//lineTo(115, 166);
//lineTo(108, 210);
//lineTo(69, 210);
//lineTo(90, 89);
//fillStyle = "#eee";
//fill();
//closePath();
globalCompositeOperation = "destination-out";
beginPath();
arc(150, 150, 60, 0, Math.PI * 2, true);
fillStyle = "red";
fill();
closePath();
//beginPath();
//moveTo(124, 117);
//lineTo(146, 117);
//quadraticCurveTo(160, 117, 160, 127);
//quadraticCurveTo(160, 145, 146, 145);
//lineTo(120, 145);
//lineTo(124, 117);
//fillStyle = "red";
//fill();
//closePath();
}
with (ctxPrincipal) {
fillStyle = "#aaa";
fillRect(0, 0, 300, 300);
drawImage(imgBack, 0, 0);
drawImage(cvBackward, 100, 100);
}
}
</script>
</head>
<body>
<canvas id="canvasPrincipal" width="300" height="300" style="border: 1px solid"></canvas>
<canvas id="canvasBackward" width="300" height="300" style="border: 1px solid"></canvas>
</body>
</html>