Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                %input{:type => "checkbox", :id => "btn"}
%label{:for => "btn", :class => "btn"}
  %span.unchecked Play!
  %span.checked Pause!
%ul.poly.penta-antiprism
  - (1...11).each do |i|
    %li.face.tri.in
  - (1...3).each do |i|
    %li.face.penta
      %div.in
              
            
!

CSS

              
                @import "compass/css3";

$n: 5; /* number of sides; 5 in the case of a pentagon */

/* angles */
$a: 180*($n - 2)/$n; /* angle of polygon */
$sa: 180 - $a; /* supplementary angle of polygon */
$ca: 360/$n; /* central angle of polygon */
/* acute angle between triangular face and plane of the pentagon for penta antiprism 
it's actually computed from acos(($cr - $ir)/$h)
I just didn't know about inverse trigonometric functions in SASS
*/
$da: 79.188;

/* lengths */
$l: 8em; /* length of a polygon side */
$h: $l*sqrt(3)/2; /* height of a regular triangle of side $l */
/* length of a pentagon diagonal */
$diagpenta: 2*$l*sin(($a/2)*pi()/180);
/* length of side of a square from which I start constructing 
   the pentagon*/
$start: ($diagpenta/2)/sin(((180 - 2*(180 - $a))/2)*pi()/180);
/* distance between a pentagon vertex and the closest diagonal */
$hdiagp: $l*cos(($a/2)*pi()/180);
/* distance between a pentagon vertex and the opposite side */
$hpenta: $start*cos(($a/2)*pi()/180);
$x: $hpenta - $hdiagp;
$ir: $l*sqrt((2*sqrt(5) + 5)/20); /* inradius for pentagon */
$cr: $l*sqrt((sqrt(5) + 5)/10); /* circumradius for pentagon */
$mr: ($cr + $ir)/2; /*average between inradius & circumradius*/
$cf: $hpenta/2 - $ir; /* correction factor */
$d: $h*sin($da*pi()/180); /* distance between the end pentagons */

*, *:before {
  position: inherit;
  width: inherit; height: inherit;
}
.in:before {
  background: rgba(255,0,0,1);
  content: '';
}
.in:nth-child(odd):before {
  background: rgba(0,0,255,1);
}

html {
  overflow: hidden;
  height: 100%;
  perspective: 20em;
  background: dimgrey;
}
.poly {
  position: absolute;
  left: 50%; top: 50%;
  margin: 0;
  padding: 0;
  width: 0; height: 0;
  list-style: none;
	transform: rotateZ(-50deg) rotateX(75deg) rotateY(-170deg);
	transform-style: preserve-3d;
  animation-play-state: paused;
	animation: rot 20s infinite linear;
  pointer-events: none;
}
@keyframes rot {
  to { transform: rotateZ(310deg) rotateX(-285deg) rotateY(190deg); }
}
.face {
  overflow: hidden;
  position: inherit;
  left: inherit; top: inherit;
  backface-visibility: hidden;
}
.tri {
  $nt: 3;
  $at: 180*($nt - 2)/$nt; /* angle of polygon */
  $sat: 180 - $at; /* supplementary angle of polygon */
  /* acute angle of created parallelogram */
  $aapara: 180 - 2*$sat;
  /* scale factor to turn the parallelogram to a rhombus */
  $sfactor: cos((90 - $aapara)*pi()/180);
  
  margin: -$l/2;
  width: $l; height: $l;
  
  @for $i from 1 to 11 {
    &:nth-child(#{$i}) {
      transform: 
        rotate(#{$i*360/(2*$n)}deg) 
        translateY($mr)
        rotateX(#{(1 - pow(-1,$i+1))*90 - pow(-1,$i)*$da}deg) 
        translateY(pow(-1,$i)*$l*sqrt(3)/4)
        rotateY(180deg) 
        rotate(#{$aapara/2}deg) 
        skewY(#{90 - $aapara}deg) 
        scaleX($sfactor);
      &:before {
        $revsfactor: 1/$sfactor;
        $revaapara: -$aapara;
    
        transform: 
          scaleX($revsfactor) 
          skewY(#{-$revaapara - 90}deg) 
          rotate(#{$revaapara/2}deg) 
          translateY(pow(-1,$i+1)*$l/2);
      }
    }
  }
  &:before {
    background: 
      radial-gradient(circle at 0 100%, hsl(60, 100%, 50%), hsla(0, 100%, 50%, 0) 50%), 
      radial-gradient(circle at 100% 100%, hsl(120, 100%, 50%), hsla(180, 100%, 50%, 0) 50%), 
      radial-gradient(circle at 50% 13.333%, hsl(240, 100%, 50%), hsla(300, 100%, 50%, 0) 50%)
  }
  &:nth-child(odd):before {
    background: 
      radial-gradient(circle at 0 0, hsl(60, 100%, 50%), hsla(0, 100%, 50%, 0) 50%), 
      radial-gradient(circle at 100% 0, hsl(120, 100%, 50%), hsla(180, 100%, 50%, 0) 50%), 
      radial-gradient(circle at 50% 86.667%, hsl(240, 100%, 50%), hsla(300, 100%, 50%, 0) 50%)
  }
}
.penta {
  $aapara: 180 - 2*$sa;
  /* scale factor to turn the parallelogram to a rhombus */
  $sfactor: cos((90 - $aapara)*pi()/180);
  
  margin: -$start/2;
  width: $start; height: $start;
  transform: 
    translateZ($d/2) 
    /* the .93 correction factor is the only thing here 
    that is trial and error, for some reason, 
    it won't be correctly positioned otherwise
    rounding errors or am I missing something? */
    translateY($cf - ($start/2 - $x)*.93) 
    rotate(#{$aapara/2}deg) 
    skewY(#{90 - $aapara}deg) 
    scaleX($sfactor);
  
  .in {
    $revsfactor: 1/$sfactor;
    $revaapara: -$aapara;
    $aapara: 180 - $a;
    $sfactor: cos((90 - $aapara)*pi()/180);
    
    overflow: hidden;
    transform: 
      scaleX($revsfactor) 
      skewY(#{-$revaapara - 90}deg) 
      rotate(#{$revaapara/2}deg) 
      translateY($x) 
      rotate(#{-$aapara/2}deg) 
      skewX(#{90 - $aapara}deg) 
      scaleY($sfactor);
    
    &:before {
      $revsfactor: 1/$sfactor;
      $revaapara: -$aapara;
      
      transform:
        scaleY($revsfactor) 
        skewX(#{-$revaapara - 90}deg) 
        rotate(#{-$revaapara/2}deg) 
        translateY(-$start/2);
      background: rgba(0,255,0,1);
      background: 
        radial-gradient(circle at ($start - $l)/2 100%, 
                    hsl(0, 100%, 50%), hsla(0, 100%, 50%, 0) 50%), 
        radial-gradient(circle at ($start + $l)/2 100%, 
                    hsl(72, 100%, 50%), hsla(72, 100%, 50%, 0) 50%),
        radial-gradient(circle at ($start + $l)/2 + $l*cos(72*pi()/180) $start - $l*sin(72*pi()/180), 
                    hsl(144, 100%, 50%), hsla(144, 100%, 50%, 0) 50%), 
        radial-gradient(circle at 50% $start - ($l*sin(72*pi()/180) + $l*sin(36*pi()/180)), 
                    hsl(216, 100%, 50%), hsla(216, 100%, 50%, 0) 50%),
        radial-gradient(circle at ($start - $l)/2 - $l*cos(72*pi()/180) $start - $l*sin(72*pi()/180), 
                    hsl(288, 100%, 50%), hsla(288, 100%, 50%, 0) 50%);
        background-size: $start $start;
    }
  }
  &:nth-child(even) {
    $aapara: 180 - 2*$sa;
    /* scale factor to turn the parallelogram to a rhombus */
    $sfactor: cos((90 - $aapara)*pi()/180);
   
    transform: 
      rotateY(180deg)
      translateZ($d/2) 
      translateY(($start/2 - $x) - $cf)
      rotate(#{$aapara/2}deg) 
      skewY(#{90 - $aapara}deg) 
      scaleX($sfactor);
    
    .in {
      $revsfactor: 1/$sfactor;
      $revaapara: -$aapara;
      $aapara: 180 - $a;
      $sfactor: cos((90 - $aapara)*pi()/180);
      
      transform: 
        scaleX($revsfactor) 
        skewY(#{-$revaapara - 90}deg) 
        rotate(#{$revaapara/2}deg) 
        translateY(-$x) 
        rotate(#{-$aapara/2}deg) 
        skewX(#{90 - $aapara}deg) 
        scaleY($sfactor);
      
      &:before {
        $revsfactor: 1/$sfactor;
        $revaapara: -$aapara;
      
        transform:
          scaleY($revsfactor) 
          skewX(#{-$revaapara - 90}deg) 
          rotate(#{-$revaapara/2}deg) 
          translateY($start/2);
        background: 
        radial-gradient(circle at ($start - $l)/2 0, 
                    hsl(0, 100%, 50%), hsla(0, 100%, 50%, 0) 50%), 
        radial-gradient(circle at ($start + $l)/2 0, 
                    hsl(72, 100%, 50%), hsla(72, 100%, 50%, 0) 50%),
        radial-gradient(circle at ($start + $l)/2 + $l*cos(72*pi()/180) $x, 
                    hsl(144, 100%, 50%), hsla(144, 100%, 50%, 0) 50%), 
        radial-gradient(circle at 50% $hpenta, 
                    hsl(216, 100%, 50%), hsla(216, 100%, 50%, 0) 50%),
        radial-gradient(circle at ($start - $l)/2 - $l*cos(72*pi()/180) $x, 
                    hsl(288, 100%, 50%), hsla(288, 100%, 50%, 0) 50%);
        background-size: $start $start;
      }
    }
  }
}
/* animate button styles */
input[type=checkbox] {
  display: none;
}
.btn {
  overflow: hidden;
  position: absolute;
  z-index: 10;
  top: .25em;
  left: 50%;
  border-radius: 0.5em;
  box-shadow: 0 1px 0 black, 0 -1px 0 #96d1f8;
  margin: 0 -3.25em;
  opacity: 0.45;
  background: #65a9d7 linear-gradient(#3e779d, #65a9d7);
  color: white;
  font: 700 italic 1em/2.6 Georgia, serif;
  text-shadow: 0 1px 0 black;
  cursor: pointer;
  transition: 0.7s;
}
.btn:hover { opacity: 1; }
.btn, .btn span { width: 6.5em; height: 2.6em; }
.btn span {
  position: absolute;
  text-align: center;
  transition: 0.5s;
}
.unchecked { top: 0; }
.checked { top: 100%; }
input[type=checkbox]:checked ~ .btn .unchecked { top: -100%; }
input[type=checkbox]:checked ~ .btn .checked { top: 0; }
            
input[type=checkbox]:checked ~ .poly {
  animation-play-state: running;
}
              
            
!

JS

              
                
              
            
!
999px

Console