DRAGCOLOR

https://github.com/Shopify/draggable#install http://madrobby.github.io/scriptaculous/draggable/ <rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" /> // coordinates https://jsfiddle.net/davidThomas/DGbT3/ https://jsfiddle.net/gabrieleromanato/MxYGZ/

by DOK_UA

HTML

<div id = "background">


 <div id="rotateable">
      <div id="rotate"></div>
  </div>

<div id="joy">
<p>Hi this is color.</p>
</div>

</div>

CSS

body {
  background: #282828;
}

#background{
  height: 300px;
  width: 300px;
  background-color: gray;
  position:absolute
}

#joy {
  margin:97px 0px 0px 97px;
  width:100px;
  height:100px;
  position: absolute;
  border-radius: 50%;
  background-color: hsl(0, 50%, 50%);
  border-style: solid;
  border-color:black;
  border-width:3px;
  

}

#rotateable,#rotate {
  width:300px;
  height:300px;
  position: absolute;
  border-radius: 50%;
  background: black;
}

p {
 color:red;
}

JavaScript

//try{  } catch(err){alert(err.message)

var H;
var S;
var V;

var newH = 0;
var newS = 0;
var newV = 0;

var ratio = 0.2;


var firstHsv = "hsl("+H+","+S+"%,"+V+"%)";


function setColor(hue,sat,vol)
{

}


$("div").mouseup(function(){
 	$("#rotate").css("background-color", firstHsv);
  $("#joy").css("border-width", 3);
  });
  $("div").mousedown(function(){
  if(H==NULL)
  {
  H=
  }
   $("#joy").css("border-width", 0);
	$("#rotate").css("background-color", firstHsv);
  });


$('#joy').draggable({ 
revert: 'invalid',
revertDuration: 100,
drag: function(event) {
//alert("helolo")
joyPoint = document.getElementById('joy'),
getJoyBounds = joyPoint.getBoundingClientRect();
center_x = ((getJoyBounds.left + getJoyBounds.right) / 2)-150,
center_y = 150-(getJoyBounds.top + getJoyBounds.bottom) / 2;

//разобратся в процентах от расположения
var percentSat = (150*center_x)/100/2;
var percentVol = (150*center_y)/100/2;

$("p").text(percentSat+" / "+percentVol+" / "+V);

var newSaturation = S+percentSat;
var newVolune = S+percentVol; 
var hsvChange = "hsl("+H+","+newSaturation+"%,"+newVolune+"%)";
  firstHsv = hsvChange;
$("#joy").css("background-color", hsvChange);

}
});
$('#rotateable').draggable({
  handle: '#rotate',
  opacity: 0.0001,
  helper: 'clone',
  drag: function(event) {
    var // get center of div to rotate
      pw = document.getElementById('rotateable'),
      pwBox = pw.getBoundingClientRect(),
    
      center_x = (pwBox.left + pwBox.right) / 2,
      center_y = (pwBox.top + pwBox.bottom) / 2,
      // get mouse position
      mouse_x = event.pageX,
      mouse_y = event.pageY,
      radians = Math.atan2(mouse_x - center_x, mouse_y - center_y),
      degree = Math.round((radians * (180 / Math.PI) * -1) + 100);
    
  // alert(mouse_x);
    var rotateCSS = 'rotate(' + (degree + 170) + 'deg)';
    $('#rotateable').css({
      '-moz-transform': rotateCSS,
      '-webkit-transform': rotateCSS
    });
  }
});