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


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.


                <canvas id='myCanvas'></canvas>


                body {
  margin: 0;
  overflow: hidden;
canvas {
  /* background: rgba(0,0,0,.1); */


                var canvas = document.getElementById('myCanvas');
var cw = canvas.width = window.innerWidth;
var ch = canvas.height = window.innerHeight;
var ctx = canvas.getContext('2d');

// you don't draw to a canvas, you draw to a context (2d or 3d)
// this clears out the context

// here we set styles for fill and stroke
ctx.fillStyle = 'rgba(0,128,255,.2)';

// these variables define our grid
var gridSize = 20;
var offset = gridSize / 2;
var gCol = Math.ceil(cw/gridSize);
var gRow = Math.ceil(ch/gridSize);

for(var x = 0; x < gCol; x++) {
  for(var y = 0; y < gRow; y++) {
    // multiply x * y by gridSize to
    // get position of grid squares.
    // add offset so we don't have dots
    // along the top and left edge.
    var gx = (x * gridSize) + offset;
    var gy = (y * gridSize) + offset;
    // to increase visiblity, and for
    // aesthetics make the dots a small
    // crosshair