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 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.

HTML

              
                <a href="https://bit.ly/prettyThings">http://dave.thehorners.com/tech-talk/programming/519-webgl-canvas-and-pretty-things</a>
<br/>    
<div id="container"></div>
    <input type="button" id="tango" value="Tango!">
      HTML5 Canvas Shape Tango with KineticJS<br/>
      <a href="https://www.html5canvastutorials.com/labs/html5-canvas-shape-tango-with-kineticjs/">https://www.html5canvastutorials.com/labs/html5-canvas-shape-tango-with-kineticjs/</a><br/>
      
              
            
!

CSS

              
                      body {
        margin: 0px;
        padding: 0px;
      }
      canvas {
        border: 1px solid #9C9898;
      }
      #tango {
        position: absolute;
        top: 20px;
        left: 0px;
        padding: 10px;
      }
      #container {
        display: inline-block;
        overflow: hidden;
        height: 100%;
        width: 100%;
      }
              
            
!

JS

              
                     var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
          
      function getRandomColor() {
          return colors[Math.round(Math.random() * 5)];
      }
      
      function tango(layer) {     
        for(var n = 0; n < layer.getChildren().length; n++) {
          var color = Kinetic.Util.getRGB(getRandomColor());
          var shape = layer.getChildren()[n];
          var stage = shape.getStage();
          var radius = Math.random() * 100 + 20;
          
          new Kinetic.Tween({
            node: shape, 
            duration: 1,
            x: Math.random() * stage.width(), 
            y: Math.random() * stage.height(), 
            rotation: Math.random() * 360, 
            radius: radius,
            opacity: (radius - 20) / 100,
            easing: Kinetic.Easings.EaseInOut,
            fillRed: color.r,
            fillGreen: color.g,
            fillBlue: color.b
          }).play();
        }
      }
      var stage = new Kinetic.Stage({
        container: 'container',
        width: 578,
        height: 363
      });

      var layer = new Kinetic.Layer();

      for(var n = 0; n < 10; n++) {
        var radius = Math.random() * 100 + 20;
        var color = Kinetic.Util.getRGB(getRandomColor());
        var shape = new Kinetic.RegularPolygon({
          x: Math.random() * stage.getWidth(),
          y: Math.random() * stage.getHeight(),
          sides: Math.ceil(Math.random() * 5 + 3),
          radius: radius,
          fillRed: color.r,
          fillGreen: color.g,
          fillBlue: color.b,
          opacity: (radius - 20) / 100,
          draggable: true
        });

        layer.add(shape);
      }

      stage.add(layer);

      document.getElementById('tango').addEventListener('click', function() {
        tango(layer);
      }, false);
              
            
!
999px

Console