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

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

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 nmax = 3, nmin = 0, nval = 2;
- var m = nmax + .5;
- var amax = 4, amin = 1/amax, aval = 1;
- var vb_u = 1500;
- var vb_h = 2*vb_u, vb_w = 2*vb_h;
- var vb_x = -.5*(vb_w - vb_u);
- var vb_y = -.5*(vb_h + vb_u);
- var ax0 = .25*vb_u, ax1 = vb_u + ax0;
- var k = .05, pr = Math.round(.1*k*vb_w);
- var ps = 2*pr, na = Math.round(.25*pr);
- var pr1 = Math.round(.65*pr), fs = .025*vb_w;
- var sw = .002*vb_w;
- var p = 180, np = p*m;
- var vg = [];

svg(viewBox=[vb_x, vb_y, vb_w, vb_h].join(' '))
	style
		| svg {
		| 	font: #{fs}px consolas, monaco, monospace;
		| 	letter-spacing: #{-.1*fs}px
		| }
		| [d], [r], #r { stroke-width: #{sw} }
		| [d][id] { stroke-width: #{2*sw} }
	marker#e(markerWidth=na markerHeight=na 
						viewBox='0 -4 8 8' 
						orient='auto')
		path(d='M8 0 0-4V4')
	
	pattern#p(width=ps height=ps patternUnits='userSpaceOnUse' patternTransform='rotate(60)')
		rect(width=ps height=Math.round(na))
	
	clipPath#o
		rect#r(y=-vb_u width=vb_u height=vb_u)
	
	defs
		g#u
			g#c
				path(d=`M${-ax0} 0H${ax1}`)
				path(d=`M0 ${ax0}V${-ax1}`)
				text(x=ax1 y=fs): tspan k

		g#v
			text(x=-.75*fs y=.9*fs) 0
			text(x=-.75*fs y=.35*fs - vb_u) 1
			text(x=vb_u - .25*fs y=.9*fs) 1
	
	g(transform=`translate(${-.875*vb_u})`)
		use(xlink:href='#u')
		text(x=.25*fs y=-ax1) (1-<tspan>k</tspan>)<tspan class='sup' dy=#{-.5*fs}>a</tspan>
		
		- for(var i = 0; i <= p; i++) {
			- var x = Math.round(i*vb_u/p);
			- var y = -Math.abs(Math.round(Math.pow(1 - i/p, 1)*vb_u));
			- vg.push([x, y])
		- }
		path#g(d=`M${vg.join(' ')}`)
		
		circle(r=pr1)
		circle(r=pr cx=vb_u)
		circle(r=pr cy=-vb_u)
		
		use(xlink:href='#v')
	
	g(transform=`translate(${.875*vb_u})`)
		use(xlink:href='#u')
		text(x=.25*fs y=-ax1) 1-|(1-<tspan>k</tspan>)<tspan class='sup' dy=#{-.5*fs}>a</tspan><tspan dy=#{.5*fs}>·</tspan>cos(<tspan>k</tspan><tspan class='sup' dy=#{-.5*fs}>b</tspan><tspan dy=#{.5*fs}>·</tspan>(n + ½)·180°)|
		
		use(xlink:href='#r')
		
		- vg = [];
		- for(var i = 0; i <= np; i++) {
			- var x = Math.round(i*2*vb_u/p);
			- var y = Math.abs(Math.round(Math.pow(1 - i/np, 1)*vb_u*Math.cos(Math.pow(i/np, 1)*m*Math.PI))) - vb_u;
			- vg.push([x, y])
		- }
		path#f(d=`M${vg.join(' ')}`)

		circle(r=pr)
		circle(r=pr1 cx=vb_u)
		circle(r=pr1 cy=-vb_u)
		circle(r=pr cx=vb_u cy=-vb_u)
		
		use(xlink:href='#v')

form
	section
		input#a(type='range' min=amin max=amax value=aval step=amin)
		label(for='a') a:
			output(for='a') #{aval}
	section
		input#n(type='range' min=nmin max=nmax value=nval)
		label(for='n') n:
			output(for='n') #{nval}
	section
		input#b(type='range' min=1 max=amax value=aval step=amin)
		label(for='b') b:
			output(for='b') #{aval}
            
          
!
            
              $theme-dark: #262626;
$theme-light: invert($theme-dark);
$theme-orange: #f90;
$theme-tomato: #b53;
$theme-purple: #95a;

$track-w: 12.5em;
$track-h: .25em;
$thumb-d: 1.5em;

@mixin track() {
	box-sizing: border-box;
	border: none;
	width: $track-w; height: $track-h;
	border-radius: $track-h;
	background: $theme-light;
}

@mixin thumb() {
	box-sizing: border-box;
	border: solid .125*$thumb-d $theme-dark;
	width: $thumb-d; height: $thumb-d;
	border-radius: 50%;
	background: currentcolor;
}

* { color: inherit; font: inherit }

body {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-between;
	margin: 0;
	height: 100vh;
	font: 1.25em/ 2 consolas, monaco, monospace
}

svg {
	flex: 1;
	width: 100%
}

tspan { font-style: italic }

.sup { font-size: .75em }

[id='e'] {
	stroke: transparent;
	fill: $theme-dark
}

[id='p'] { fill: $theme-orange }

[id='l'] { stroke: $theme-light }

[id='c'] [d] {
	stroke: $theme-dark;
	marker-end: url(#e)
}

[id='r'] {
	stroke: $theme-orange;
	stroke-dasharray: 1%;
	fill: url(#p)
}

[id='f'] {
	stroke: $theme-tomato;
	fill: none;
	clip-path: url(#o)
}

[id='g'] {
	stroke: $theme-purple;
	fill: none
}

[r] {
	stroke: $theme-dark;
	fill: $theme-orange
}

form {
	display: flex;
	align-items: center;
	justify-content: space-around;
	padding: .75em 0 0;
	width: 100%;
	background: $theme-dark;
	color: $theme-light;
}

input, label {
	display: block;
	margin: .25em auto;
	text-align: center;
}

input {
	&, &::-webkit-slider-thumb {
		-webkit-appearance: none;
	}
	
	margin: 0;
	padding: 0;
	width: $track-w; height: $thumb-d;
	background: transparent;
	transition: color .3s;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track {
		@include track
	}
	&::-moz-range-track { @include track }
	&::-ms-track { @include track }
	
	&::-webkit-slider-thumb {
		margin-top: .5*($track-h - $thumb-d);
		@include thumb
	}
	&::-moz-range-thumb { @include thumb }
	&::-ms-thumb {
		margin-top: 0;
		@include thumb
	}
	
	&::-ms-tooltip { display: none }
	
	&:focus {
		outline: solid 1px transparent;
		color: $theme-orange;
		
		+ label output { color: $theme-orange }
	}
}
            
          
!
            
              const R = {}, 
			_F = document.getElementById('f'), 
			_G = document.getElementById('g'), 
			U = +document.getElementById('r').getAttribute('width');

let pts = _F.getAttribute('d').replace(/(M|L)\s?/g, '')
						.split(/\s|\,/).map(c => +c), 
		pts1 = _G.getAttribute('d').replace(/(M|L)\s?/g, '')
						.split(/\s|\,/).map(c => +c), 
		np = pts.length, np1 = .5*pts1.length, m;

function update(e) {
	if(e) {
		let _t = e.target, id = _t.id;
	
		R[id]._o.value = _t.value.replace('0.', '.');
	}
	
	_F.setAttribute('d', `M${pts.map((c, j) => c.map((k, i) => i ? 
    Math.abs(Math.round(Math.pow(1 - j/np, +R.a._e.value)*U*Math.cos(Math.pow(j/np, +R.b._e.value)*m*Math.PI))) - U : 
    Math.round(k/(2*+R.n._e.value + 1)))).join(' ')}`);
	
	if(!e || e.target === R.a._e) {
		_G.setAttribute('d', `M${pts1.map((c, j) => c.map((k, i) => i ? -Math.pow(1 - j/np1, +R.a._e.value)*U : k)).join(' ')} ${U} 0`);
	}
};

(function init() {
	let _r = Array.from(document.querySelectorAll('[type=range]'));
	
	_r.forEach(c => {
		R[c.id] = {
			_e: c, 
			_o: c.nextElementSibling.querySelector('output'), 
			v: c.value
		};
	});
	
	pts = pts.reduce((a, c, i) => i%2 ? a.concat([[pts[i - 1], c]]) : a, []);
	pts = pts.map(c => c.map((k, i) => i ? k + U : k));
	pts1 = pts1.reduce((a, c, i) => i%2 ? a.concat([[pts1[i - 1], c]]) : a, []);
	pts1 = pts1.map(c => c.map((k, i) => i ? k/U : k));
	m = 2*+R.n._e.max + 1;
	update();
})();

addEventListener('input', update, false);
addEventListener('change', update, 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