cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

              <div id="container">
    <label for="upload-image">1. upload an image</label>
    <input type="file" id="upload-image" name="upload-image" />

  <p id="frame-container">
    <canvas id="frame-canvas"></canvas>

<div id="menu"> 

  <div class="tray">
    <p><a href="index.html">SEURAT.EXTEND()<br /> a <code>var t;</code> demo</a></p>
    <p><small>upload an image, get an art<br /><a href="index.html">learn about  george-pierre seurat</a></small></p>
      <button id="clear">Clear</button>
      <button id="save">Save</button>
              body { font-family: Helvetica; padding: 1em; }

#container p { margin: 0 0 2em; }
label { font-weight: bold; text-transform: uppercase; font-size: 1.5em; display: block; margin: .5em 0; }

#menu { position: absolute; top: 10px; right: 10px; text-align: right;   }
#menu a { text-decoration: none; color: black; font-weight: bold; font-size: 1.2em; }
#menu p { margin-bottom: 10px; }
#menu small { font-family: monospace; }


    var uploadInput = document.getElementById('upload-image');
    var frameContainer = document.getElementById('frame-container');
    var canvas = document.getElementById('frame-canvas');
    var ctx = canvas.getContext('2d');

    var buttonClear = document.getElementById('clear');
    var buttonSave = document.getElementById('save');

    var pixelSize = 15;
    var frameSize;


    var calculateFrameSize = function(dimension) {
      // returns computer-pixel width of frame
      var size = pixelSize * Math.ceil( (dimension * .1) / pixelSize) ;
      return size;
    var drawFrame = function() {

      // go through each 15px pixel and draw 
      for ( var x = 0; x <= canvas.width; x = x + pixelSize ) {
        for ( var y = 0; y <= canvas.height; y = y + pixelSize ) {

          console.log(x, y);
          // only draw if pixel is outside of image
          if ( 
            x < frameSize || 
            y < frameSize ||
            x >= canvas.width - frameSize - 1 ||
            y >= canvas.height - frameSize - 1
          ) {
            ctx.fillStyle = 'lime';
            ctx.fillRect(x, y, pixelSize, pixelSize);


    /** EVENTS **/

    // when uploading an image, embed it onto canvas and show it
    uploadInput.onchange = function(){

      // embed image onto canvas
      var uploadedImage = uploadInput.files[0];
      var reader = new FileReader();
      reader.onload = function(e){
        var img = new Image();
        img.onload =function() {
          // calculate frame width off of smallest dimension
          frameSize = calculateFrameSize(Math.min(img.width, img.height));
          canvas.style.backgroundColor = 'hotpink';
          canvas.width = img.width + 2 * frameSize;
          canvas.height = img.height + 2 * frameSize;

        img.src = e.target.result;

      // show sketch container
      frameContainer.style.display = "block";

    // clear canvas when clear button clicked
    buttonClear.onclick = function(){
      ctx.fillStyle = "#ffffff";

      frameContainer.style.display = 'none';

    // open png in new window when save button clicked
    buttonSave.onclick = function(){

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................