cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm 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. We'll also process your JavaScript with Babel.

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

Code Indentation

     

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.

            
              - var n = 12;

section.argvis
	.hue-strip
		.marks(style=`--n: ${n}`)
			- for(var i = 0; i <= n; i++)
				code.mark(style=`--k: ${i/n}`) #{i*360/n}
	.hue-stops
	.hue-range
	.hue-start start
section.slider
	ul
		li
			pre
				span.token--func linear-gradient
				span.token--punc (
				span.token--args
					span.token--arg
						span.token--func get-stops
						span.token--punc (
							span.token--arg
								span.token--num.hue-start 240
							span.token--punc ,
							span.token--arg
								span.token--num.hue-range 60
							span.token--punc ,
							span.token--arg
								span.token--num.hue-stops 4
						span.token--punc )
				span.token--punc )
			.result
		li
			pre
				span.token--func radial-gradient
				span.token--punc (
				span.token--args
					span.token--arg
						span.token--func get-stops
						span.token--punc (
							span.token--arg
								span.token--num.hue-start 150
							span.token--punc ,
							span.token--arg
								span.token--num.hue-range -120
							span.token--punc ,
							span.token--arg
								span.token--num.hue-stops 10
						span.token--punc )
				span.token--punc )
			.result
		li
			pre
				span.token--func conic-gradient
				span.token--punc (
				span.token--args
					span.token--arg
						span.token--func get-stops
						span.token--punc (
							span.token--arg
								span.token--num.hue-start 30
							span.token--punc ,
							span.token--arg
								span.token--num.hue-range 120
							span.token--punc ,
							span.token--arg
								span.token--num.hue-stops 7
						span.token--punc )
				span.token--punc )
			.result
		li
			pre
				span.token--func linear-gradient
				span.token--punc (
				span.token--args
					span.token--arg
						span.token--val
							span.token--num -45
							span.token--uni deg
					span.token--punc ,
					span.token--arg
						span.token--func get-stops
						span.token--punc (
							span.token--arg
								span.token--num.hue-start 30
							span.token--punc ,
							span.token--arg
								span.token--num.hue-range -210
							span.token--punc ,
							span.token--arg
								span.token--num.hue-stops 5
						span.token--punc )
				span.token--punc )
			.result
		li
			pre
				span.token--func radial-gradient
				span.token--punc (
				span.token--args
					span.token--arg
						span.token--key circle at
						| 
						span.token--val
							span.token--num 65
							span.token--uni %
						| 
						span.token--val
							span.token--num 4
							span.token--uni em
					span.token--punc ,
					span.token--arg
						span.token--func get-stops
						span.token--punc (
							span.token--arg
								span.token--num.hue-start 270
							span.token--punc ,
							span.token--arg
								span.token--num.hue-range 180
							span.token--punc ,
							span.token--arg
								span.token--num.hue-stops 10
						span.token--punc )
				span.token--punc )
			.result
		li
			pre
				span.token--func conic-gradient
				span.token--punc (
				span.token--args
					span.token--arg
						span.token--key from
						| 
						span.token--val
							span.token--num 45
							span.token--uni deg
					span.token--punc ,
					span.token--arg
						span.token--func get-stops
						span.token--punc (
							span.token--arg
								span.token--num.hue-start 75
							span.token--punc ,
							span.token--arg
								span.token--num.hue-range -180
							span.token--punc ,
							span.token--arg
								span.token--num.hue-stops 13
						span.token--punc )
				span.token--punc )
			.result
	button#prev(style='--dir: -1') previous
	button#next(style='--dir: +1') next
            
          
!
            
              $theme-dark: #222;
$theme-light: invert($theme-dark);
$strip-h: 3em;

@function get-stops($hue-start: 180, $hue-range: -180, $num-stops: 9) {
  $list: ();
  $unit: $hue-range/($num-stops - 1);
	
	@for $i from 0 to $num-stops {
		$hue-curr: $hue-start + $i*$unit;
		$list: $list, hsl($hue-curr, 85%, 57%)
	}
	
  @return $list
}

@mixin visualise-arg($hue-start: 180, $hue-range: -180, $num-stops: 9) {
	$max: 360
}

* {
	margin: 0;
	padding: 0;
	font: inherit
}

body {
	--sel: 0;
	--start: 240;
	--range: 60;
	--end: 300;
	--stops: 4;
	display: flex;
	flex-direction: column;
	align-items: center;
	overflow: hidden;
	height: 100vh;
	font: 1em/ 1.5em trebuchet ms, verdana, sans-serif
}

pre, code {
	font-family: consolas, monaco, monospace
}

pre {
	padding: .5em;
	background: $theme-dark;
	color: $theme-light;
	font-size: calc(.75em + 1.25vw);
	text-align: center;
	
	@media (max-width: 690px) { font-size: calc(.75em + 1vw) }
	
	@media (max-width: 590px) { font-size: 1em }
}

ul {
	--nex: 6;
	display: flex;
	width: calc(var(--nex)*100vw); height: 100%;
	transform: translate(calc(var(--sel)*-100vw));
}

li {
	display: flex;
	flex-direction: column-reverse;
	overflow-x: hidden;
	width: 100vw; height: inherit;
	list-style: none;
}

button {
	overflow: hidden;
	position: absolute;
	top: 50%;
	border: none;
	width: $strip-h; height: calc(100% - #{2*$strip-h});
	transform: translateY(-50%);
	background: none;
	text-indent: -10em;
	cursor: pointer;
	
	&:hover, &:focus {
		outline: none;
		background: rgba($theme-dark, .35)
	}
	
	&:after {
		position: absolute;
		top: 50%; left: 50%;
		transform: translate(-50%, -50%) var(--flip, scalex(1));
		color: $theme-light;
		font-size: 4em;
		text-align: center;
		text-indent: 0;
		text-shadow: 0 1px 2px $theme-dark;
		content: '➧'
	}
}

.argvis {
	--strip-w: 92vw;
	position: relative;
	padding-bottom: $strip-h;
	width: var(--strip-w);
	
	@media (max-width: 350px) {
		--strip-w: 80vw;
	}
}

div.hue-strip {
	display: flex;
	flex-direction: column;
	
	&:before {
		display: block;
		height: $strip-h;
		background: linear-gradient(90deg, get-stops(0, 360, 13));
		content: ''
	}
	
	~ * { position: absolute }
}

.marks {
	position: relative;
	height: 3em;
	font-weight: 900;
}

.mark {
	position: absolute;
	top: 50%; left: calc(var(--k)*100%);
	transform: translate(-50%, -50%);
	
	&:before {
		position: absolute;
		bottom: calc(100% + 3px); left: calc(50% - 1px);
		width: 2px; height: .5em;
		background: $theme-dark;
		content: ''
	}
	
	@media (max-width: 500px) {
		&:nth-child(2n) { display: none }
	}
	
	@media (max-width: 250px) {
		&:nth-child(2n) { display: block }
		
		&:not(:nth-child(3n + 1)) { display: none }
	}
}

div.hue-stops {
	overflow: hidden;
	top: 0;
	width: inherit; height: $strip-h;
	filter: drop-shadow(1px 1px $theme-light);
	
	&:before, &:after {
		position: absolute;
		top: 0;
		width: calc(var(--range)/360*100% + 2px); height: inherit;
		transform: translate(calc(var(--pos, var(--start))/360*var(--strip-w) - 1px));
		background: linear-gradient(90deg, $theme-dark 2px, transparent 0) 
			0 50%/ calc((100% - 2px)/(var(--stops) - 1)) 35% repeat-x;
		content: '';
		
		body.negative & { --pos: var(--end) }
	}
	
	&:after {
		transform: translate(calc(var(--pos, var(--end))/360*var(--strip-w) + 1px - 100%));
		
		body.negative & { --pos: var(--start) }
		
		body.single & { opacity: 0 }
	}
}

div.hue-range {
	left: 0; bottom: .25em;
	overflow-x: hidden;
	width: calc(100% + 1px); height: 3.5em;
	
	&:before, &:after {
		box-sizing: border-box;
		position: absolute;
		top: 0; left: 0;
		border: solid 0 $theme-dark;
		border-width: 0 2px 2px 2px;
		width: calc(var(--range)/360*100% + 2px); height: .5em;
		transform: translate(calc(var(--pos, var(--start))/360*var(--strip-w) - 1px));
		line-height: 2;
		content: 'range';
		
		body.negative & { --pos: var(--end) }
		
		body.single & { text-align: center }
	}
	
	&:after {
		transform: translate(calc(var(--pos, var(--end))/360*var(--strip-w) + 1px - 100%));
		text-align: right;
		
		body.negative & { --pos: var(--start) }
		
		body.single & { opacity: 0 }
	}
}

div.hue-start {
	bottom: 0;
	transform: translate(calc(var(--pos, var(--start))/360*var(--strip-w) - 1px - 50%));
	text-align: center;
	
	&:before {
		position: absolute;
		bottom: calc(100% - .25em); left: 50%;
		transform: translate(-50%);
		content: '▲'
	}
}

.slider {
	flex: 1;
	position: relative;
	width: 100vw;
}

.result {
	flex: 1;
	padding: 1em;
	background: content-box;
	
	li:nth-child(1) & {
		background-image: linear-gradient(get-stops(240, 60, 4))
	}
	
	li:nth-child(2) & {
		background-image: radial-gradient(get-stops(150,-120,10))
	}
	
	li:nth-child(3) & {
		background-image: conic-gradient(get-stops(30,120,5))
	}
	
	li:nth-child(4) & {
		background-image: linear-gradient(-45deg, get-stops(30, -210, 7))
	}
	
	li:nth-child(5) & {
		background-image: radial-gradient(circle at 65% 4em, get-stops(270,180,10))

	}
	
	li:nth-child(6) & {
		background-image: conic-gradient(from 45deg,get-stops(75,-180,13))
	}
}

[id='prev']:after { --flip: scalex(-1) }

[id='next'] { right: 0 }

.no-prev [id='prev'], .no-next [id='next'] { display: none }

.token {
	&--num { color: #f8f087 }
	
	&--unit { color: #f39dd4 }
	
	&--keyw { color: #b7e3c0 }
	
	&--func { color: #b8d0dd }
	
	&--arg &--func { color: #d1ffa1 }
	
	&--punc + &--arg:before { content: ' ' }
}

span[class*='hue-'] {
	position: relative;
	cursor: pointer;
	
	&:before {
		position: absolute;
		bottom: calc(100% + .25em); left: 50%;
		padding: 0 .5em;
		border-radius: 5px;
		transform-origin: 50% 100%;
		transform: translate(-50%) scale(0);
		background: #f90;
		color: #fff;
		content: ''
	}
	
	&:hover:before { transform: translate(-50%) scale(1) }
}

span.hue-start:before { content: 'start' }

span.hue-range:before { content: 'range' }

span.hue-stops:before { content: 'stops' }
            
          
!
            
              const _LIST = document.querySelector('ul'), 
			DATA = [..._LIST.querySelectorAll('pre')]
								 .map(c => c.textContent.match(/(\-?\d+\,?){3}/)[0]
								 .split(',').map(c => +c)), 
			N = DATA.length;

let sel = 0;

document.body.classList.add('single');
document.body.classList.add('no-prev');

function shift(dir) {
	if(!sel) document.body.classList.remove('no-prev');
	if(sel === N - 1) document.body.classList.remove('no-next');

	sel += dir;
	c = DATA[sel]

	document.body.style.setProperty('--sel', sel);
	document.body.style.setProperty('--start', c[0]);
	document.body.style.setProperty('--range', Math.abs(c[1]));
	document.body.style.setProperty('--stops', c[2]);
	document.body.style.setProperty('--end', (c[0] + c[1] + 360)%360);

	if(c[0] + c[1] < 360 && c[0] + c[1] > 0) 
		document.body.classList.add('single')
	else document.body.classList.remove('single')

	if(c[1] < 0) 
		document.body.classList.add('negative')
	else document.body.classList.remove('negative')

	if(!sel) document.body.classList.add('no-prev');
	if(sel === N - 1) document.body.classList.add('no-next');
};

addEventListener('click', e => {
	let _t = e.target;
	
	if(_t.tagName.toLowerCase() === 'button')
		shift(+_t.style.getPropertyValue('--dir'))
}, false);

addEventListener('keyup', e => {	
	if([34, 39, 40].indexOf(e.keyCode) > -1) {
		if(sel < N - 1) shift(1);
		return
	}
	
	if([33, 37, 38].indexOf(e.keyCode) > -1) 
		if(sel) shift(-1)
}, false);
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console