Pen Settings



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


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


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.


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.


                <div class="autoscale" id="autoscale1">
  <canvas id="canvas1"></canvas>


                html {
  background-color: #202020;
  /* Striped background */
  background-image: repeating-linear-gradient(
    #202020 0px,
    #202020 20px,
    #303030 20px,
    #404040 40px
  height: 100vh;

canvas {
  display: block;

.autoscale {
  left: 0;
  position: absolute;
  top: 0;
  transform-origin: 0 0;

#canvas1 {
  height: 540px;
  width: 960px;



                import { AutoScaleWrapper } from '[email protected]/viewport/AutoScaleWrapper.js'
import { CanvasHandle } from '[email protected]/canvas/CanvasHandle.js'
import { startMainloop } from '[email protected]/scheduling/mainloop.js'

/* Fit the browser window */
const autoscale = new AutoScaleWrapper(document.querySelector('#autoscale1'), 960, 540)

/* Canvas handle for convenience (not required) */
const canvas = new CanvasHandle(document.querySelector('#canvas1'), 960, 540)
const con = canvas.con /* CanvasRenderingContext2D */

/* Fixed-step update function */
function update() {
  /* Nobody here but us chickens! */

/* The rendering function receives `t` in the range (0, 1] for interpolation */
function render(t) {
  con.fillStyle = '#000'
  con.fillRect(0, 0, canvas.width, canvas.height)

  con.fillStyle = '#fff'
  con.fillRect(0.5 * canvas.width - 20, 40, 40, 40)

/* Start the loop */
startMainloop(update, render)