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. 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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <svg class="result">
	<g class="copy"></g>
	<g class="spiral"></g>
</svg>
<div class="info">Move mouse<br><small>- click to stamp current version to background<br>
	- double click to clear background
</small></div>
              
            
!

CSS

              
                html, body, svg {
	width: 100vw;
	height: 100vh;
	margin: 0;
	padding: 0;
}
.copy {
	opacity: .6;
}
path {
	stroke: hsla(0,10%,60%,.75);
}
.info {
	text-align: center;
	width: 50%;
	height: 100px;
	position: fixed;
	top: 35%;
	z-index: 10;
	left: 25%;
	font-size: 24pt;
	font-family: monospace;
	color: hsla(0,0%,10%,0.5);
	transition: opacity 1.2s;
	pointer-events: none;
	user-select: none;
}
.moved .info {opacity: 0;}
small {
	display: inline-block;
	font-size: small;
	line-height: 12pt;
	margin: 15px 0 0 0;
	padding: 0;
}
              
            
!

JS

              
                Object.prototype.rad = (deg) => (Math.PI / 180) * deg;
Object.prototype.deg = (rad) => (180 / Math.PI) * rad;
Object.prototype.getAngle = (point1, point2) =>
	Math.atan2(point1.y - point2.y, point1.x - point2.x);
Object.prototype.getDistance = (point1, point2) =>
	Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));

const eleResult = document.querySelector(".result");
const elePath = document.querySelector("#fibo");
const eleSpiral = document.querySelector(".spiral");
const eleCopy = document.querySelector(".copy");
const NS = eleResult.namespaceURI;
let ROTATE = 10;
const fibo = [0, 1];
const pos = 1;
let CX, CY;
let maxValue = -1;
let minValue = Infinity;
let divide = 100;
let ddeg = 10;
let crossLines = [];
function next() {
	fibo.push(fibo[fibo.length - 1] + fibo[fibo.length - 2]);
	return fibo[fibo.length - 1];
}
for (var i = 0; i < 50; i++) {
	const current = next();
	const x = fibo.length;
}


function click(evt) {
	const { clientX, clientY } = evt;
	eleCopy.innerHTML += eleSpiral.innerHTML;
};

function dblclick(evt) {
	const { clientX, clientY } = evt;
	evt.preventDefault();
	eleCopy.innerHTML = eleSpiral.innerHTML;
	return false;
};

function mousemove(evt) {
	const { clientX, clientY } = evt;
	document.body.classList.add('moved');
	CX = clientX;
	CY = clientY;
	eleSpiral.innerHTML = "";
	crossLines = [];
	ROTATE = Math.cos(Math.rad(Date.now().toFixed()/200))*40+80;
	ROTATE = Math.abs(ROTATE) < 1 ? 1 : ROTATE;
	for (var i = 0; i < 360; i += ROTATE) {
		addSpiral(i + ddeg, divide, i);
	}
	for (var i = 0; i < fibo.length; i++) {
		const spiral = c(
		"path",
		{ d:crossLines[i]+' Z', fill: "transparent", "stroke-width": "1px" },
		NS
	);
	eleSpiral.appendChild(spiral);
	}
	divide++;
	ddeg += 5;
};

function addSpiral(ddeg = 0, divide, i) {
	let d = "";
	for (var x = 0; x < fibo.length; x++) {
		let y = fibo[x];
		let rad = Math.rad(x * ROTATE + ddeg);
		let xx = (Math.cos(rad) * y) / divide + CX;
		let yy = (Math.sin(rad) * y) / divide + CY;
		if (d === "") {
			d = `M ${xx} ${yy} L `;
		}
		d += `${xx} ${yy} `;
		if (crossLines[x] === undefined) {
			crossLines[x] = `M ${xx} ${yy} L `;
		}
		crossLines[x] += `${xx} ${yy} `;
	}
	const spiral = c(
		"path",
		{ d, fill: "transparent", stroke: "black", "stroke-width": "1px" },
		NS
	);
	eleSpiral.appendChild(spiral);
}

function setMinMax(y) {
	maxValue = Math.min(innerHeight, Math.max(maxValue, y));
	minValue = Math.min(minValue, y);
	//eleResult.setAttribute("viewBox", `0 0 ${fibo.length} ${maxValue}`);
}

function c(tagName, attributes, ns) {
	const ele = ns
		? document.createElementNS(ns, tagName)
		: document.createElement(tagName);
	for (att in attributes) {
		ele.setAttribute(att, attributes[att]);
	}
	return ele;
}


window.addEventListener("click", click);
window.addEventListener("dblclick", dblclick);
window.addEventListener("mousemove", mousemove);
              
            
!
999px

Console