Pen Settings



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


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


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.


Auto Save

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.


                <canvas id='canvas'></canvas>
<span>Move the mouse to paint.<span>

     Move the mouse to paint.
     Click to change color.
     Double Click to clear the canvas.


                @import "compass/css3";

@import url(;

body { 
  overflow: hidden;
  font-family: 'Give You Glory', cursive;
  font-size: 40px;
  &:hover {
   span {
      display: none; 

span {
 position: fixed; 
  top: 50%;
  left: 50%;
  color: #000;
  margin-top: -40px;
  margin-left: -227px;


                // Oil Painting
// Ported from flash project -
function OilPainting(){
  var canvas;
	var context;

	var width;
	var height;

	var startPos = {x: window.innerWidth/2, y: window.innerHeight/2};
	var prevPos = {x: window.innerWidth/2, y: 0};
	var dist = {x: 0, y: 0};
	var colour = '#'+Math.floor(Math.random()*16777215).toString(16);
	this.initialize = function(){
		canvas  = document.getElementById("canvas");
		context = canvas.getContext('2d');
		width = window.innerWidth
		height = window.innerHeight
		canvas.width = width;
		canvas.height = height;
		canvas.addEventListener('mousemove', MouseMove, false);
		canvas.addEventListener('click', MouseDown, false);
		canvas.addEventListener('dblclick', MouseDbl, false);	
	var MouseMove = function(e) {
		var distance = Math.sqrt(Math.pow(prevPos.x - startPos.x, 2) +
								 Math.pow(prevPos.y - startPos.y, 2));
		var a = distance * 10 * (Math.pow(Math.random(), 2) - 0.5);
		var r = Math.random() - 0.5;
		var size = (Math.random() * 15) / distance;
		dist.x = (prevPos.x - startPos.x) * Math.sin(0.5) + startPos.x;
		dist.y = (prevPos.y - startPos.y) * Math.cos(0.5) + startPos.y;
		startPos.x = prevPos.x;
		startPos.y = prevPos.y;
		prevPos.x = (e.layerX);
		prevPos.y = (e.layerY);
	   // ------- Draw -------
	   var lWidth = (Math.random()+20/10-0.5)*size+(1-Math.random()+30/20-0.5)*size;
	   context.lineWidth = lWidth;
	   context.strokeWidth = lWidth;
	   context.lineCap = 'round';
	    context.lineJoin = 'round';
	   context.moveTo(startPos.x, startPos.y);
	   context.quadraticCurveTo(dist.x, dist.y, prevPos.x, prevPos.y);
	   context.fillStyle = colour;
	   context.strokeStyle = colour;
	   context.moveTo(startPos.x + a, startPos.y + a);
	   context.lineTo(startPos.x + r + a, startPos.y + r + a);
	var MouseDown = function(e) {
		colour = '#'+Math.floor(Math.random()*16777215).toString(16);
		context.fillStyle = colour;
	    context.strokeStyle = colour;
	var MouseDbl = function(e) {
		context.clearRect(0, 0, width, height);

var app = new OilPainting();