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

              
                
              
            
!

CSS

              
                body {
  background-color: #0098e1;
}
              
            
!

JS

              
                /*
 * @name Array and Object
 * @description An array is a list of data, and an Object is a
 * list of colors. Each piece of data in an array is identified
 * by an index number representing its position in the array. 
 */
/*
  PixelArt
  Array map for paint a pixel art
*/

var grid = 16;    // Width of grid

var w = 20;       // Width of rect
var h = 20;       // Height of rect
var colors = {    // Object Colors
    1: '#000000', // Black
    2: '#ed225d', // P5Color
    3: '#ff829f', // LightP5Color
    4: '#b40067', // ShadowP5Color
    5: '#5b6468', // Grey
    6: '#5b6468', // LightGrey
    7: '#323436'  // DarkGrey
  };
var pixelArt = [  // Array Map
  0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,
  0,0,0,0,0,1,3,3,2,2,1,0,0,0,0,0,
  0,0,0,0,1,2,3,3,2,2,2,1,0,0,0,0,
  0,0,0,0,1,2,2,2,2,2,2,1,0,0,0,0,
  0,0,0,0,1,2,2,2,2,2,4,1,0,0,0,0,
  0,0,0,0,1,2,2,2,2,4,4,1,0,0,0,0,
  0,0,0,0,0,1,2,2,4,4,1,0,0,0,0,0,
  0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,
  0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,
  0,0,0,0,6,5,5,5,5,5,5,5,0,0,0,0,
  0,0,0,5,1,1,1,1,1,1,1,1,1,0,0,0
];

function setup() {
  createCanvas(400,400);
}


function draw() {
  var posX = 40;    // X possition
  var posY = 40;    // Y possition
  background('#0098e1');
  
 
  strokeWeight(0);


  for ( var i=0; i <= pixelArt.length; i++ ) {
      posX = posX + w;
      
      if( i % grid === 0 ) {
        posX = 40;
        posY = posY + h;
      }
      
      if( pixelArt[i] > 0 ){
        fill( colors[pixelArt[i]] );
        rect(posX, posY, w, h);
      }
  }

  var posXGrid = 0;
  var posYGrid = 0;

  strokeWeight(1);
  stroke(255,30);
  
  for ( var i=0; i < height; i = i+h ) {
    
    for ( var j=0; j < width; j = j+w ) {
      fill(0,random(0,25));
      rect(posXGrid,posYGrid,w,h);
      posXGrid = posXGrid + w;
    }
    
    posXGrid = 0;
    posYGrid = posYGrid + h;
  }

}

              
            
!
999px

Console