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

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

              
                <canvas height="400" id="c" width="800"></canvas>
              
            
!

CSS

              
                
              
            
!

JS

              
                const width = 800;
const height = 400;

// Get 2d drawing context
const ctx = document.getElementById('c').getContext('2d');
// Get copy of actual imagedata (for the whole canvas area)
const imageData = ctx.getImageData(0, 0, width, height);
// Create a buffer that's the same size as our canvas image data
const buf = new ArrayBuffer(imageData.data.length);
// 'Live' 8 bit clamped view to our buffer, we'll use this for writing to the canvas
const buf8 = new Uint8ClampedArray(buf);
// 'Live' 32 bit view into our buffer, we'll use this for drawing
const buf32 = new Uint32Array(buf);
// RGBA stored in a 32bit uint
const red = (255 << 24) | 255;
// Loop through all the pixels.
for (let y = 0; y < height; y++) {
  const yw = y * width;
  for (let x = 0; x < width; x++) {
    buf32[yw + x] = red;
  }
}
// Update imageData and put it to our drawing context
imageData.data.set(buf8);
ctx.putImageData(imageData, 0, 0);
              
            
!
999px

Console