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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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 vb_u = 500;
- var vb_w = (Math.ceil(m*Math.PI) + 1)*vb_u;
- var vb_h = 3*vb_u;
- var vb_x = -.5*vb_u, vb_y = -.5*vb_h;
- var ax_x0 = .5*vb_x;
- var ax_y = .5*(vb_y - vb_u);
- 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 = .03*vb_w;
- var sw = .002*vb_w;
- var p = 180, np = p*m;
- var gmax = Math.round(m*Math.PI*vb_u);
- var vl = [], 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], #h { stroke-width: #{sw} }
		| #f { 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))
	
	linearGradient#g
		stop(stop-color='#b53' offset=((nval + .5)/m).toFixed(3))
		stop(stop-color='#ccc' offset=0)
	
	- for(var i = 1; i <= 2*m; i++) {
		- vl.push(`M${Math.round(i*vb_u*.5*Math.PI)}${-vb_u}V${vb_u}`)
	- }
	path#l(d=`${vl.join(' ')}M0${-vb_u}H${gmax}M0 ${vb_u}H${gmax}`)
	
	g#c
		path(d=`M${ax_x0} 0h${vb_w + vb_x}`)
		path(d=`M0 ${-ax_y}V${ax_y}`)
		text(x=vb_w + 1.5*vb_x y=fs): tspan k
		text(x=.25*fs y=ax_y) 1-|cos(<tspan>k</tspan>)|
	
	rect#h(y=-vb_u width=Math.round((nval + .5)*Math.PI*vb_u) height=vb_u)
	
	- for(var i = 0; i <= np; i++) {
		- var x = Math.round(i*Math.PI*vb_u/p);
		- var y = Math.abs(Math.round(vb_u*Math.cos(i*Math.PI/p))) - vb_u;
		- vg.push([x, y])
	- }
	path#f(d=`M${vg.join(' ')}`)
	
	- for(var i = 0; i <= 2*m; i++) {
		- var x = Math.round(i*.5*Math.PI*vb_u);
		- if((i%2)) {
			circle(r=pr cx=x?x:null cy=-vb_u)
		- }
		circle(r=i%2 ? pr1 : pr cx=x?x:null)
	- }
	
	text(x=Math.round(.5*Math.PI*vb_u - .5*fs) y=fs) 90°
	text(x=Math.round(1.5*Math.PI*vb_u - .75*fs) y=fs) 270°
	text(x=Math.round(2.5*Math.PI*vb_u - .75*fs) y=fs) 450°
	text(x=Math.round(3.5*Math.PI*vb_u - 1.25*fs) y=fs) 630°
	
	text(x=-fs y=fs) 0°
	text(x=Math.round(Math.PI*vb_u - .75*fs) y=fs) 180°
	text(x=Math.round(2*Math.PI*vb_u - .75*fs) y=fs) 360°
	text(x=Math.round(3*Math.PI*vb_u - .75*fs) y=fs) 540°
	
	text(x=-.75*fs y=.35*fs - vb_u) 1

form
	section
		input#n(type='range' min=nmin max=nmax value=nval)
		label(for='n') n:
			output(for='n') #{nval}
            
          
!
            
              $theme-dark: #262626;
$theme-light: invert($theme-dark);
$theme-orange: #f90;
$thrme-tomato: #b53;

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

[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='h'] {
	stroke: $theme-orange;
	stroke-dasharray: 1%;
	fill: url(#p)
}

[id='f'] {
	stroke: url(#g);
	fill: none;
}

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

form {
	display: flex;
	flex-direction: column;
	align-items: center;
	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 _N = document.getElementById('n'), 
			_O = _N.nextElementSibling.querySelector('output'), 
			_H = document.getElementById('h'), 
			U = +_H.getAttribute('height'), 
			_GS = document.querySelector('#g stop:first-child'), 
			MIN = +_N.min, MAX = +_N.max, M = MAX + .5;

let n = _N.value;

function update() {
	if(n != +_N.value) {
		_O.value = n = +_N.value;
		
		let num = n + .5;
		
		_H.setAttribute('width', Math.round(num*Math.PI*U));
		_GS.setAttribute('offset', (num/M).toFixed(3));
	}
};

addEventListener('input', update, false);
addEventListener('change', update, false);
            
          
!
999px
Loading ..................

Console