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.

              <p>This script loads jquery and the drawtools library from <a href="https://github.com/bronkula/drawtoolsjs/blob/master/draw.js">GitHub</a></p>
<p>Click and drag to test</p>

<canvas width="400" height="400"></canvas>
<div class="temp-change"></div>
              var cvs = $("canvas");
var ctx = cvs[0].getContext("2d");
var cvsW = cvs.width();
var cvsH = cvs.height();
var isDragging = false;
var originPos = false;

  .on("mousedown touchstart",function(e){
  // set the origin position
  originPos = getEventXY(e);
  // start dragging
  // draw an origin circle
  .on("mousemove touchmove",function(e){
  // cancel this function if not dragging
  if(!isDragging) return;
  var pos = getEventXY(e);
  // clear out the previous drawings
  // During the next few lines, if you switch the originPos with the pos values, you can get some drastically different results. Right now, this is keeping the position circle in a vertical line by using the originPos x.
  // draw the line in the back
  // then draw the origin circle
  // then draw the position circle
  // Draw the offset text
  // Round it, because on hidpi screens the number is a float.
  drawText(ctx,Math.round(originPos.y-pos.y),originPos.x-30,pos.y,{fillStyle:"gray",font:"16px verdana",textAlign:"right",textBaseline:"middle"})
  .on("mouseup touchend",function(e){
  var pos = getEventXY(e);
  // Write the offset amount
  $(".temp-change").html(Math.round(originPos.y-pos.y)+" Change to temperature")
  isDragging = false;
  originPos = false;
Loading ..................