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

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <svg width='0' height='0'>
	<defs><circle id='point' r='2'/></defs>
</svg>

<h1>Polygon</h1>

<p>A polygon satisfies all the following:</p>
	
<ul>
	<li>2D shape</li>
	<li>closed, with equal number of vertices and edges (at least 3)</li>
	<li>only straight lines as edges</li>
	<li>no 3 consecutive vertices on the same line</li>
</ul>

<section>
	<p>The following are not polygons:</p>
	
	<article class='no'>
		<div class='cube'>
			<div class='cube__face'></div>
			<div class='cube__face'></div>
			<div class='cube__face'></div>
			<div class='cube__face'></div>
			<div class='cube__face'></div>
			<div class='cube__face'></div>
		</div>
	</article>
	
	<article class='no'>
		<svg viewbox='0 0 200 200'>
			<polyline points='70,5 170,150 15,147'/>
			<g class='points'>
				<use xlink:href='#point' x='70' y='5'/>
				<use xlink:href='#point' x='170' y='150'/>
				<use xlink:href='#point' x='15' y='147'/>
			</g>
		</svg>
	</article>
	
	<article class='no'>
		<svg viewbox='0 0 200 200'>
			<path d='M50,20 Q170,5 65,147 L180,90 
							 A67 90 35 0 1 45 150z'/>
			<g class='points'>
				<use xlink:href='#point' x='50' y='20'/>
				<use xlink:href='#point' x='65' y='147'/>
				<use xlink:href='#point' x='180' y='90'/>
				<use xlink:href='#point' x='45' y='150'/>
			</g>
		</svg>
	</article>
	
	<article class='no'>
		<svg viewbox='0 0 200 200'>
			<polygon points='25,75 100,100 175,125'/>
			<g class='points'>
				<use xlink:href='#point' x='25' y='75'/>
				<use xlink:href='#point' x='100' y='100'/>
				<use xlink:href='#point' x='175' y='125'/>
			</g>
		</svg>
	</article>
	
	<p>The cube is not a 2D shape. The polyline in the second example is not closed and has 3 vertices, but only 2 edges. The third shape is not made entirely of straight lines. And, in the fourth case, we have 3 consecutive points on the same line.</p>
	
	<hr>
	
	<p>The following are polygons:</p>
	
	<article class='ok'>
		<svg viewbox='0 0 200 200'>
			<polygon points='25,75 50,5 175,125'/>
			<g class='points'>
				<use xlink:href='#point' x='25' y='75'/>
				<use xlink:href='#point' x='50' y='5'/>
				<use xlink:href='#point' x='175' y='125'/>
			</g>
		</svg>
	</article>
	
	<article class='ok'>
		<svg viewbox='0 0 200 200'>
			<polygon points='70,5 170,150 
											 15,147 100,90'/>
			<g class='points'>
				<use xlink:href='#point' x='70' y='5'/>
				<use xlink:href='#point' x='170' y='150'/>
				<use xlink:href='#point' x='15' y='147'/>
				<use xlink:href='#point' x='100' y='90'/>
			</g>
		</svg>
	</article>
	
	<article class='ok'>
		<svg viewbox='0 0 200 200'>
			<polygon points='100,10 145,190 5,65 
											 195,75 56,185'/>
			<g class='points'>
				<use xlink:href='#point' x='100' y='10'/>
				<use xlink:href='#point' x='145' y='190'/>
				<use xlink:href='#point' x='5' y='65'/>
				<use xlink:href='#point' x='195' y='75'/>
				<use xlink:href='#point' x='56' y='185'/>
			</g>
		</svg>
	</article>
</section>
              
            
!

CSS

              
                html {
	font: 1em trebuchet ms, verdana, arial, sans-serif;
}

article {
	display: inline-block;
	position: relative;
	min-width: 20em; min-height: 20em;
	width: 20vw; height: 20vw;
	perspective: 50em;
}

line, polyline, path, polygon {
	fill: none;
	
	.no & { stroke: red; }
	.ok & { stroke: green; }
}

.cube {
	&, * {
		position: absolute;
		top: 50%; left: 50%;
	}
	
	transform-style: preserve-3d;
	animation: rot 16s linear infinite;
	
	&__face {
		margin: -6.5em;
		width: 13em; height: 13em;
		box-shadow: inset 0 0 0 .1875em red;
		
		@for $i from 0 to 6 {
			&:nth-child(#{$i + 1}) {
				transform: 
					if($i < 4, rotateY($i*90deg), rotateX(pow(-1, $i)*90deg)) 
					translateZ(6.5em);
			}
		}
	}
}

@keyframes rot { to { transform: rotate(360deg) rotateY(360deg); } }
              
            
!

JS

              
                
              
            
!
999px

Console