cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              * {
  background-color: black;
}
.lamp {
  height: 500px;
  width: 100%;
  background-color: black;
  position: absolute;
  -webkit-filter: contrast(10);
  filter: contrast(10);
  top:0;
}

.blob {
  background-color: orange;
  position: absolute;
  -webkit-filter: blur(10px);
  filter: blur(10px)
}

            
          
!
            
              (function(document,lampDiv,numberBlobs){

	var lamp = document.getElementById(lampDiv);

	var Blob = function(size, x, y, initialHeading, initialSpeed){
		var width = height = size*2;

		//we use these to get the bounding X and Y vals for the blob ...
		var leftX = x - size,
			rightX = x + size,
			topY = y - size,
			bottomY = y + size,
			domObj = null,
			that = this;

		function recalcPos(){
			leftX = x - size;
			rightX = x + size;
			topY = y - size;
			bottomY = y + size;

			that.domObj.style.top = topY + "px";
			that.domObj.style.left = leftX + "px";
		}

		//self updating to only allow single run
		this.render = function() {

			that.domObj = document.createElement("div");
			that.domObj.setAttribute("class","blob");
			that.domObj.style.width = width + "px";
			that.domObj.style.height = height + "px";
			that.domObj.style.borderRadius = size + "px";
			lamp.appendChild(that.domObj);

			that.render = function() {
				console.log("Rendered already");
			};

			recalcPos();

			return that;
		};

		this.update = function() {
			y += (initialHeading*initialSpeed);

			if(initialHeading < 0){
				if(topY < 0) {
					y = lamp.clientHeight;
				}
			} else {
				if(bottomY > lamp.clientHeight) {
					y = 0;
				}
			}

			recalcPos();
		};
	};


	function randomUpTo(min,max) {
		return Math.floor(Math.random() * max) + (1 + min);
	}
	//start with N blobs of different sizes, headings etc.
	var blobArray = [];
	for(var i = 0; i < numberBlobs; i++) {

    var InitialHeading = randomUpTo(1,2) % 2 == 0 ? -1 : 1;
		var InitialSpeed = randomUpTo(0,10);
		var Size = randomUpTo(10,Math.floor(lamp.clientHeight/8));
		
    var X = randomUpTo(0,lamp.clientWidth);
		var Y = randomUpTo(0,lamp.clientHeight);


		blobArray.push(new Blob(Size,X,Y,InitialHeading,InitialSpeed).render());
	}

	var updateBlobs = function(){
		blobArray.forEach(function(v){
			v.update();
		});
	}

	setInterval(updateBlobs,100);

})(document,'lamp',30);

            
          
!
999px
Loading ..................

Console