|
@@ -1,6 +1,5 @@
|
|
|
-<html>
|
|
|
|
|
-
|
|
|
|
|
-<style>
|
|
|
|
|
|
|
+<html><head>
|
|
|
|
|
+<meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>
|
|
|
|
|
|
|
|
body, html, canvas {
|
|
body, html, canvas {
|
|
|
padding: 0;
|
|
padding: 0;
|
|
@@ -13,9 +12,9 @@ body, html, canvas {
|
|
|
|
|
|
|
|
</style>
|
|
</style>
|
|
|
|
|
|
|
|
-<body>
|
|
|
|
|
|
|
+</head><body>
|
|
|
|
|
|
|
|
- <canvas></canvas>
|
|
|
|
|
|
|
+ <canvas height="627" width="20"></canvas>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
|
|
@@ -66,6 +65,7 @@ var colors = [
|
|
|
'#66ff00',
|
|
'#66ff00',
|
|
|
'#ffff66',
|
|
'#ffff66',
|
|
|
'#b4ff00',
|
|
'#b4ff00',
|
|
|
|
|
+ '#ff5400',
|
|
|
'#ffff33',
|
|
'#ffff33',
|
|
|
'white',
|
|
'white',
|
|
|
'black'
|
|
'black'
|
|
@@ -81,8 +81,16 @@ function randomFloat(min, max) {
|
|
|
return (Math.random() * (max - min + 1)) + min;
|
|
return (Math.random() * (max - min + 1)) + min;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function randomColor() {
|
|
|
|
|
- return colors[Math.floor(Math.random() * colors.length)];
|
|
|
|
|
|
|
+function randomColor(blacklist) {
|
|
|
|
|
+ if (!blacklist) blacklist = [];
|
|
|
|
|
+
|
|
|
|
|
+ var color;
|
|
|
|
|
+ do {
|
|
|
|
|
+ color = colors[Math.floor(Math.random() * colors.length)]
|
|
|
|
|
+ }
|
|
|
|
|
+ while (blacklist.indexOf(color) > -1);
|
|
|
|
|
+
|
|
|
|
|
+ return color;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var backgroundFillStyle = 'blue';
|
|
var backgroundFillStyle = 'blue';
|
|
@@ -141,17 +149,17 @@ function setupClipping(ctx, x, y, w, h) {
|
|
|
function resetFeature(f) {
|
|
function resetFeature(f) {
|
|
|
if (f.type === 'line') {
|
|
if (f.type === 'line') {
|
|
|
f.fillStyle = randomColor();
|
|
f.fillStyle = randomColor();
|
|
|
- f.speed = randomFloat(0.1, 1);
|
|
|
|
|
- f.h = randomInt(10, 50);
|
|
|
|
|
|
|
+ f.speed = randomFloat(0.5, 2);
|
|
|
|
|
+ f.h = randomInt(20, 80);
|
|
|
f.y = -f.h;
|
|
f.y = -f.h;
|
|
|
} else if (f.type === 'circle') {
|
|
} else if (f.type === 'circle') {
|
|
|
if (f.speed < 0) {
|
|
if (f.speed < 0) {
|
|
|
f.r = 0;
|
|
f.r = 0;
|
|
|
- f.fillStyle = randomColor();
|
|
|
|
|
- f.speed = randomFloat(0.1, 1);
|
|
|
|
|
|
|
+ f.fillStyle = randomColor(['black']);
|
|
|
|
|
+ f.speed = randomFloat(0.8, 1.5);
|
|
|
} else {
|
|
} else {
|
|
|
f.r -= f.speed;
|
|
f.r -= f.speed;
|
|
|
- f.speed = -randomFloat(0.1, 1);
|
|
|
|
|
|
|
+ f.speed = -randomFloat(0.8, 1.5);
|
|
|
}
|
|
}
|
|
|
f.y = clipRegion.y + clipRegion.h/2;
|
|
f.y = clipRegion.y + clipRegion.h/2;
|
|
|
f.x = clipRegion.x + clipRegion.w/2;
|
|
f.x = clipRegion.x + clipRegion.w/2;
|
|
@@ -173,12 +181,12 @@ if (localStorage.clipRegion) {
|
|
|
|
|
|
|
|
function animateContent() {
|
|
function animateContent() {
|
|
|
// change background maybe
|
|
// change background maybe
|
|
|
- // if (randomInt(0, 10000) < 10) backgroundFillStyle = randomColor();
|
|
|
|
|
|
|
+ // if (randomInt(0, 1000) < 5) backgroundFillStyle = randomColor();
|
|
|
backgroundFillStyle = 'black';
|
|
backgroundFillStyle = 'black';
|
|
|
|
|
|
|
|
features.forEach(function (f) {
|
|
features.forEach(function (f) {
|
|
|
if (f.type === 'line') {
|
|
if (f.type === 'line') {
|
|
|
- if (f.y > canvas.height) {
|
|
|
|
|
|
|
+ if (f.y > canvas.width) {
|
|
|
resetFeature(f);
|
|
resetFeature(f);
|
|
|
} else {
|
|
} else {
|
|
|
f.y += f.speed;
|
|
f.y += f.speed;
|
|
@@ -218,13 +226,16 @@ function redraw() {
|
|
|
|
|
|
|
|
ctx.save();
|
|
ctx.save();
|
|
|
|
|
|
|
|
|
|
+ if (mode !== 'clip_edit') {
|
|
|
|
|
+ setupClipping(ctx, clipRegion.x, clipRegion.y, clipRegion.w, clipRegion.h);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ animateContent();
|
|
|
|
|
+ drawContent();
|
|
|
|
|
+
|
|
|
if (mode === 'clip_edit') {
|
|
if (mode === 'clip_edit') {
|
|
|
drawEllipse(ctx, 10, 10, 20, 20, 'red');
|
|
drawEllipse(ctx, 10, 10, 20, 20, 'red');
|
|
|
drawEllipse(ctx, clipRegion.x, clipRegion.y, clipRegion.w, clipRegion.h, '#ff0000aa');
|
|
drawEllipse(ctx, clipRegion.x, clipRegion.y, clipRegion.w, clipRegion.h, '#ff0000aa');
|
|
|
- } else {
|
|
|
|
|
- setupClipping(ctx, clipRegion.x, clipRegion.y, clipRegion.w, clipRegion.h);
|
|
|
|
|
- animateContent();
|
|
|
|
|
- drawContent();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ctx.restore();
|
|
ctx.restore();
|
|
@@ -288,7 +299,7 @@ function onMouseMove(e) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function onKeypress(e) {
|
|
function onKeypress(e) {
|
|
|
- if (e.key === 'Escape') {
|
|
|
|
|
|
|
+ if (e.key === 'e') {
|
|
|
mode = mode === 'clip_edit' ? '' : 'clip_edit';
|
|
mode = mode === 'clip_edit' ? '' : 'clip_edit';
|
|
|
} else if (e.key === 'f') {
|
|
} else if (e.key === 'f') {
|
|
|
toggleFullScreen();
|
|
toggleFullScreen();
|
|
@@ -307,5 +318,5 @@ requestAnimationFrame(redraw);
|
|
|
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
-</body>
|
|
|
|
|
-</html>
|
|
|
|
|
|
|
+
|
|
|
|
|
+</body></html>
|