Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <canvas id="mycanvas" width="100%" height="100%"></canvas>

              
            
!

CSS

              
                body{
    margin: 0; padding: 0; 
    /*background:linear-gradient(360deg, #e56420, #37bbde);*/
    overflow:hidden;
    background-color: black;
    width:100%;
    height:100vh;
    background-size:cover;
    background-blend-mode: hard-light;
    animation: hue-rotate 10s linear infinite;
}

@keyframes hue-rotate {
  from {
    -webkit-filter: hue-rotate(0);
    -moz-filter: hue-rotate(0);
    -ms-filter: hue-rotate(0);
    filter: hue-rotate(0);
  }
  to {
    -webkit-filter: hue-rotate(360deg);
    -moz-filter: hue-rotate(360deg);
    -ms-filter: hue-rotate(360deg);
    filter: hue-rotate(360deg);
  }
}
              
            
!

JS

              
                ;void function () {

	var depth = 16 , branchWidth = 12, step = 0
	var newDepthPub, depthPub
	var canvas = document.getElementById('mycanvas')
	var ctx = canvas.getContext('2d')
	canvas.width = window.innerWidth
	canvas.height = window.innerHeight
    ctx.globalCompositeOperation = 'lighter';

	var drawTree = function (ctx, startX, startY, length, angle ,depth, branchWidth) {
		var rand = Math.random, newDepth,
			newLength, newAngle, maxBranch = 3, 
			endX, endY, maxAngle = 2*Math.PI /4,
			subBranches, lenShrink;

		ctx.beginPath()
		ctx.moveTo(startX, startY)
		endX = startX + length * Math.cos(angle)
		endY = startY + length * Math.sin(angle)
		ctx.lineCap = 'round'
		ctx.lineWidth = branchWidth
		ctx.lineTo(endX, endY)

		if (depth <= 2) {
			ctx.strokeStyle = 'rgb(0,' +(((rand()*64) + 128) >> 0) + ',0)'
		}else{
			ctx.strokeStyle = 'rgb(' +(((rand()*64) + 64) >> 0) + ',50, 25)'
		}
		ctx.stroke()

		newDepth = depth -1
		if (!newDepth) return


		subBranches = maxBranch -1
		branchWidth *= .7

		for (var i = 0; i < subBranches; i++) {
			newAngle = angle + rand()*maxAngle - maxAngle*.5
			newLength = length * (.7 + rand()*.3)
			setTimeout(function () {
				drawTree(ctx, endX, endY, newLength, newAngle, newDepth, branchWidth)
				newDepthPub = newDepth
				depthPub = depth
				step++;
			},100)
		}
	}

	var init = function () {
		step = 0
		canvas.width = window.innerWidth
		canvas.height = window.innerHeight
    	ctx.globalCompositeOperation = 'lighter';
		ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
		drawTree(ctx, ~~(window.innerWidth/2), ~~(window.innerHeight/1.02), 60, -Math.PI/2, depth, branchWidth)
	}

	var regrow = function () {
		if (step < 65534) return
		init()
	}

	document.querySelector('body').addEventListener('click', function (e) {
		regrow()
	})

	document.addEventListener('DOMContentLoaded',function(){
		init()
	},false);

	window.onresize = regrow

}();
              
            
!
999px

Console