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

              
                - let data = [
- 	{ shape: '⭐', n: 6, rf: .57, sec: [ { shape: '⭐', n: 5, rf: .47, sf: .75 } ] }, 
- 	{ shape: '⭐', typ: 1, hf: .25 }, 
- 	{ shape: '🌙', n: 24, sec: [ { shape: '⭐', n: 12, rf: .47, sf: .4, sec: [ { shape: '⭐', n: 6, rf: .47, sf: .25 } ] }, { shape: '⭐', n: 5, rf: .47, sf: .5, tip: 1 } ] }
- ];
- let nd = data.length;

mixin star(o)
	- let typ = o.typ || 0, n = o.n || 5;
	- let rf = o.rf || .5, hf = o.hf || 0, sf = o.sf || 1;
	- let m = (1 + typ)*n;
	- let ba = Math.PI/n, cos_ba = Math.cos(ba);
	- let rri = rf*cos_ba, rh = hf;
	- let sq = 1 + Math.pow(rri, 2) - 2*rri*cos_ba;
	- let re = Math.sqrt(sq);
	- let cos_ax = .5*(1 + sq - Math.pow(rri, 2))/re;
	- let rad_ax = Math.acos(cos_ax);
	- let deg_ax = +(rad_ax*180/Math.PI).toFixed(2);
	- let rcm = +(.5*(.5*Math.PI - rad_ax)/Math.PI).toFixed(3);
	- let rad_ay = typ*Math.atan(Math.sin(rad_ax)/rh);
	- let rsw = +(typ*Math.hypot(rh, Math.sin(rad_ax))).toFixed(2);
	- let rsh = +(typ*cos_ax).toFixed(2);
	- let deg_ay = +(typ*rad_ay*180/Math.PI).toFixed(2);
	- let vx = [];
	- for(let i = 0; i < 2*n; i++)
		- let ca = i*ba - .5*Math.PI;
		- let cr = i%2 ? rri : 1;
		- vx.push([50*(1 + cr*Math.cos(ca)), 50*(1 + cr*Math.sin(ca))])
	- vx = vx.map(c => c.map(k => `${+k.toFixed(2)}%`).join(' '))
	div(class=`hang ${o.shape} ${typ ? '🟨' : '🟫'}` style=`--typ: ${typ}; --n: ${n}; --sf: ${sf}; --re: ${+re.toFixed(2)}; --ax: ${deg_ax}deg; --rcm: ${rcm}; --pos: ${o.tip || 0}${typ ? `; --rsw: ${rsw}; --rsh: ${rsh}; --ay: ${deg_ay}deg` : `; --vx: ${vx}`}`)
		- for(let i = 0; i < m; i++)
			.lat.comp(style=`--i: ${i%n}${typ ? `; --q: ${~~(i/n)}` : ''}`)
		if !typ
			.main.comp
		if(o.sec)
			- let ns = o.sec.length;
			- for(let i = 0; i < ns; i++)
				+star(o.sec[i])

mixin moon(o)
	- let typ = o.typ || 0, n = o.n || 20, rf = o.rf || .875, ofx = o.ofx || .4375;
	- let rad_al = Math.acos(.5*(1 + Math.pow(ofx, 2) - Math.pow(rf, 2))/Math.abs(ofx));
	- let rad_as = Math.PI - Math.acos(.5*(Math.pow(ofx, 2) + Math.pow(rf, 2) - 1)/ofx/rf);
	- let rad_dl = 2*(Math.PI - rad_al);
	- let rad_ds = 2*(Math.PI - rad_as);
	- let rad_bl = rad_dl/n;
	- let rad_bs = rad_ds/n;
	- let rel = +(2*Math.tan(.5*rad_bl)).toFixed(3);
	- let res = +(2*rf*Math.tan(.5*rad_bs)).toFixed(3);
	- let rsl = +(.5*rad_al/Math.PI).toFixed(3);
	- let rss = +(.5*rad_as/Math.PI).toFixed(3);
	- let rdl = +(.5*rad_dl/Math.PI).toFixed(3);
	- let rds = +(.5*rad_ds/Math.PI).toFixed(3);
	- let deg_dl = +(rad_dl*180/Math.PI).toFixed(2);
	- let deg_ds = +(rad_ds*180/Math.PI).toFixed(2);
	div(class=`hang ${o.shape} ${typ ? '🟨' : '🟫'}` style=`--n: ${n}; --rf: ${rf}; --ofx: ${ofx}; --rel: ${rel}; --res: ${res}; --rsl: ${rsl}; --rss: ${rss}; --rdl: ${rdl}; --rds: ${rds}; --dl: ${deg_dl}deg; --ds: ${deg_ds}deg`)
		- for(let i = 0; i < n; i++)
			.lat.comp(style=`--i: ${i}`)
		.main.comp
		if(o.sec)
			- let ns = o.sec.length;
			- for(let i = 0; i < ns; i++)
				+star(o.sec[i])

style
	- for(let i = 0; i < nd; i++)
		| .toy > .hang:nth-of-type(n + #{i + 1}) { --py: #{+(i/nd).toFixed(3)} }
.toy
	- for(let i = 0; i < nd; i++) {
		- let o = data[i];
		if o.shape == '⭐'
			+star(o)
		else
			+moon(o)
	- }

audio(src='https://assets.codepen.io/2017/castleonacloud.mp3' controls='true')
              
            
!

CSS

              
                $ro: 6.25em;
$w: 1em;
$t: 12s;

@function ccirc($pos, $hue, $lum, $a: .3) {
	@return 
		repeating-radial-gradient(circle at 100% 100%, 
				transparent 0 $pos, 
				hsla($hue, 100%, calc(#{$lum}*(1 + var(--inc))), $a), 
				transparent $pos + 2px)
}

@property --houdini {
	syntax: '<integer>';
	initial-value: 1;
	inherits: true
}

html {
	height: 100%;
	background: #000014;
	
	&:before, &:after {
		position: absolute;
		z-index: -1;
		width: 100%;
		opacity: .05;
		color: #fff;
		font: italic 900 4vmin/ 2 petit formal script;
		text-align: center
	}
	
	&:after { content: 'Missing you every day' }
	
	&:before { content: '1st of June 1927 - 18th of January 2019' }
}

body, div { display: grid }

body {
	--s: var(--houdini, 0);
	--not-s: calc(1 - var(--s));
	overflow: hidden;
	margin: 0;
	min-height: 3*$ro;
	perspective: 39em
}

div, ::before, ::after { grid-area: 1/ 1; place-self: center }

::before, ::after {
	--not-k: calc(1 - var(--k));
	--sgn-k: calc(2*var(--k) - 1)
}

::before { --k: 0 }
::after { --k: 1 }

div { transform-style: preserve-3d }

.toy {
	animation: rot-y $t linear infinite;
	
	> .hang {
		transform: 
			rotatey(calc(var(--py)*1turn)) 
			translate(1.5*$ro) 
			//rotatey(calc(var(--py)*-1turn))
	}
}

@keyframes rot-y {
	to { transform: rotatey(calc((1 - var(--py, 0))*1turn)) }
}

.hang {
	--not-typ: calc(1 - var(--typ));
	position: relative;
	
	> .hang { 
		--not-pos: calc(1 - var(--pos, 0));
		transform: 
			rotatex(calc(var(--pos)*var(--dl, 0deg)))
			translate3d(0, calc((1.2 + var(--sf))*var(--not-pos)*#{$ro}), calc(var(--pos)*#{-$ro})) 
			rotatex(calc(-1*var(--pos)*var(--dl, 0deg))) 
			translatey(calc(var(--pos)*var(--sf)*#{$ro}))
	}
	
	&:before {
		position: absolute;
		bottom: 50%;
		width: 4px; height: 2*$ro;
		transform: rotatey(calc(var(--py)*-1turn));
		background: 
			repeating-linear-gradient(60deg, 
					darkorange 0 4px, maroon 0 8px);
		animation: rot-y $t linear infinite reverse;
		content: ''
	}
}

@property --int {
	syntax: '<integer>';
	initial-value: 0;
	inherits: false
}

.⭐ {	
	> .lat {
		--p: calc(var(--i)/var(--n));
		--not-up: Min(1, var(--i));
		--up: calc(1 - var(--not-up));
		--dif: calc(2*var(--i) - var(--n));
		--not-dn: Min(1, Max(var(--dif), calc(-1*var(--dif))));
		--dn: calc(1 - var(--not-dn));
		height: 0;
		transform: rotatex(calc(var(--p)*1turn)) translatey(calc(-1*var(--sf)*#{$ro}));
			
		&::before, &::after {
			--sum: calc(var(--p) + var(--sgn-k)*var(--rcm) + 1);
			--int: calc(var(--sum) - .5);
			--mod: calc(var(--sum) - var(--int));
			--term: calc(var(--s)*var(--mod) + var(--not-s)*var(--p));
			--abs: Max(calc(var(--term) - .5), calc(.5 - var(--term)));
			--inc: calc(2*var(--abs) - .5);
			--sgn-j: calc(var(--dn)*var(--sgn-k) - 
										var(--up)*var(--sgn-k) + 
										var(--not-dn)*var(--not-up)*clamp(-1, var(--dif), 1));
			--j: calc(.5*(var(--sgn-j) + 1));
			width: calc(var(--sf)*(var(--not-typ)*#{$w} + 2*var(--typ)*var(--rsw, 0)*#{$ro}));
			height: calc(var(--sf)*(var(--not-typ)*var(--re) + var(--typ)*var(--rsh, 0))*#{$ro});
			transform-origin: 50% 0;
			transform: 
				rotatey(calc(var(--k)*.5turn)) 
				rotatex(var(--ax)) 
				scalex(calc(var(--not-typ) + var(--typ)*var(--sgn-q, 0)*var(--sgn-k))) 
				rotatey(var(--ay, 0deg));
		}
	}
	
	.main {
		&::before, &::after {
			-webkit-clip-path: polygon(var(--vx));
							clip-path: polygon(var(--vx))
		}
	}
}

@property --intl {
	syntax: '<integer>';
	initial-value: 0;
	inherits: true
}

@property --ints {
	syntax: '<integer>';
	initial-value: 0;
	inherits: true
}

@property --rndl {
	syntax: '<integer>';
	initial-value: 0;
	inherits: true
}

@property --rnds {
	syntax: '<integer>';
	initial-value: 0;
	inherits: true
}

.🌙 {
	> .lat {
		--p: calc((var(--i) + .5)/var(--n));
		--pl: calc(.25 - var(--rsl) - var(--p)*var(--rdl) + 1);
		--ps: calc(.25 - var(--rss) - var(--p)*var(--rds) + 1);
		--intl: calc(var(--pl) - .5);
		--ints: calc(var(--ps) - .5);
		--modl: calc(var(--pl) - var(--intl));
		--mods: calc(var(--ps) - var(--ints));
		--absl: Max(calc(var(--modl) - .5), calc(.5 - var(--modl)));
		--abss: Max(calc(var(--mods) - .5), calc(.5 - var(--mods)));
		--incl: calc(2*var(--absl) - .5);
		--incs: calc(2*var(--abss) - .5);
		--rndl: var(--modl);
		--rnds: var(--mods);
		
		&::before, &::after {
			--r: calc((var(--k) + var(--not-k)*var(--rf))*#{$ro});
			--ax: calc(var(--not-k)*(var(--rss)*-1turn - var(--p)*var(--ds)) + 
								 var(--k)*(var(--rsl)*-1turn - var(--p)*var(--dl)));
			--h: calc((var(--not-k)*var(--res) + var(--k)*var(--rel))*#{$ro});
			--inc: calc(var(--k)*var(--incl) + var(--not-k)*var(--incs));
			--rnd: calc(var(--k)*var(--rndl) + var(--not-k)*var(--rnds));
			--dif: calc(var(--k) - var(--rnd));
			--not-xor: calc(1 - var(--dif)*var(--dif));
			--sh: calc(-.5*var(--not-xor));
			width: $w; height: var(--h);
			transform: 
				translatez(calc(var(--not-k)*var(--ofx)*#{$ro}))
				rotatex(var(--ax)) 
				translatez(var(--r)) 
				scaley(1.05);
			background-position: 50% calc(-1*var(--i)*var(--h));
			background-size: auto calc(var(--n)*var(--h));
			background-color: hsl(25, 50%, calc(50%*(1 - 1.5*var(--sgn-k)*var(--inc))))
		}
	}
	
	> .main {
		&::before, &::after {
			--sh: calc(-.25 - .5*var(--k));
			--mask: 
				radial-gradient(circle at calc(50%*(1 + var(--ofx))), 
						transparent calc(var(--rf)*#{$ro}), 
						red calc(var(--rf)*#{$ro} + 1px));
			-webkit-mask: var(--mask);
							mask: var(--mask);
		}
	}
}

.🟫 {
	&.⭐ {
		.lat { --sh: calc(.5*var(--j) - 1.5) }
		
		.main { --sh: calc(-.5*var(--j) - .75) }
	}
	
	.comp {
		&::before, &::after {
			background: 
				var(--over, #{unquote(' ')})
				url(https://assets.codepen.io/2017/wood_door.jpg) 50%/ cover
				burlywood;
			background-blend-mode: overlay
		}
	}
	
	.lat {
		&::before, &::after {
			background-color: hsl(25, 50%, calc(50%*(1 + var(--inc))));
		}
	}
}

.🟨 {	
	.lat {
		--sgn-q: calc(2*var(--q) - 1);
	
		&::before, &::after {
			--sh: calc(-.25*(3*var(--q) - var(--sgn-q)*(1 - var(--j))) - .125);
			background: 
				ccirc(5px, 47, 44%), 
				ccirc(11px, 48, 45%), 
				ccirc(17px, 49, 47%), 
				ccirc(41px, 41, 43%), 
				linear-gradient(90deg, 
						transparent 50%, 
						hsl(40, 100%, calc(50%*(1 + var(--inc)))) 0, 
						hsl(55, 100%, calc(52%*(1 + var(--inc)))));
			background-blend-mode: multiply;
			clip-path: polygon(50% 0, 50% calc(var(--re)*#{$ro}), 100% 100%)
		}
	}
}

.comp {
	place-self: center;
	
	&::before, &::after {
		animation: shade .5*$t ease-in-out calc((var(--sh) - var(--py))*#{$t}) infinite alternate;
		content: ''
	}
}

@keyframes shade { to { filter: brightness(.5) } }

.main {
	&::before, &::after {
		--over: linear-gradient(#fff, #000), ;
		padding: calc(var(--sf, 1)*#{$ro});
		border-radius: 50%;
		transform: 
			rotateY(calc(-90deg))
			scalez(var(--sgn-k)) 
			translatez(calc(.5*var(--sf, 1)*#{$w}))
	}
}

audio {
	--hl: 0;
	position: fixed;
	top: 100vh; left: 50%;
	transform: translate(-50%, -100%);
	opacity: calc((1 + 3*var(--hl))*.25);
	filter: invert(1) sepia(1) hue-rotate(180deg);
	
	&:focus, &:hover {
		--hl: 1;
		outline: none
	}
}
              
            
!

JS

              
                
              
            
!
999px

Console