• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Animated background for all layouts

PhoOwned

^_^
Joined
Nov 11, 2010
Messages
375
Reaction score
66
I made animated background that you can add to your layout ^_^
* Animation will be over your background image/color and under logo/website content
* Works in IE, Firefox, Chrome
* Works fine after resize/scroll browser
Example (text, color, animation speed is configurable):
OTS.ME - Background example
How to add?
1. Above:
PHP:
</head>
Paste:
PHP:
<script type="text/javascript">
function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  return myHeight
}

var colors = new Array("#009900","#00AA00","#00CC00","#00EE00");

function doAnimObjects() {
	var height = getHeight();
	var arr = new Array();
	if (navigator.userAgent.indexOf('MSIE') !=-1)
		arr = document.getElementById("backgroundAnim").childNodes;
	else
		arr = document.getElementsByName("newAnim");
	for(var i = 0; i < arr.length; i++)
	{
		var obj = arr[i];
		var objMargin = parseInt(obj.style.marginTop);
		if(objMargin < height)
			obj.style.marginTop = (objMargin + 2 + parseInt(obj.style.borderTop)) + "px";
		else
		{
			var rand = Math.floor(Math.random()*4);
			obj.style.borderTop = rand + "px";
			obj.style.color = colors[rand];
			obj.style.marginTop = "-" + height + "px";
			obj.style.marginLeft = Math.floor(Math.random()*document.body.clientWidth) + "px";
			obj.style.fontSize = (8 + Math.floor(Math.random()*18)) + "px";
		}
	}
	setTimeout(doAnimObjects, 30);
}
</script>
2. Under:
PHP:
<body>
Paste:
PHP:
<div style="position: absolute; margin-top: 0px; margin-left: 0px">
	<div id="backgroundAnim" style="position: fixed; width: 100%; height: 100%" ></div>
</div>
<div style="position: absolute; margin-top: 0px; margin-left: 0px">
3. Above:
PHP:
</body>
Paste:
PHP:
</div>
<script type="text/javascript">
function startBackgroundAnim() {
	for(var i = 0; i < 90; i++)
	{
		var newdiv = document.createElement(\'div\');
		newdiv.style.marginLeft = Math.floor(Math.random()*document.body.clientWidth) + "px";
		newdiv.style.marginTop = "-" + Math.floor(Math.random()*document.documentElement.clientHeight*2) + "px";
		newdiv.style.fontSize = (8 + Math.floor(Math.random()*18)) + "px";
		newdiv.style.position = "absolute";
		newdiv.style.textAlign = "center";
		var rand = Math.floor(Math.random()*4);
		newdiv.style.borderTop = rand + "px";
		newdiv.style.color = colors[rand];
		newdiv.innerHTML = "M<br />A<br />T<br />R<br />I<br />X";
		newdiv.setAttribute("name","newAnim");
		document.getElementById("backgroundAnim").appendChild(newdiv);
	}
	doAnimObjects();
}
window.onload = startBackgroundAnim;
</script>
 
bb, 100% cpu
I know that it use a lot of CPU, but 100%.. nice PC ;)
On my PC it use:
18-23% CPU when I open page in 5 cards [chrome]
25-30% CPU - 10 cards (start lagging a bit) [chrome]

CONFIG
Maximum number of frames = 1000 / 30 = 33FPS:
setTimeout(doAnimObjects, 30);
Number of texts 90:
for(var i = 0; i < 90; i++)
Example with time between frames 60ms (2x higher, 17.5 FPS only) and number of texts 30 (3x lower):
OTS.ME On my PC:
Internet Explorer 8 - 0-3% CPU
Firefox (newest) - 0-2% CPU
Chrome (newest) - 0-2% CPU
 
Tested at Intel Pentium III Xeon 2x 2.5 GHz with ONLY ONE tab opened.
Firefox Portable:
dbqEt.png


Google Chrome:
p8Upp.png
 
I know that it use a lot of CPU, but 100%.. nice PC ;)
On my PC it use:
18-23% CPU when I open page in 5 cards [chrome]
25-30% CPU - 10 cards (start lagging a bit) [chrome]
it's probably because you have multiple cores but your browser is singlethreaded
 
I turned off 3 cores, but still no lag. I had to change frequncy to 1.33GHz to make it a bit laggy (1.5GHz, no lag, use 60-80% CPU). Buy better PC Cyko :p
 
It's making actually lagg. More people using the f5 button on the page, more CPU resource waste. You can use it much more usefull.
 

Similar threads

Back
Top