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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

              <section id="control-panel"><label for="blendmode">Blend Mode:</label><select id="blendmode">
      <option value="normal" data-desc="No Blending">Normal</option>
      <option value="multiply" data-desc="Result is at least as dark as existing image and draw color" selected>Multiply</option>
      <option value="screen" data-desc="Result is at least as light as existing image and draw color">Screen</option>
      <option value="overlay" data-desc="Shadows and hilights are preserved">Overlay</option>
      <option value="darken" data-desc"Darker of image and draw color are chosen">Darken</option>
      <option value="lighten" data-desc="Lighter of image and draw color are chosen">Lighten</option>
      <option value="color-dodge" data-desc="Brighten the image to reflect the draw color">Color Dodge</option>
      <option value="color-burn" data-desc="Darken the image to reflect the draw color">Color Burn</option>
      <option value="hard-light" data-desc="Similar to shining a harsh light on the image">Hard Light</option>
      <option value="soft-light" data-desc="Similar to shining a diffuse light on the image">Soft Light</option>
      <option value="difference" data-desc="Subtracts the darker of the image and draw color from the other">Difference</option>
      <option value="exclusion" data-desc="Low contrast version of Difference">Exclusion</option>  
      <option value="hue" data-desc="Use the hue of the draw color and the saturation &amp; luminosity of the image">Hue</option>
      <option value="saturation" data-desc="Use the saturation of the draw color and the hue &amp; luminosity of the image">Saturation</option>
      <option value="color" data-desc="Use the hue &amp; saturation of the draw color and the luminosity of the image">Color</option>
      <option value="luminosity" data-desc="Use the luminosity of the draw color and the hue &amp; saturation of the image">Luminosity</option>
  <div id="blend-desc"></div>

  <label for="color-picker">Draw Color: </label>
  <select id="color-picker">
    <option value="#00FFFF">Aqua</option>
    <option value="#000000">Black</option>
    <option value="#0000FF">Blue</option>
    <option value="#FF00FF">Fuchsia</option>
    <option value="#808080">Gray</option>
    <option value="#008000">Green</option>
    <option value="#00FF00">Lime</option>
    <option value="#800000">Maroon</option>
    <option value="#000080">Navy</option>
    <option value="#808000">Olive</option>    
    <option value="#FFA500">Orange</option>    
    <option value="#800080">Purple</option>    
    <option value="#FF0000">Red</option>      
    <option value="#C0C0C0">Silver</option>     
    <option value="#008080">Teal</option>     
    <option value="#FFFFFF">White</option>     
    <option value="#FFFF00">Yellow</option>    
  <input type="button" value="Reset" id="reset-btn">

<div class="canvas-container">
  <canvas id="canvas"></canvas>
  <small>Photo By Alan Greenblatt</small>

              #control-panel {
  float: left;
  width: 25%;
  margin-right: 10px;

#blend-desc {
  margin-bottom: 10px;

.canvas-container {
  display: block;
  height: 450px;

#canvas {
  display: block;
  cursor: pointer;
  width: 600px;
  height: 400px;

input[type=button] {
  font-size: 1.5rem;
              var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 600;
canvas.height = 400;

$canvas = $('canvas');
var offset = $canvas.offset();

ctx.globalCompositeOperation = 'source-over';
ctx.clearRect(0, 0, 600, 400);

var img = document.createElement('img');
img.src = "http://blattchat.com/demos/images/tower-bridge.JPG";

img.onload = function() {
    ctx.drawImage(this, 0, 0, 600, 400);

// Update the blend mode description text

$('#blendmode').on('change', function(e) {
  var desc = $(this).find(":selected").data('desc');

// Reset the image
$('#reset-btn').on('click', function() {
  ctx.globalCompositeOperation = 'source-over';
  ctx.drawImage(img, 0, 0, 600, 400);

var TWO_PI = 2.0 * Math.PI;
var radius = 20;

var mouseDown = false;
var mouseMoving = false;
var mouseX, mouseY;

function drawCircle(x, y) {
  ctx.arc(x-offset.left, y-offset.top,radius,0, TWO_PI);

$canvas.on('mousedown touchstart', function(e) {  
  mouseDown = true;
  return false;

$canvas.on('mouseup touchend', function(e) {
  mouseDown = false;
  return false;

$canvas.on('mousemove touchmove', function(e) {
  if (mouseDown) {
    ctx.globalCompositeOperation = $('#blendmode').val();
    ctx.fillStyle = $('#color-picker').val();

    mouseX = [];
    mouseY = [];
    if (Modernizr.touch) {
      var touches = e.originalEvent.changedTouches;
      for (var i in touches) {
    } else {
      mouseX[0] = e.clientX;
      mouseY[0] = e.clientY;
    for (var i=0; i<mouseX.length; i++) {
      drawCircle(mouseX[i], mouseY[i]);
  return false;

🕑 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 ..................