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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              html {
	overflow: hidden;
	touch-action: none;
	content-zooming: none;
}
body {
	position: absolute;
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	background: #111;
}
#canvas {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 600px;
	height: 400px;
	margin-left: -300px;
	margin-top: -200px;
	background: #000;
}
#frame {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 700px;
	height: 500px;
	margin-left: -350px;
	margin-top: -250px;
	border-radius: 10px;
	box-shadow: 0px 0px 100px 0px #fda;
}
            
          
!
            
              ! function () {

	"use strict"; 

	function chromaKey(source, id) {
		// create new image
		var imgSource = new Image();
		imgSource.crossOrigin = "Anonymous";
		imgSource.src = source;
		imgSource.onload = function () {
			// render image in canvas
			var jpg    = document.createElement('canvas');
			var w = jpg.width  = this.width;
			var h = jpg.height = this.height;
			var ctx = jpg.getContext('2d');
			ctx.drawImage(this, 0, 0, w, h);
			// chroma Key
			var img = ctx.getImageData(0, 0, w, h),
				data = img.data;
			for (var i =0, n = data.length; i < n; i += 4) {
				var r = data [i + 0];
				var g = data [i + 1];
				var b = data [i + 2];
				// make white transparent (rgb > 240, 240, 240)
				if (r > 240 && g > 240 && b > 240) {  
					data[i + 3] = 0; 
				} 
			}
			// create new transparent image
			var transparent = document.createElement('canvas');
			transparent.width = w;
			transparent.height = h;
			var ctx = transparent.getContext('2d');
			ctx.putImageData(img, 0, 0);
			images[id] = transparent;
		}
	}

	// draw parallax image
	function parallax (id, x, y) {
		var image = images[id];
		if (image) {
			ctx.drawImage(image, x, y);
		}
	}

	// main loop
	function run() {
		// request next frame
		requestAnimationFrame(run);
		// clear screen
		ctx.clearRect(0, 0, canvas.width, canvas.height);
		// ease pointer
		pointer.cx += (pointer.x - pointer.cx) / 10;
		pointer.cy += (pointer.y - pointer.cy) / 10;
		var rx = -((canvas.width  / 2) - Math.max(15, Math.min(pointer.cx, canvas.width - 15))) / 7;
		var ry = -((canvas.height / 2) - Math.max(0, Math.min(pointer.cy, canvas.height - 5))) / 4.75;
		// parallax
		parallax(0, -20 + (rx / 2), -80 + (ry * 2)); 
		parallax(1, -40 + (rx / 2),  20 + (ry / 2)); 
		parallax(2, -20 + (rx / 3),  90 + (ry / 3)); 
		parallax(3, -20 - (rx / 2), 130 - (ry / 2)); 
		parallax(4,   0 - (rx / 1), 160 - (ry / 1));
		parallax(5, 240 - (rx * 2), 220 - (ry * 2));
	}

	// canvas
	var canvas  = ge1doot.canvas("canvas");
	var ctx     = canvas.ctx;
	// pointer
	var pointer = canvas.pointer;
	pointer.cx  = pointer.x = canvas.width / 2;
	pointer.cy  = 0;
	pointer.y = canvas.height;
	// images
	var images = [];
	// make jpg images transparent images
	chromaKey("is05.jpg", 0);
	chromaKey("is04.jpg", 1);
	chromaKey("is03.jpg", 2);
	chromaKey("is02.jpg", 3);
	chromaKey("is01.jpg", 4);
	chromaKey("is07.jpg", 5);
	// zyva!
	run();

}();
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console