-
Notifications
You must be signed in to change notification settings - Fork 0
/
camerawithpaperboob.html
309 lines (251 loc) · 8.49 KB
/
camerawithpaperboob.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<html>
<head>
<title>BoobBlobs</title>
<meta content="telephone=no" name="format-detection">
<meta property="og:image" content="http://nahbee10.github.io/blobs/boobblobscreenshot.png" />
<meta property="og:title" content="Obscene cursor's daily life" />
<link rel="shortcut icon" type="image/png" href="boobicon.png"/>
<link rel="stylesheet" href="../style.css">
<script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
<script language="javascript" type="text/javascript" src="libraries/p5.dom.js"></script>
<script type="text/javascript" src="../paper-full.js"></script>
<script src="../shared/utils.js"></script>
<script language="javascript" type="text/javascript" src="sketch_mh.js"></script>
<script type="text/paperscript" canvas="canvas">
var point = new Point(view.size.width/2-130, view.size.height/2);
var point2 = new Point(view.size.width/2+130, view.size.height/2);
var point_tit = new Point(view.size.width/2-135, view.size.height/2+10);
var point_tit2 = new Point(view.size.width/2+135, view.size.height/2+10);
var radius = 120;
var radius_tit = 40;
var radius_tit_tit = 10;
var boundOffset = [];
var boundOffsetBuff = [];
var sidePoints = [];
var boundOffset2 = [];
var boundOffsetBuff2 = [];
var sidePoints2 = [];
var boundOffset_tit = [];
var boundOffsetBuff_tit = [];
var sidePoints_tit = [];
var boundOffset_tit2 = [];
var boundOffsetBuff_tit2 = [];
var sidePoints_tit2 = [];
var boundOffset_tit_tit = [];
var boundOffsetBuff_tit_tit = [];
var sidePoints_tit_tit = [];
var boundOffset_tit_tit2 = [];
var boundOffsetBuff_tit_tit2 = [];
var sidePoints_tit_tit2 = [];
var numSegment = Math.floor(radius / 3 + 2);
var numSegment_tit = Math.floor(radius_tit / 1 + 0);
var path = new Path({
fillColor: new Color(205/255,142/255,109/255),
});
var path2 = new Path({
fillColor: new Color(205/255,142/255,109/255),
});
var path_tit = new Path({
fillColor: new Color(144/255,109/255,107/255),
});
var path_tit2 = new Path({
fillColor: new Color(144/255,109/255,107/255),
});
var path_tit_tit = new Path({
fillColor: new Color(124/255,92/255,90/255),
});
var path_tit_tit2 = new Path({
fillColor: new Color(124/255,92/255,90/255),
});
var mouseMPoint = new Point();
for (var i = 0; i < numSegment; i ++) {
boundOffset.push(radius);
boundOffsetBuff.push(radius);
boundOffset2.push(radius);
boundOffsetBuff2.push(radius);
boundOffset2.push(radius);
boundOffsetBuff2.push(radius);
path.add(new Point());
path2.add(new Point());
sidePoints.push(new Point({
angle: 360 / numSegment * i,
length: 1
}));
sidePoints2.push(new Point({
angle: 360 / numSegment * i,
length: 1
}));
}
for (var j = 0; j < numSegment_tit; j ++) {
boundOffset_tit.push(radius_tit);
boundOffsetBuff_tit.push(radius_tit);
boundOffset_tit2.push(radius_tit);
boundOffsetBuff_tit2.push(radius_tit);
boundOffset_tit_tit.push(radius_tit_tit);
boundOffsetBuff_tit_tit.push(radius_tit_tit);
boundOffset_tit_tit2.push(radius_tit_tit);
boundOffsetBuff_tit_tit2.push(radius_tit_tit);
path_tit.add(new Point());
path_tit2.add(new Point());
path_tit_tit.add(new Point());
path_tit_tit2.add(new Point());
sidePoints_tit.push(new Point({
angle: 360 / numSegment_tit * j,
length: 1
}));
sidePoints_tit2.push(new Point({
angle: 360 / numSegment_tit * j,
length: 1
}));
sidePoints_tit_tit.push(new Point({
angle: 360 / numSegment_tit * j,
length: 1
}));
sidePoints_tit_tit2.push(new Point({
angle: 360 / numSegment_tit * j,
length: 1
}));
}
function onMouseMove(event) {
mouseMPoint = event.point;
}
var minusPt = new Point(0,10);
function iterate() {
//point_tit = getSidePoint(point, 40, sidePoints, boundOffset) - minusPt;
//point_tit2 = getSidePoint(point2, 40, sidePoints2, boundOffset2) - minusPt;
updateShape(point, path, boundOffset, boundOffsetBuff, sidePoints, numSegment, radius);
updateShape(point2, path2, boundOffset2, boundOffsetBuff2, sidePoints2, numSegment, radius);
updateShape(point_tit, path_tit, boundOffset_tit, boundOffsetBuff_tit, sidePoints_tit, numSegment_tit, radius_tit);
updateShape(point_tit2, path_tit2, boundOffset_tit2, boundOffsetBuff_tit2, sidePoints_tit2, numSegment_tit, radius_tit);
updateShape(point_tit, path_tit_tit, boundOffset_tit_tit, boundOffsetBuff_tit_tit, sidePoints_tit_tit, numSegment_tit, radius_tit_tit);
updateShape(point_tit2, path_tit_tit2, boundOffset_tit_tit2, boundOffsetBuff_tit_tit2, sidePoints_tit_tit2, numSegment_tit, radius_tit_tit);
//updateShape(path2);
//console.log(mouseMPoint);
}
function updateShape(pt, pth, bOSet, bOSetBuff, sP, nS, rad){
var segments = pth.segments;
for (var i = 0; i < nS; i ++)
segments[i].point = getSidePoint(pt, i, sP, bOSet);
pth.smooth();
//console.log(path);
for (var i = 0; i < nS; i ++) {
if (bOSet[i] < rad / 4)
bOSet[i] = rad / 4;
var next = (i + 1) % nS;
var prev = (i > 0) ? i - 1 : nS - 1;
var offset = bOSet[i];
offset += (rad - offset) / 2;
//offset += ((bOSet[next] + bOSet[prev]) / 2 - offset) / 150;
bOSetBuff[i] = bOSet[i] = offset;
}
}
function react(pt, bOSet, bOSetBuff, sP, nS, rad) {
var dist = pt.getDistance(mouseMPoint);
if (dist < rad && dist != 0) {
var overlap = rad - dist;
//var direc = (point - this.mouseE).normalize(overlap * 0.015);
//this.vector += direc;
//b.vector -= direc;
calcBounds(pt, mouseMPoint, bOSet, bOSetBuff, sP, nS);
//b.calcBounds(this);
updateBounds(bOSet, bOSetBuff, nS);
//b.updateBounds();
}
}
function getBoundOffset(b, bOSet) {
var diff = b - mouseMPoint;
//console.log(diff);
var angle = (diff.angle + 180) % 360;
return bOSet[Math.floor(angle / 360 * bOSet.length)];
}
function calcBounds(pt, b, bOSet, bOSetBuff, sP, nS) {
for (var i = 0; i < nS; i ++) {
//console.log(tp);
var tp = getSidePoint(pt, i, sP, bOSet);
var bLen = getBoundOffset(tp, bOSet);
var td = tp.getDistance(b);
if (td < bLen) {
bOSetBuff[i] -= (bLen - td) / 24;
}
}
}
function getSidePoint(pt, index, sP, bOSet) {
return pt + sP[index] * bOSet[index];
}
function updateBounds(bOSet, bOSetBuff, nS) {
for (var i = 0; i < nS; i ++)
bOSet[i] = bOSetBuff[i];
}
//--------------------- main ---------------------
function onFrame() {
react(point, boundOffset, boundOffsetBuff, sidePoints, numSegment, radius);
react(point2, boundOffset2, boundOffsetBuff2, sidePoints2, numSegment, radius);
react(point_tit, boundOffset_tit, boundOffsetBuff_tit, sidePoints_tit, numSegment_tit, radius_tit);
react(point_tit2, boundOffset_tit2, boundOffsetBuff_tit2, sidePoints_tit2, numSegment_tit, radius_tit);
react(point_tit, boundOffset_tit_tit, boundOffsetBuff_tit_tit, sidePoints_tit_tit, numSegment_tit, radius_tit_tit);
react(point_tit2, boundOffset_tit_tit2, boundOffsetBuff_tit_tit2, sidePoints_tit_tit2, numSegment_tit, radius_tit_tit);
iterate();
}
</script>
<style>
/* Center the loader */
#loader {
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border: 16px solid #000000;
border-radius: 50%;
border-top: 16px solid #ffffff;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Add animation to "page content" */
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}
@-webkit-keyframes animatebottom {
from { bottom:-100px; opacity:0 }
to { bottom:0px; opacity:1 }
}
@keyframes animatebottom {
from{ bottom:-100px; opacity:0 }
to{ bottom:0; opacity:1 }
}
</style>
</head>
<body onload="myFunction()" style="margin:0;">
<div id="loader"></div>
<p>Threshold <input type="range" id="thresholdAmount" value="25"></p>
<p><button onclick="resetBackground()">resetBackground()</button></p>
<canvas id="canvas" resize stats hidpi="off"></canvas>
<script>
var myVar;
function myFunction() {
document.getElementById("canvas").style.display = "none";
myVar = setTimeout(showPage, 6000);
}
function showPage() {
document.getElementById("loader").style.display = "none";
document.getElementById("canvas").style.display = "inline";
}
</script>
</body>
</html>