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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              %input{:type => "checkbox", :id => "btn"}
%label{:for => "btn", :class => "btn"}
  %span.unchecked Play!
  %span.checked Pause!

  -(1..160).each do |i|
        -(1..5).each do |j|
              @import 'compass/css3';

$w: .25em; // width of strip
$l: 5em; // length of strip
$n: 5; // number of sides, should match number of nodes in DOM
$m: 32; // number of rings on each torus side
$ratio: 2; // major radius/minor radius

$p: $n*$m; // should match number of nodes in DOM

$ca: 360deg/$n;
$riminor: ($l/2)/tan($ca/2);
$rcminor: ($l/2)/sin($ca/2);

$cam: 360deg/$p;
$rcmajor: $ratio*$rcminor;

@mixin sp($w, $h: $w) {
  margin: if($w == $h, -$w/2, -$h/2 (-$w/2));
  width: $w; height: $h;

html, body { height: 100%; }

body {
  overflow: hidden;
  margin: 0;
  perspective: 32em;
  background: dimgrey;

.torus, .torus *, .torus :before, .torus :after {
  box-sizing: border-box;
  position: absolute;
  top: 50%; left: 50%;
  transform-style: preserve-3d;

.torus { transform: rotateX(-45deg) rotateY(0deg); }

@keyframes rotmaj { 
  to { transform: rotateX(-45deg) rotateY(360deg); }

.ring--penta {
  @for $i from 0 to $p {
    $rcurr: $rcmajor/cos($i*$cam - (floor($i/$m) + .5)*$ca);
    &:nth-child(#{$i + 1}) {
      transform: rotateY($i*$cam) 

@keyframes rotmin { to { transform: rotate(360deg); } }

.strip {
  @include sp($w, $l);
  &:before, &:after {
    @include sp($w, $l);
    backface-visibility: hidden;
    transform: rotateY(-90deg);
    content: '';
  &:after {
    transform: rotateY(90deg);
  @for $i from 0 to $n {
    $c: hsl($i*360/$n, 100%, 65%);
    $c1: hsl(($i + 1)*360/$n, 100%, 65%);
    &:nth-child(#{$i + 1}) {
      transform: rotate($i*$ca) translate($riminor);
      &:before { background: rgba($c, .4); }
      &:after { background: linear-gradient($c, $c1); }

/* "play animation" button styles */
input[type=checkbox] { display: none }
.btn {
  overflow: hidden;
  position: absolute;
  z-index: 10;
  top: 1em; left: 50%;
  border-radius: .5em;
  box-shadow: 0 1px 0 black, 0 -1px 0 #96d1f8;
  margin: 0 -3.25em;
  opacity: .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: .7s;
  &:hover { opacity: 1; }
.btn, .btn span { width: 6.5em; height: 2.6em; }
.btn span {
  position: absolute;
  text-align: center;
  transition: .5s;
.unchecked { top: 0; }
.checked { top: 100%; }
input[type=checkbox]:checked ~ .btn .unchecked { top: -100%; }
input[type=checkbox]:checked ~ .btn .checked { top: 0; }

/* in case anyone is wondering why I haven't used 
 * `animation-play-state`: Chrome Canary on Win 7 fucks up */
input[type=checkbox]:checked ~ .torus {
  animation: rotmaj 17.43s linear infinite;
input[type=checkbox]:checked ~ .torus .rotor {
  animation: rotmin 8.37s linear infinite;
              /* NO, there is NO JS, just a comment
Clicking the *Play!* button starts the animation. Needs support for `transform-style: preserve-3d` (so no IE, not even 11, sorry). Tested & works on Win 7 in Chrome 34 Canary, Chrome 32, Opera 19, Firefox 26 (choppy animation & not so great rendering - original version actually had twice the number of elements, but changed that due to how it behaved in FF). 

It's a torus (http://en.wikipedia.org/wiki/Torus) with pentagonal rings whose centres are distributed along a hypocycloid (http://en.wikipedia.org/wiki/Hypocycloid) with 5 cusps in the `xOz` plane. The pentagonal rings rotate and so does the torus itself.
🕑 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.