Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                - var data = [
- 	'10 lateral antiprism faces (all triangles) pointing up', 
- 	'10 lateral antiprism faces (all triangles) pointing down', 
- 	'10 lateral rotunda faces (alternating triangles and pentagons) pointing up', 
- 	'5 lateral rotunda faces (all triangles) pointing down'
- ];
- var m = data.length;
- var n = 5;
- var max = 45, val = -max/3;

body.paused(style=`--max: ${max}; --val: ${val}` data-step='0')
	nav
		button#prev(data-dir='-1') Previous
		p#inf
			- for(var i = 0; i <m; i++){
				span.step(data-step=i class=i ? null : 'curr') #{data[i]}
			- }
		button#next(data-dir='1') Next

	section.scene
		.rot
			.s3d
				- for(var j = 0; j < 4*n; j++)
					.s2d.mid.lat.s3gon(class=j < 2*n ? 'dir' : 'rev')
				- for(var j = 0; j < n; j++)
					.s2d.cup.lat.s3gon.dir
					.s2d.cup.lat.s5gon.dir
				- for(var j = 0; j < n; j++)
					.s2d.cup.lat.s3gon.rev
				.s2d.mid.base(class=`s${2*n}gon`)
				.s2d.cup.base(class=`s${n}gon`)

	form
		input#fx(type='range' min=-max max=max value=val)
		label(for='fx')
			span.token--func rotatex
			span.token--punc (
			span.token--arg.token--ang
				span.token--num
				span.token--unit deg
			span.token--punc )
		input#play(type='checkbox')
		label(for='play') Playing
              
            
!

CSS

              
                $bg: #262626;
$fg: #e7e7e7;
$hl: #f44336;
$fc: #8bc34a;
$gc: #4caf50;

$gap: .5em;
$num: 2.5em;

$thumb-d: 1.25em;
$track-w: 9em;
$track-h: .25em;
$input-h: $thumb-d + 2*$track-h;

$check-d: 1.522em;
$lc: #8bc34a;
$dc: #f44336;

// GEOMETRY
$l: 15vmin; // edge length
$n: 5; // base face type (3 = triangular)
// lateral face heights
$h3gon: poly-h($l, 3);
$h5gon: poly-h($l, 5);
// pentagonal diagonal
$d5gon: 2*$l*sin(.5*vx-ang(5));
// base planes
$ba-b0: bc-ang($n); // top base central angle
$ri-b0: in-rad($l, $ba-b0); // top base inradius
$rc-b0: cc-rad($l, $ba-b0); // top base circumradius
$ba-b1: bc-ang(2*$n); // bottom base central angle
$ri-b1: in-rad($l, $ba-b1); // bottom base inradius
$rc-b1: cc-rad($l, $ba-b1); // bottom base circumradius
// mid plane
$rc-m: cc-rad($d5gon, $ba-b0);
// lateral face angles with the vertical
$ax3-mid: to-deg(asin(($rc-b1 - $ri-b1)/$h3gon));
$ax3-cup-dir: to-deg(asin(($ri-b1 - $rc-m)/$h3gon));
$ax3-cup-rev: to-deg(asin(($ri-b0 - $rc-m)/$h3gon));
$ax5: to-deg(asin(($ri-b1 - $rc-b0)/$h5gon));
// heights
$h-mid: cath1($h3gon, $rc-b1 - $ri-b1);
$h-cup: cath1($h5gon, $ri-b1 - $rc-b0);
$h: $h-mid + $h-cup;

// VISUAL
$clst: #ff8a00 #da1b60 #9c27b0;
$flst: 3 $n 2*$n;
$llen: length($flst);

$t: 15s;

@mixin track() {
	width: 100%; height: $track-h;
	border-radius: $track-h;
	background-color: $fg;
	background: radial-gradient(circle at var(--pos) 50%, transparent .5*$thumb-d, $fg 0)
}

@mixin thumb() {
	width: $thumb-d; height: $thumb-d;
	border-radius: 50%;
	transform: scale(calc(1 - var(--nothl)*.39));
	background: $hl;
	filter: grayScale(var(--nothl)) brightness(calc(1 + 1.5*var(--nothl)));
	transition: .3s
}

@mixin poly($n, $ba) {
	--rc: #{cc-rad($l, $ba)};
	--ri: #{in-rad($l, $ba)};
	--poly: #{polygon(get-poly-points($n))};
	
	&:before { --poly: #{polygon(get-poly-points($n, $bw: 2px))} }
}

* { margin: 0; font: inherit }

body {
	--ax: calc(var(--val)*1deg);
	display: flex;
	align-items: center;
	flex-direction: column-reverse;
	overflow: hidden;
	position: relative;
	min-height: 100vh;
	background: $bg;
	color: $fg;
}

nav, form {
	font: 1.25em consolas, monaco, ubuntu mono, monospace
}

nav {
	box-sizing: border-box;
	display: grid;
	grid-template-columns: max-content 1fr max-content;
	grid-gap: $gap;
	place-items: center;
	padding: $gap;
	width: 100%;
}

[id='inf'] { display: contents }

.step {
	position: relative;
	border: solid .5*$gap transparent;
	border-radius: 5px;
	background: #03a9f4;
	color: $bg;
	
	&:not(.curr) { display: none }
}

button {
	--hl: 0;
	--nothl: calc(1 - var(--hl));
	--notk: calc(1 - var(--k));
	--sgnk: calc(1 - 2*var(--k));
	overflow: hidden;
	position: relative;
	outline: solid 0 RGBA(0, 0, 0, calc(var(--hl)*var(--nothl)));
	border: solid 3px RGBA(red($fc), green($fc), blue($fc), var(--i));
	padding: $gap;
	width: 2em;
	border-radius: 5px;
	background: $gc;
	color: $bg;
	text-indent: -100vw;
	filter: contrast(9) Grayscale(var(--nothl));
	cursor: pointer;
	
	&:before, &:after {
		--noti: calc(1 - var(--i));
		--sgni: calc(1 - 2*var(--i));
		position: absolute;
		top: calc(50% - #{.5*$track-h}); left: 15%;
		width: 70%; height: $track-h;
		border-radius: .5*$track-h;
		transform-origin: calc(var(--k)*100%) 50%;
		transform: rotate(calc(var(--sgnk)*var(--sgni)*30deg));
		background: $bg;
		filter: blur(2px);
		content: ''
	}
	
	&:before { --i: 0 }
	&:after { --i: 1 }
	
	&:hover, &:focus { --hl: 1 }
}

[id='prev'] { --k: 0 }
[id='next'] { --k: 1 }

.scene {
	flex: 1;
	perspective: 25em
}

div {
	position: absolute;
	transform-style: preserve-3d
}

.rot {
	top: 50%; left: 50%;
	transform: rotatex(var(--ax))
}

.s3d {
	
	transform: rotatey(0turn);
	animation: rot $t linear infinite;
	
	.paused & { animation-play-state: paused }
}

@keyframes rot { 0% { transform: rotatey(1turn) } }

.s2d {
	--noti: calc(1 - var(--i));
	--sgni: calc(2*var(--i) - 1);
	--notk: calc(1 - var(--k));
	--notp: calc(1 - var(--p));
	--nor: calc((1 - var(--k))*(1 - var(--i)));
	--xor: calc((var(--k) - var(--i))*(var(--k) - var(--i)));
	--and: calc(var(--i)*var(--k));
	--nand: calc(1 - var(--and));
	margin: calc(-1*var(--rc));
	padding: var(--rc);
	-webkit-clip-path: var(--poly);
					clip-path: var(--poly);
	
	&:before, &:after {
		position: absolute;
		top: 0; right: 0; bottom: 0; left: 0;
		content: ''
	}
	
	&:before {
		background: currentcolor;
		-webkit-clip-path: var(--poly);
						clip-path: var(--poly);
	}
}

.mid { --i: 0 }
.cup { --i: 1 }

.lat {
	--vis: 0;
	--j: calc((1 + var(--and))*var(--idx) + .5*var(--nor));
	--ay: calc(var(--j)*#{$ba-b1});
	--y: calc(var(--nor)*#{.5*$h} + 
						var(--xor)*#{.5*$h - $h-mid} - 
						var(--and)*#{.5*$h});
	--z: calc(var(--and)*#{$ri-b0} + var(--nand)*#{$ri-b1});
	--ax: calc(var(--notp)*(var(--noti)*#{-$ax3-mid} + 
													var(--i)*(var(--notk)*#{$ax3-cup-dir} + 
																		var(--k)*#{$ax3-cup-rev})) +
						 var(--p)*#{$ax5});
	margin-top: calc(-1*(var(--rc) + var(--ri)));
	transform-origin: 50% calc(50% + var(--ri));
	transform: 
		rotatey(var(--ay)) 
		translate3d(0, var(--y), var(--z)) 
		rotate(calc(var(--k)*.5turn)) 
		rotatex(var(--ax));
	
	@for $i from 0 to 2*$n {
		&:nth-child(#{2*$n}n + #{$i + 1}) { --idx: #{$i} }
	}

	&:after {
		display: grid;
		place-content: center;
		transform: rotate(calc(var(--k)*-.5turn));
		opacity: var(--vis);
		color: #000;
		counter-reset: idx var(--idx);
		content: counter(idx)
	}
	
	[data-step='0'] &:nth-child(-n + #{2*$n}), 
	[data-step='1'] &:nth-child(n + #{2*$n + 1}):nth-child(-n + #{4*$n}), 
	[data-step='2'] &:nth-child(n + #{4*$n + 1}):nth-child(-n + #{6*$n}), 
	[data-step='3'] &:nth-child(n + #{6*$n + 1}):nth-child(-n + #{8*$n}) { --vis: 1 }
}

.base {
	--vis: .65;
	transform: 
		rotatex(calc(var(--sgni)*90deg)) 
		translatez(.5*$h)
		rotate(calc(var(--noti)*#{.5*$ba-b1}));
	opacity: .5
}

@for $i from 0 to $llen {
	$m: nth($flst, $i + 1);
	
	.s#{$m}gon {
		@if $m < 2*$n { --p: #{$i} }
		@include poly($m, bc-ang($m));
		$c: nth($clst, $i + 1);
		background: RGBA(red($c), green($c), blue($c), var(--vis))
	}
}

.dir { --k: 0 }
.rev { --k: 1 }

form {
	--pos: calc(.5*(#{$thumb-d} + (var(--val) + var(--max))/var(--max)*(100% - #{$thumb-d})));
	padding: .5em;
	width: $track-w; height: 2*$input-h;
	background: rgba(#000, .5);
	color: $fg;
	font: 1em consolas, monaco, ubuntu mono, monospace
}

input, label {
	--hl: 0;
	--nothl: calc(1 - var(--hl))
}

input:focus, input:focus + label, 
[type='range']:hover, [type='checkbox'] + label:hover { --hl: 1 }

[type='range'] {
	&, &::-webkit-slider-thumb, 
	&::-webkit-slider-runnable-track {
		-webkit-appearance: none
	}
	
	display: block;
	width: 100%; height: $input-h;
	background: none;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track {
		@include track
	}
	
	&::-moz-range-track {
		@include track
	}
	
	&::-webkit-slider-thumb {
		margin-top: .5*($track-h - $thumb-d);
		@include thumb
	}
	
	&::-moz-slider-thumb {
		@include thumb
	}
	
	+ label {
		display: block;
		text-align: center;
		
	}
	
	&:focus { outline: solid 0 transparent }
}

.token {
	&--num {
		counter-reset: fx var(--val);
		
		&:after { content: counter(fx) }
	}
}

[type='checkbox'] {
	left: -100vmax;
	position: absolute;
	
	+ label {
		--check: 0;
		--notcheck: calc(1 - var(--check));
		overflow: hidden;
		position: absolute;
		top: $gap; left: $gap;
		border: solid $gap transparent;
		width: $check-d; height: $check-d;
		border-radius: 5px;
		background: inherit;
		text-indent: -100vw;
		cursor: pointer;
		
		&:before, &:after {
			$hue0: hue($lc);
			$sat0: saturation($lc);
			$lum0: lightness($lc);
			$hue1: hue($dc);
			$sat1: saturation($dc);
			$lum1: lightness($dc);
			
			--q: 0;
			--notq: calc(1 - var(--q));
			position: absolute;
			top: 0; right: 0; bottom: 0; left: 0;
			transform-origin: 100% 50%;
			transform: scalex(calc(1 - var(--notcheck)*.2));
			background: 
			hsl(calc(var(--notcheck)*#{$hue0} + var(--check)*#{$hue1}), 
					calc(var(--notcheck)*#{$sat0} + var(--check)*#{$sat1}), 
					calc(var(--notcheck)*#{$lum0} + var(--check)*#{$lum1}));
			--points: calc(var(--q)*var(--check)*65%) 0, 
								calc(var(--q)*var(--check)*65%) 100%,  
								calc(100% - var(--notq)*var(--check)*65%) calc(100% - var(--notcheck)*50%), 
								calc(100% - var(--notq)*var(--check)*65%) calc(var(--notcheck)*50%);
			-webkit-clip-path: polygon(var(--points));
							clip-path: polygon(var(--points));
			filter: grayScale(var(--nothl));
			transition: .3s;
			content: ''
		}
		
		&:after { --q: 1 }
	}
	
	&:checked + label { --check: 1 }
}
              
            
!

JS

              
                const _BODY = document.body, 
			_STEP = [...document.querySelectorAll('.step')], 
			_PLAY = document.getElementById('play'), 
			_FVAL = document.getElementById('fx'), 
			N = _STEP.length;

let curr = +_BODY.dataset.step;

addEventListener('click', e => {
	let _tg = e.target;
	
	if(_tg.tagName.toLowerCase() === 'button') {
		let dir = +_tg.dataset.dir;
		
		_STEP[curr].classList.remove('curr');
		curr = (curr + dir + N)%N;
		_STEP[curr].classList.add('curr');
		_BODY.dataset.step = curr
	}
}, false);

_PLAY.addEventListener('change', e => {
	_BODY.classList.toggle('paused')
}, false);

_FVAL.addEventListener('input', e => {
	_BODY.style.setProperty('--val', 1*_FVAL.value)
}, false);
              
            
!
999px

Console