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.

            
              <pre>&lt;svg viewBox='<span class='values--vb'><span id='vb0' data-inf='SVG canvas top left corner x coordinate'>-250</span> <span id='vb1' data-inf='SVG canvas top left corner y coordinate'>-250</span> <span id='vb2' data-inf='SVG canvas width'>500</span> <span id='vb3' data-inf='SVG canvas width'>500</span></span>'&gt;
	&lt;polygon points='<span class='values--pt'><span id='p0'>250,0</span> <span id='p1'>20,20</span> <span id='p2'>0,250</span> <span id='p3'>-20,20</span> <span id='p4'>-250,0</span> <span id='p5'>-20,-20</span> <span id='p6'>0,-250</span> <span id='p7'>20,-20</span></span>'/&gt;
&lt;/svg&gt;</pre>

<div class='container'>
	<svg viewBox='-320 -320 640 640'>
		<defs>
			<polygon id='star' points='250,0 20,20 0,250 -20,20 -250,0 -20,-20 0,-250 20,-20 '/>
			<circle id='pt' r='5'/>
			<rect id='lt' x='-32' y='-17' width='64' height='34' rx='5' ry='5'/>
		</defs>

		<g class='cs'>
			<path d='M0,-270 L0,315 L-10,300 L0,305 L10,300 L0,315z'/>
			<path d='M-270,0 L315,0 L300,-10 L305,0 L300,10 L315,0z'/>
		</g>

		<g class='guides'>
			<rect x='-250' y='-250' width='500' height='500'/>
			<line x1='-250' y1='-250' x2='-250' y2='-285'/>
			<line x1='250' y1='-250' x2='250' y2='-285'/>
			<line x1='-250' y1='-250' x2='-285' y2='-250'/>
			<line x1='-250' y1='250' x2='-285' y2='250'/>
		</g>

		<g id='topleft'>
			<circle cx='-250' cy='-250' r='4'/>
			<g class='label' id='l0' transform='translate(-210, -230)'>
				<use xlink:href='#lt'/>
				<text y='8'>-250</text>
			</g>
			<text y='8' transform='translate(-170, -230)'>,</text>
			<g class='label' id='l1' transform='translate(-130, -230)'>
				<use xlink:href='#lt'/>
				<text y='8'>-250</text>
			</g>
		</g>

		<g class='meas'>
			<path d='M-250,-280 
							 L-235,-270 L-240,-280 L-235,-290 
							 L-250,-280 L250,-280
							 L235,-270 L240,-280 L235,-290 
							 L250,-280z'/>
			<g class='label' id='l2' transform='translate(0, -303)'>
				<use xlink:href='#lt'/>
				<text y='8'>500</text>
			</g>
			<path d='M-280,-250 
							 L-270,-235 L-280,-240 L-290,-235 
							 L-280,-250 L-280,250
							 L-270,235 L-280,240 L-290,235 
							 L-280,250z'/>
			<g class='label' id='l3' transform='rotate(-90) translate(0, -303)'>
				<use xlink:href='#lt'/>
				<text y='8'>500</text>
			</g>
		</g>
	</svg>

	<svg class='adjustable' viewBox='-250 -250 500 500'>
		<use xlink:href='#star'/>
		<use xlink:href='#star'/>
		<g id='vertices'>
			<use id='v0' xlink:href='#pt' x='250' y='0'/>
			<use id='v1' xlink:href='#pt' x='20' y='20'/>
			<use id='v2' xlink:href='#pt' x='0' y='250'/>
			<use id='v3' xlink:href='#pt' x='-20' y='20'/>
			<use id='v4' xlink:href='#pt' x='-250' y='0'/>
			<use id='v5' xlink:href='#pt' x='-20' y='-20'/>
			<use id='v6' xlink:href='#pt' x='0' y='-250'/>
			<use id='v7' xlink:href='#pt' x='20' y='-20'/>
		</g>
	</svg>
</div>
            
          
!
            
              $code-bg: #222;
$code-c: #ddd;

$vb-hl: crimson;

$cs-c: #777;
$guides-c: #777;
$meas-c: #222;
$poly-c: #000;
$poly-bg: #d49b00;

pre {
	padding: .5em;
	background: $code-bg;
	color: $code-c;
	tab-size: 4;
	
	[class*=values] span {
		display: inline-block;
		margin: .125em 0;
		padding: .25em .125em;
		border-radius: 3px;
		vertical-align: middle;
		transition: .35s;
		cursor: pointer;
	}
}

.values {
	&--vb {
		.hl { background: $vb-hl; }
	}
	
	&--pt {
		@for $i from 0 to 8 {
			$c: hsl($i*45, 100%, 50%);
			
			span:nth-of-type(#{$i + 1}) {
				color: lighten($c, 25%);
			}
			
			.hl:nth-of-type(#{$i + 1}) {
				background: lighten($c, 25%);
				color: #000;
			}
			
			@at-root {
				use[id*='v']:nth-of-type(#{$i + 1}) {
					fill: $c;
					stroke: rgba(lighten($c, 10%), .16);
					opacity: .65;
				}
				use.hl[id*='v']:nth-of-type(#{$i + 1}) {
					fill: darken($c, 45%);
					stroke: rgba(lighten($c, 10%), .64);
					opacity: .99;
				}
			}
		}
	}
}

.container {
	position: relative;
	margin: 0 auto;
	min-width: 20em; min-height: 20em;
	width: 80vmin; height: 80vmin;
}

svg {
	overflow: hidden; // IE
	position: absolute;
}

.adjustable {
	$r: 25/32;
	
	top: 50%; left: 50%;
	width: $r*100%; height: $r*100%;
	transform: translate(-50%, -50%);
	pointer-events: none;
}

line, path {
	stroke-width: 1;
	vector-effect: non-scaling-stroke;
}

circle {
	vector-effect: non-scaling-stroke;
}

.cs path {
	fill: $cs-c;
	stroke: $cs-c;
}

.guides {
	fill: transparent;
	stroke: $guides-c;
	stroke-dasharray: 5;
}

.meas path {
	fill: $meas-c;
	stroke: $meas-c;
}

[id='topleft'] .hl {
	fill: $vb-hl;
}

text {
	font: 700 2em monospace;
	text-anchor: middle;
}

.label {
	use { fill: rgba($vb-hl, .01); }
	text { cursor: pointer; }
}

.hl {
	use { fill: $vb-hl; }
	text { fill: $code-c; }
}

.adjustable > use {
	&:nth-of-type(1) {
		stroke: rgba($poly-bg, .32);
		stroke-width: 20;
		stroke-miterlimit: 32;
	}

	&:nth-of-type(2) {
		stroke: $poly-c;
		opacity: .5;
		vector-effect: non-scaling-stroke;
	}
	
	fill: transparent;
}

[id='vertices'] { pointer-events: auto; }

use[id*='v'] {
	stroke-width: 20;
	cursor: pointer;
}

/* controls */

$theme-hl: #e18728;

$ctrl-bg: #262626;
$ctrl-ll: #aaa;
$ctrl-hl: $theme-hl;

$track-w: 13em;
$track-h: .25em;

$thumb-d: 1.25em;

@mixin track() {
	width: $track-w; height: $track-h;
	background: $ctrl-ll;
}

@mixin fill() {
	background: $ctrl-hl;
}

@mixin thumb() {
	border: none;
	width: $thumb-d; height: $thumb-d;
	border-radius: 50%;
	background: $ctrl-hl;
}

form {
	position: absolute;
	bottom: .25em; right: .25em;
	margin: .25em;
	padding: .5em;
	background: $ctrl-bg;
	color: $ctrl-ll;
	font: 1em/1.375em trebuchet ms, sans serif;
}

input[type='range'] {
	&, 
	&::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb {
		-webkit-appearance: none;
	}
	
	display: block;
	margin: 1em auto 0;
	padding: 0;
	width: $track-w; height: 2em;
	background: none;
	font-size: 1em;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track {
		@include track();
	}
	&::-moz-range-track {
		@include track();
	}
	&::-ms-track {
		border: none;
		@include track();
		color: transparent;
	}
	
	&::-moz-range-progress {
		height: $track-h;
		@include fill();
	}
	&::-ms-fill-lower {
		@include fill();
	}
	
	&::-webkit-slider-thumb {
		margin-top: ($track-h - $thumb-d)/2;
		@include thumb();
	}
	&::-moz-range-thumb {
		@include thumb();
	}
	&::-ms-thumb {
		@include thumb();
	}
	
	&::-ms-tooltip { display: none; }
	
	+ label {
		display: block;
		text-align: center;
	}
		
	&:focus { outline: none; }
}
            
          
!
            
              /* because me lazy */
Object.getOwnPropertyNames(Math).map(function(p) {
  window[p] = Math[p];
});

var svg = document.querySelector('.adjustable'), 
		star = document.getElementById('star'), 
		pt = document.getElementById('pt'), 
		vb_code = document.querySelectorAll('[id*=vb]'), 
		vb_svg = document.querySelectorAll('.label'), 
		vb_svg_in = [], 
		pt_code = document.querySelectorAll('[id*=p]'), 
		pt_svg = document.querySelectorAll('use[id*=v]'), 
		topleft = document.querySelector('#topleft circle'), 
		r_id = null, dir = -1, t = 0, 
		f = (20 - 10.8)/115, 
		paused = false, 
		val = 
			~~pt_code[0].textContent.split(',')[0], 
		val2 = 
			~~pt_code[1].textContent.split(',')[0];

for(var i = 0; i <4; i++) {
	vb_svg_in.push(vb_svg[i].querySelector('text'));
}

var hl = function(e) {
	var t = e.target, ts, idx;
	
	if(t.id) {
		if(t.id.indexOf('vb') === 0) {
			idx = t.id[2]*1;
			ts = vb_svg[idx];
						
			if(idx < 2 && topleft.classList) {
				topleft.classList.toggle('hl');
			}
		}
		if(t.id[0] === 'p') {
			idx = t.id[1]*1;
			ts = pt_svg[idx];
		}
		if(t.tagName.toLowerCase() === 'use' && 
			 t.id.indexOf('v') === 0) {
			idx = t.id[1]*1;
			ts = pt_code[idx];
		}
	}
	
	if(t.parentNode && t.parentNode.id && 
		 t.parentNode.id[0] === 'l') {
		t = t.parentNode;
		idx = t.id[1]*1;
		ts = vb_code[idx];
		
		if(idx < 2 && topleft.classList) {
			topleft.classList.toggle('hl');
		}
	}
	
	if(t && ts) {
		if(!t.classList) {
			if(t.className.baseVal.indexOf('hl') === -1) {
				t.className.baseVal = 
				t.className.animVal = 
				t.className.baseVal.trim();
				t.className.baseVal += ' hl'; 
				t.className.animVal += ' hl'; 
			}
			else {
				t.className.baseVal = 
				t.className.animVal = 
				t.className.baseVal.replace('hl', '');

			}
		}
		else {
			t.classList.toggle('hl');
		}
		
		if(!ts.classList) {
			if(ts.className.baseVal.indexOf('hl') === -1) {
				ts.className.baseVal = 
				ts.className.animVal = 
				ts.className.baseVal.trim();
				ts.className.baseVal += ' hl'; 
				ts.className.animVal += ' hl'; 
			}
			else {
				ts.className.baseVal = 
				ts.className.animVal = 
				ts.className.baseVal.replace('hl', '');

			}
		}
		else {
			ts.classList.toggle('hl');
		}
	}
};

var update = function() {
	var j, k, k2, k3, id, starp;
	
	if(paused && t > 60) {
		paused = false;
	}
	
	if(t%6 === 0 && !paused) {
		starp = [];
		val += dir;
		val2 += dir*f;
		
		for(var i = 0; i < 4; i++) {
			id = i*2;
			j = ((i%2) === 0);
			k = pow(-1, floor(id/4))*val;
			k2 = pow(-1, floor(id/4))*val2;
			k3 = pow(-1, i%2)*k2;

			pt_code[id].textContent = 
				j ? (k + ',0') : ('0,' + k);
			pt_code[id + 1].textContent = 
				~~k3 + ',' + ~~k2;
			
			starp.push(pt_code[id].textContent);
			starp.push(k3 + ',' + k2);
			
			pt_svg[id].setAttribute(j?'x':'y', k);
			pt_svg[id + 1].setAttribute('x', k3);
			pt_svg[id + 1].setAttribute('y', k2);
		}
		
		star.setAttribute('points', starp.join(' '));
				
		if(val >= 250 || val <= 135) {
			dir *= -1;
			paused = true;
			t = 0;
		}
	}
	
	t++;
	
	r_id = requestAnimationFrame(update);
};

update();

addEventListener('mouseover', hl, false);
addEventListener('mouseout', hl, false);
            
          
!
999px
Loading ..................

Console