Divvil colorwheel

The Divvil colorwheel is a jQuery UI widget. It offers:
  • High-precision colorwheel
  • Fully responsive - user can resize on the fly
  • Standard jQuery UI behaviour
  • WebGL rendering with fallback
  • HSL, RGB and string input
  • Tested in Chrome, Firefox, IE9+, Safari, Edge
  • One .js and one .css, less than 8kb zipped
  • Nothing is rendered until the user opens the interface - minimal resource usage
  • MIT license
Try it: 


Download

Usage

There are two ways to add it: either as a button that brings up a popup, or you can insert the widget in your design.

Colorbutton

Apply it as a standard jQuery UI widget:

$('#myButton').colorbutton({color: '#30D030', dialogTitle: 'Choose color'});

Get or set the color:

var col = $('#myButton').colorbutton('color');
$('#myButton').colorbutton('color', col);

Options:

autofocusWhether to place keyboard cursor in string input
colorDefault color in the format #30D030
dialogHeightDefault dialog height
dialogTitleDialog title string
dialogWidthDefault dialog width
enableGLWhether to use WebGL (if available) for rendering
enableMouseWheelWhether to catch mouse wheel input on wheel and sliders
innerRadiusWheel inner radius as ratio of diameter (0-0.5)
maxDiameterMaximum wheel diameter
maxTimeMaximum uninterrupted render time for non-WebGL rendering

Callback:

changeTriggers when the color is changed (may be triggered a lot)
Example:
$('#myButton').colorbutton({change: function(ui, data) {$('body').css('background',data.color)}});

Colorwheel

$('#myWheel').colorwheel({color: '#30D030'});

Options:

autofocusWhether to place keyboard cursor in string input
changeCallback to trigger on change (see below)
colorDefault color in the format #30D030
enableGLWhether to use WebGL (if available) for rendering
enableMouseWheelWhether to catch mouse wheel input on wheel and sliders
innerRadiusWheel inner radius as ratio of diameter (0-0.5)
maxDiameterMaximum wheel diameter
maxTimeMaximum uninterrupted render time for non-WebGL rendering

Functions:

colorGet or set color
Example:
$('#myWheel').colorwheel('color', '#ABCDEF');

resizeRe-render a larger wheel if required, and force resizing on some browsers if the proportions of the container have changed

Callback:

changeTriggers when the color is changed (may be triggered a lot)
Example:
$('#myWheel').on('colorwheelchange', function(ui, data) {$('body').css('background',data.color)});