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

Packages

Add Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              - var n = 5;
- var max = 45, val = -2*max/3;

body.paused(style=`--max: ${max}; --val: ${val}`)
	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
	
	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`)
            
          
!
            
              $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;
	flex-direction: column;
	overflow: hidden;
	position: relative;
	min-height: 100vh;
	background: #333;
}

.scene {
	flex: 1;
	position: relative;
	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: $fg;
		-webkit-clip-path: var(--poly);
						clip-path: var(--poly);
	}
}

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

.lat {
	--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});
	margin-top: calc(-1*(var(--rc) + var(--ri)));
	transform-origin: 50% calc(50% + var(--ri));
	transform: 
		rotatey(var(--ay)) 
		translate3d(0, var(--y, 0), var(--z, 0));
	
	@for $i from 0 to 2*$n {
		&:nth-child(#{2*$n}n + #{$i + 1}) { --idx: #{$i} }
	}
}

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

@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($c, .5)
	}
}

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

form {
	--pos: calc(.5*(#{$thumb-d} + (var(--val) + var(--max))/var(--max)*(100% - #{$thumb-d})));
	margin: 0 calc(50vw - #{.5*$track-w}) 0;
	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 }
}
            
          
!
            
              const _BODY = document.body, 
			_PLAY = document.getElementById('play'), 
			_FVAL = document.getElementById('fx');

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

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

Console