tweaks, bugfix
This commit is contained in:
parent
f0ed7a17d9
commit
22ce8823a3
2 changed files with 45 additions and 55 deletions
|
|
@ -5,6 +5,8 @@ body {
|
|||
}
|
||||
|
||||
#sky {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: black;
|
||||
/*background: #ff8f00;*/
|
||||
/*background: black;*/
|
||||
|
|
@ -16,12 +18,9 @@ body {
|
|||
}
|
||||
|
||||
a{
|
||||
position: absolute;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
color: red;
|
||||
}
|
||||
|
||||
div{
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
font-family: pt sans, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
import '../css/app.css';
|
||||
|
||||
(function () {
|
||||
const num_clouds = 100,
|
||||
max_cloud_size = 300,
|
||||
let width = window.innerWidth,
|
||||
height = window.innerHeight;
|
||||
const num_clouds = 100;
|
||||
let size_factor = Math.random() * 1000 + 2000,
|
||||
max_cloud_size = (width * height) / size_factor,
|
||||
max_speed_x = 50,
|
||||
max_speed_y = 30,
|
||||
num_clusters = 30;
|
||||
|
|
@ -15,12 +18,11 @@ import '../css/app.css';
|
|||
};
|
||||
|
||||
document.onkeypress = () => {
|
||||
create_clouds();
|
||||
size_factor = Math.random() * 1000 + 2000;
|
||||
max_cloud_size = (width * height) / size_factor;
|
||||
arrange_clouds();
|
||||
}
|
||||
|
||||
let width = window.outerWidth,
|
||||
height = window.outerHeight;
|
||||
|
||||
window.onresize = () => {
|
||||
width = window.innerWidth;
|
||||
|
|
@ -39,38 +41,27 @@ import '../css/app.css';
|
|||
newCloud.style.background = `radial-gradient(circle ${size / 2}px, rgba(255, ${255 - green_shift}, 0, ${Math.random()}), rgba(0, 0, 0, 0.0)) no-repeat`;
|
||||
newCloud.setAttribute("size", `${size}`);
|
||||
sky.appendChild(newCloud);
|
||||
if (i === 0) {
|
||||
newCloud.style.top = "0";
|
||||
newCloud.style.left = "0";
|
||||
newCloud.style.width = `100vw`;
|
||||
newCloud.style.height = `100vh`;
|
||||
newCloud.setAttribute("size", `2000`);
|
||||
// newCloud.style.background = `radial-gradient(circle 1000px, rgba(255, 0, 0, 0.0), rgba(255, 0, 0, 1.0)) no-repeat`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let arrange_clouds = function () {
|
||||
let num_clouds_in_cluster = (Math.floor(num_clouds / num_clusters));
|
||||
for (let i = 1; i < num_clouds; i++) {
|
||||
for (let i = 0; i < num_clouds; i++) {
|
||||
if (i % num_clouds_in_cluster === 0) {
|
||||
cluster_x = Math.random() * width;
|
||||
cluster_y = Math.random() * height;
|
||||
cluster_size = Math.random() * 50;
|
||||
cluster_x = 100 + Math.random() * width;
|
||||
cluster_y = 100 + Math.random() * height;
|
||||
cluster_size = Math.random() * 150;
|
||||
}
|
||||
|
||||
let cloud = get_cloud(i);
|
||||
cloud.style.top = `${cluster_x - cluster_size / 2 + Math.random() * cluster_size}px`;
|
||||
cloud.style.left = `${cluster_y - cluster_size / 2 + Math.random() * cluster_size}px`;
|
||||
cloud.style.left = `${cluster_x - max_cloud_size / 2 + Math.random() * cluster_size}px`;
|
||||
cloud.style.top = `${cluster_y - max_cloud_size / 2 + Math.random() * cluster_size}px`;
|
||||
}
|
||||
cluster_size = Math.random() * max_cloud_size;
|
||||
cluster_x = width + cluster_size + Math.random() * width;
|
||||
cluster_y = height + cluster_size + Math.random() * height;
|
||||
}
|
||||
|
||||
let step = function () {
|
||||
let cloud_index = Math.floor(Math.random() * num_clouds);
|
||||
if (cloud_index > 1) {
|
||||
|
||||
let cloud = get_cloud(cloud_index);
|
||||
let x = parseInt(cloud.style.left), y = parseInt(cloud.style.top);
|
||||
|
||||
|
|
@ -100,7 +91,7 @@ import '../css/app.css';
|
|||
cloud.style.left = `${x}px`;
|
||||
cloud.style.top = `${y}px`;
|
||||
}
|
||||
}
|
||||
|
||||
requestAnimationFrame(step);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue