Improved snow machichara

main
Inga 🏳‍🌈 14 years ago
parent 66d7f7c4f3
commit 67f0d3c785
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Common/dataobjects/AnonymousUserSettings.cs
  3. 7
      static/js/machichara/fractalsnow-bg-specific.js
  4. 13
      static/js/machichara/fractalsnow-specific.js

@ -15,7 +15,7 @@ namespace FLocal.Common.dataobjects {
//this._skinId = allSkins[Util.RandomInt(0, allSkins.Length)].id; //this._skinId = allSkins[Util.RandomInt(0, allSkins.Length)].id;
this._skinId = 28; this._skinId = 28;
this._modernSkinId = 2; this._modernSkinId = 2;
this._machicharaId = 2; this._machicharaId = 5;
} }
public int threadsPerPage { public int threadsPerPage {

@ -26,7 +26,7 @@
var sqrt3_2 = Math.sqrt(3) / 2; // Height of an equilateral triangle var sqrt3_2 = Math.sqrt(3) / 2; // Height of an equilateral triangle
var flakes = []; // Things that are dropping var flakes = []; // Things that are dropping
var scrollspeed = 64; // How often we animate things var scrollspeed = 64; // How often we animate things
var snowspeed = 500; // How often we add a new snowflake var snowspeed = 200; // How often we add a new snowflake
var maxflakes = 20; // Max number of flakes to be added at the same time var maxflakes = 20; // Max number of flakes to be added at the same time
var rand = function (n) { return Math.floor(n * Math.random()); } var rand = function (n) { return Math.floor(n * Math.random()); }
@ -110,8 +110,9 @@
function createSnowflake() { function createSnowflake() {
var order = 2; var order = 2;
var size = 10 + rand(90); var size = 10 + rand(90);
var t = (document.body.offsetWidth - 964) / 2; // var t = (document.body.offsetWidth - 964) / 2;
var x = (rand(2) == 0) ? rand(t) : t + 964 + rand(t); // Make it fit with my blog // var x = (rand(2) == 0) ? rand(t) : t + 964 + rand(t); // Make it fit with my blog
var x = rand(document.body.offsetWidth);
var y = window.pageYOffset; var y = window.pageYOffset;
flakes.push({ x: x, y: y, vx: 0, vy: 3 + rand(3), size: size, order: order }); flakes.push({ x: x, y: y, vx: 0, vy: 3 + rand(3), size: size, order: order });

@ -68,20 +68,22 @@
var sqrt3_2 = Math.sqrt(3)/2; // Height of an equilateral triangle var sqrt3_2 = Math.sqrt(3)/2; // Height of an equilateral triangle
var flakes = []; // Things that are dropping var flakes = []; // Things that are dropping
var scrollspeed = 80; // How often we animate things var scrollspeed = 80; // How often we animate things
var snowspeed = 500; // How often we add a new snowflake var snowspeed = 1500; // How often we add a new snowflake
var rand = function(n) { return Math.floor(n*Math.random()); } var rand = function(n) { return Math.floor(n*Math.random()); }
// Add a new snowflake at the top of the viewport // Add a new snowflake at the top of the viewport
function createSnowflake() { function createSnowflake() {
var order = 2 + rand(3); // 2nd, 3rd, or 4th order fractal var order = 2 + rand(3); // 2nd, 3rd, or 4th order fractal
var size = 10 + rand(90); var size = 10 + rand(90);
var width = size;
var height = size*sqrt3_2*4/3;
var x = rand(window.innerWidth - size); var x = rand(window.innerWidth - size);
var y = window.pageYOffset; var y = window.pageYOffset;
// Create a <canvas> element // Create a <canvas> element
var canvas = document.createElement("canvas"); var canvas = document.createElement("canvas");
canvas.width = size; canvas.width = width;
canvas.height = size*sqrt3_2*4/3; canvas.height = height;
canvas.style.position = "absolute"; canvas.style.position = "absolute";
canvas.style.left = x + "px"; canvas.style.left = x + "px";
canvas.style.top = y + "px"; canvas.style.top = y + "px";
@ -97,17 +99,18 @@
// Add the canvas to the document and to our array of snowflakes // Add the canvas to the document and to our array of snowflakes
document.body.appendChild(canvas); document.body.appendChild(canvas);
flakes.push({elt:canvas, x: x, y:y, vy:3+rand(3)}); flakes.push({elt:canvas, x: x, y:y, vy:3+rand(3), width:width, height:height});
} }
// This function animates the flakes falling down the screen // This function animates the flakes falling down the screen
function moveSnowflakes() { function moveSnowflakes() {
var maxy = window.pageYOffset + window.innerHeight; var maxy = window.pageYOffset + window.innerHeight;
var maxx = window.pageXOffset + window.innerWidth;
var i = 0; var i = 0;
while(i < flakes.length) { // Loop through the array of flakes while(i < flakes.length) { // Loop through the array of flakes
var flake = flakes[i]; var flake = flakes[i];
flake.y += flake.vy; flake.y += flake.vy;
if (flake.y > maxy) { if ((flake.y+flake.height > maxy) || (flake.x+flake.width > maxx)) {
// The flake has scrolled off, so get rid of it // The flake has scrolled off, so get rid of it
document.body.removeChild(flake.elt); document.body.removeChild(flake.elt);
flakes.splice(i, 1); flakes.splice(i, 1);

Loading…
Cancel
Save