cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmloctocatspinnerstartv

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.

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


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


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