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

              
                <canvas id="canvas1" width="550" height="500"></canvas>
<input id="button" type="button" value="toggle paused" onclick="createjs.Ticker.paused = !createjs.Ticker.paused;">
<a href="https://createjs.com/" target="_blank"><img id="logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1524180/createjs-badge-black.png"></a>
              
            
!

CSS

              
                html, body {
  margin:0px;
  padding:0px;
  background-color:#FFFFFF;
  overflow:hidden;
}

#button {
  position: absolute;
  bottom: 20px;
  left: 10px;
}

#logo { 
	position: absolute;
  right:0px;
  bottom:0px;
}

canvas {
  background-color:#FFFFFF;
}
              
            
!

JS

              
                var canvas, stage, star;
function init() {
  // set up our stage:
  stage = new createjs.Stage("canvas1");
  canvas = stage.canvas;
  stage.autoClear = false;

  star = new createjs.Shape();
  var fillCmd = star.graphics.beginFill("#FF0000").command;
  star.graphics.drawPolyStar(0, 0, 300, 12, 0.85);
  star.x = stage.canvas.width/2;
  star.y = stage.canvas.height/2;

  stage.addChild(star);

  // install the sample plugin:
  createjs.ColorPlugin.install();

  // set up a tween that tweens the color of the fill:
  createjs.Tween.get(fillCmd, {loop:-1, bounce:true})
    .to({style:"#00FF00"}, 1000) // supports 6 digit hex colors
    .to({style:"#00F"}, 2000) // 3 digit hex colors
    .to({style:"rgb(255,128,0)"}, 1000) // rgb and rgba colors
    .to({style:"hsl(295, 100%, 50%)"}, 1000) // hsl & hsla colors
    .to({style:"rgb(0%,100%,100%)"}, 1000) // and percentage based rgb / rgba

  // and just for fun, lets make it spin and scale:
  // comment this out if you want to focus on the color shifts.
  createjs.Tween.get(star, {loop:-1, bounce:true})
    .to({alpha:0.3, scaleX:0.2, scaleY:0.2})
    .to({rotation:360, scaleX:3, scaleY:3}, 3300, createjs.Ease.quadInOut);

  createjs.Ticker.timingMode = createjs.Ticker.RAF;
  createjs.Ticker.on("tick", stage);
  handleResize();
}

init();

window.addEventListener("resize", handleResize, false);
function handleResize(event) {
  var w = window.innerWidth, h = window.innerHeight;
  canvas.width = w; canvas.height = h;
  star.x = w >> 1; star.y = h >> 1;
};
              
            
!
999px

Console