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

              
                <canvas id=c width=512 height=256 style=width:100%;image-rendering:-moz-crisp-edges;image-rendering:pixelated>
<!--
Right click on the image to save.

Sprites are aligned to a 16x16 pixel grid with a transparent background.

Reload for a new sheet, or set the seed to whatever you want! ✌️😄
-->
              
            
!

CSS

              
                
              
            
!

JS

              
                // Tiny Sprite Sheet Generator - Frank Force 2020 - MIT License

'use strict'
let seed, x, R, i, j, pass, s, X, Y;

seed = Date.now();    // seed for random generaton, can be replaced with hardcoded value
x = c.getContext`2d`; // 2d canvas context
x.lineWidth = 2;      // set 2 pixel wide line width to make the black outline
R = ()=> (Math.sin(++s + i*i) + 1)*1e9 % 256 | 0; // get a seeded random integer between 0-256

for(i = 32 * 16; i--;)                          // for each sprite (32 rows x 16 columns)
for(pass = 4; pass--;)                          // 4 passes, outline left/right and fill left/right
for(s = seed, j = R()/5 + 50|0; j--;)           // set seed, randomize max sprite pixels, 50-101
  X = j&7, Y = j>>3,                            // X & Y pixel index in sprite
  R() < 19 ?                                    // small chance of new color
    x.fillStyle = `rgb(${R()},${R()},${R()})` : // randomize color
    R()**2 / 2e3 > X*X + (Y-5)**2 &&            // distance from center vs random number
      x[pass&2 ? 'strokeRect' : 'fillRect'](    // stroke first for outline then fill with color
          7 + i%32*16 - pass%2*2*X + X,         // x pos, flipped if pass is even
          2 + (i>>5)*16 + Y,                    // y pos
          1, 1);                                // 1 pixel size
              
            
!
999px

Console