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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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="sketch-container" class="hide">
    <label>2. Draw some edges or erase for a "sketched" look.</label>

    <canvas id="sketch-canvas"></canvas>

<div id="menu"> 

 <div class="tray">
    <p><a href="index.html">DE-SKETCHING CASSATT<br /> a <code>var t;</code> demo</a></p>
    <p><small>upload an image<br />make it an art<br /><a href="index.html">learn about mary cassatt</a></small></p>
    <div id="sketch-tools">
      <button class="clear">Clear</button>
      <button class="save">Save</button> <br />
      <button class="pencil">Pencil</button> 
      <button class="eraser">Eraser</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; width: 500px;}

#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; }

#sketch-container { position: relative; }

button { background-color: #ccc; border-color: #ccc; margin: 5px;}
button.in-use { background-color: lime; border-color: lime; }

.hide { display: none; }

  var $uploadInput = $('#upload-image');
  var $sketchContainer = $('#sketch-container');
  var $sketchTools = $('#sketch-tools').addClass('hide');
  var canvas = $('#sketch-canvas')[0];
  var ctx = canvas.getContext('2d');

  var $buttonClear = $('button.clear');
  var $buttonSave = $('button.save');
  var $buttonPencil = $('button.pencil').addClass('in-use');
  var $buttonEraser = $('button.eraser');

  var sketchRadius = 2;
  var sketchColor = '#897171';
  var tool = 'pencil';

  /** EVENTS **/

  // when uploading an image, embed it onto canvas and show it

    // embed image onto canvas
    var uploadedImage = $uploadInput[0].files[0];
    var reader = new FileReader();
    reader.onload = function(e){
      var img = new Image();
      img.onload =function() {
        canvas.width = img.width;
        canvas.height = img.height;
      img.src = e.target.result;

    // show sketch container

  // clear canvas when clear button clicked
    ctx.fillStyle = "#ffffff";


  // open png in new window when save button clicked
  // use pencil when pencil button clicked
    tool = 'pencil';
  // use eraser when eraser button clicked
    tool = 'eraser';

  /** DE-SKETCHING **/


      // get current pixel position
      var offset = $(this).offset(); 
      var x = e.pageX - offset.left;
      var y = e.pageY - offset.top;

      // draw 2px wide circle with grey around the point of mouse
      // if pencil, draw edges. if eraser, do the magical erase thing
      if ( tool === 'pencil' ) {
        ctx.arc(x, y, sketchRadius, 0, 2 * Math.PI, false);
        ctx.fillStyle = sketchColor;
      else if ( tool === 'eraser' ) {
        // magical erase thing will go here!

  // when mouse goes up, stop de-sketching

Loading ..................