Pen Settings

HTML

CSS

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

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

              
                <!-- The concept was inspired by this project: https://googlecreativelab.github.io/coder-projects/projects/mondrian/ -->
<!--  The frame design was inspired/lifted/altered from https://codepen.io/chris22smith/pen/PbBwjp -->

<div id="phrame1">
  <div id="painting1">
  </div>
</div>
<br>
<div id="refresh">&#8635;</div>
              
            
!

CSS

              
                html {
  height:100%;
}

body {
  background-image:linear-gradient(#eee, #aaa);
  height:100%;
}

#painting1, #painting-1 {
  width:100%;
  height:100%;
}

#phrame1, #phrame-1 {
  margin:auto;
  background-color:#ddc;
  border:solid 5vmin #eee;
  border-bottom-color:#fff;
  border-left-color:#eee;
  border-radius:2px;
  border-right-color:#eee;
  border-top-color:#ddd;
  box-shadow:0 0 5px 0 rgba(0,0,0,.25) inset, 0 5px 10px 5px rgba(0,0,0,.25);
  box-sizing:border-box;
  display:inline-block;
  margin:10vh 10vw;
  height:70%;
  width: 80%;
/*   padding:8vmin; */
  position:relative;
  text-align:center;
  &:before {
    border-radius:2px;
    bottom:-2vmin;
    box-shadow:0 2px 5px 0 rgba(0,0,0,.25) inset;
    content:"";
    left:-2vmin;
    position:absolute;
    right:-2vmin;
    top:-2vmin;
  }
  &:after {
    border-radius:2px;
    bottom:-2.5vmin;
    box-shadow: 0 2px 5px 0 rgba(0,0,0,.25);
    content:"";
    left:-2.5vmin;
    position:absolute;
    right:-2.5vmin;
    top:-2.5vmin;
  }
}

#refresh {
  font-size:80px;
  font-weight:800;
  position: absolute;
  bottom: 0px;
  left: 20px;
  margin:auto;
  cursor:pointer;
}

table, th, td {
/*     border: 1px solid #30303a; */
    border-collapse: collapse;
}

.Yellow {
  background: #fff001;
}

.Blue {
  background: #0101fd;
}

.Red {
  background: #ff0101;
}

.White {
  background: #f9f9f9;
}

.Black {
  background: #30303a;
}

.noTopWhite {
  border-top: 10px solid #f9f9f9;
}

.noLeftWhite {
  border-left: 10px solid #f9f9f9;
}

.noTopYellow {
  border-top: 10px solid #fff001;
}

.noLeftYellow {
  border-left: 10px solid #fff001;
}

.noTopBlue {
  border-top: 10px solid #0101fd;
}

.noLeftBlue {
  border-left: 10px solid #0101fd;
}

.noTopRed {
  border-top: 10px solid #ff0101;
}

.noLeftRed {
  border-left: 10px solid #ff0101;
}

.leftBlack {
  border-left: 10px solid #30303a;
}

.topBlack {
  border-top: 10px solid #30303a;
}

.noise {
  height: 100%;
  background: radial-gradient(circle at 45% 55%, transparent, rgba(30, 30, 30, .20) ), url(https://grainy-gradients.vercel.app/noise.svg);
  mix-blend-mode: color;
}

/* Chrome-specific */
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {
  .noise {
    filter: contrast(190%) brightness(10%);
  }
}
.overlay {
  position: absolute;
  top: 0;
/*   width: 100%; */
  height: 100%;
  background: moccasin;
  mix-blend-mode: multiply;
}
              
            
!

JS

              
                const colors = ["Black","White","Yellow","Blue","Red"];
let currentArt = 1;

$("#refresh").click(mondit);
  
function mondit () {
  $("#painting"+currentArt).html("");
  let newWidth = Math.floor(Math.random()*45)+35;
  let newHeight = Math.floor(Math.random()*45)+35;
  $("#phrame"+currentArt).css({
    "width" : newWidth+"%", 
    "margin-left" : (100-newWidth)/2 +"%", 
    "height" : newHeight+"%"
  });
  $("#painting"+currentArt).html('<table style="width:100%;height:100%"></table>');
  let rows = Math.floor(Math.random()*3)+3;
  let cols = Math.floor(Math.random()*3)+3;
  for (let row=0; row<rows ; row++) {
    $("table").append("<tr class='a"+ row +"'></tr>");
    for (let col=0; col<cols; col++) {
      if (Math.random()>.1) {
        var pick = Math.floor(Math.random()*4)+1;
      } else {
        var pick = 0;
      }

      if ( row>0 ) { var toAbove = $(".a"+(row-1)+" td:nth-child("+(col+1)+")").hasClass( colors[pick] ) };
      if ( col>0 ) { var toLeft = $(".a"+row+" td:nth-child("+col+")").hasClass( colors[pick] ) };
      
      if ( row<1 && col<1 ) {
          $(".a"+row ).append("<td class='"+ colors[pick] +"'><div class='noise'></div><div class='overlay'></div></td>");
      } else if ( row<1 && col>0 ) {
          $(".a"+row ).append("<td class='"+ colors[pick] +" leftBlack'><div class='noise'></div><div class='overlay'></div></td>");
      } else if ( row>0 && col<1 ) {
        if ( toAbove ) {
          $(".a"+row ).append("<td class='"+ colors[pick] +"'><div class='noise'></div><div class='overlay'></div></td>");
        } else {
          $(".a"+row ).append("<td class='"+ colors[pick] +" topBlack'><div class='noise'></div><div class='overlay'></div></td>");
        }
      } else if ( toAbove && toLeft || toAbove ) {
          $(".a"+row ).append("<td class='"+ colors[pick] +" leftBlack'><div class='noise'></div><div class='overlay'></div></td>");
      } else if ( toAbove && col<1 ) {
          $(".a"+row ).append("<td class='"+ colors[pick] +"'><div class='noise'></div><div class='overlay'></div></td>");
      } else if ( toLeft ) {
          $(".a"+row ).append("<td class='"+ colors[pick] +" topBlack leftBlack'><div class='noise'></div><div class='overlay'></div></td>");
          $(".a"+row+" td:nth-child("+(col)+")" ).addClass( "topBlack" );
          $(".a"+(row+1)+" td:nth-child("+(col)+")" ).addClass( "topBlack" );
      } else {
          $(".a"+row ).append("<td class='"+ colors[pick] +" leftBlack topBlack'><div class='noise'></div><div class='overlay'></div></td>");
      }
    }
  }
  let widthLeft = 100;
  for (a=0; a<cols-1 ; a++) {
    let thisWidth = Math.floor(Math.random()*(widthLeft/3))+10;
    widthLeft -= thisWidth;
    $("td:nth-child("+(a+1)+")").css("width", thisWidth+"%"); 
  }
  let heightLeft = 100;
  for (a=0; a<rows-1 ; a++) {
    let thisHeight = Math.floor(Math.random()*(heightLeft/3))+10;
    heightLeft -= thisHeight;
    $("tr:nth-child("+(a+1)+")").css("height", thisHeight+"%");
  }
  // currentArt *= -1;
}

mondit();
              
            
!
999px

Console