<div class="picker" id="primary_block" > <div id="line"> <div id="arrows"> <div class="left_arrow"></div> <div class="right_arrow"></div> </div> </div> <div id="block_picker"> <img src="img/bgGradient.png" class="bk_img"><div id="circle"></div> </div> </div>
.right_arrow { width:0; height:0; left:23px; position:absolute; border-bottom:6px solid transparent; border-left:10px solid transparent; border-top:6px solid transparent; border-right:10px solid black; }// .circle { width:8px; height:8px; border:1px solid black; border-radius:50%; position:absolute; left:0; top:0; cursor: default; -moz-user-select: none; -khtml-user-select: none; user-select: none; -webkit-user-select: none; }
gradient: function(canva,w,h){ /* canva- canvas h - w- */ var context, gradient, hue; context = canva.getContext("2d"); gradient = context.createLinearGradient(w/2,h,w/2,0); hue = [[255,0,0],[255,255,0],[0,255,0],[0,255,255],[0,0,255],[255,0,255],[255,0,0]]; // hue rgb for (var i=0; i <= 6;i++){ color = 'rgb('+hue[i][0]+','+hue[i][1]+','+hue[i][2]+')'; gradient.addColorStop(i*1/6, color); }; context.fillStyle = gradient; context.fillRect(0,0, w ,h); }
HSV is a color model in which the color coordinates are:
Hue - color tone (for example, red, green or blue-blue). Varies in the range of 0-360 °, however, sometimes it is reduced to the range of 0-100 or 0-1.
Saturation - saturation. Varies in the range of 0-100 or 0-1. The larger this parameter, the “cleaner” the color, so this parameter is sometimes called color purity. And the closer this parameter is to zero, the closer the color is to neutral gray.
Value (color value) or Brightness - brightness. It is also set between 0-100 and 0-1.
var px_X = elem.clientWidth / 100; /* px . : 180 180/100 , 1 1,8; */ var S = left / px_X;// left "" (div c id = "circle") Math.round(S);//
hsv_rgb: function (H,S,V){ var f , p, q , t, lH; S /=100; V /=100; lH = Math.floor(H / 60); f = H/60 - lH; p = V * (1 - S); q = V *(1 - S*f); t = V* (1 - (1-f)* S); switch (lH){ case 0: R = V; G = t; B = p; break; case 1: R = q; G = V; B = p; break; case 2: R = p; G = V; B = t; break; case 3: R = p; G = q; B = V; break; case 4: R = t; G = p; B = V; break; case 5: R = V; G = p; B = q; break; } return [parseInt(R*255), parseInt(G*255), parseInt(B*255)]; }
Source: https://habr.com/ru/post/147032/