Giter Club home page Giter Club logo

colorpicker's Introduction

colorPicker and colors

An advanced, fast and small (45.4KB, 19.5KB gZip) JavaScript (framework independent) color picker (color chooser) that uses only one javaScript (x.min.js) file, so no extra HTML, CSS, images, etc... on IE9+ and internet browsers.

ColorPicker works in all browsers incl. IE6+ (an extra CSS has to be made to make it work in IE6 though and some additional setTimeout tricks to make it work in IE5.5)
colorPicker.js uses colors.js, a small but comprehensive tool for color conversions / calculations (WCAG 2.0, contrast, color difference, layer mix, etc.)...

With colors.js (~8.7k or way smaller if other color spaces and complex calculations are taken out...) you can also build your own simpler and / or smaller color pickers quite easy as demonstrated on the demo page.
colors.js can convert 182 different combinations of color spaces (rgb2HSV, RGB2hsl, rgb2RGB, HEX2Lab, ...)

If you like it, don't be shy to click the ★ Star button ;o)

Now with new implementations for JavaScript and jQuery

Demo & integration

See demo at dematte.at/colorPicker or check out a simple jQuery integration at dematte.at/colorPicker/jQuery_implementation and jQuery_implementation/jqColor.js or the javaScript implementation at dematte.at/colorPicker/javaScript_implementation and javascript_implementation/jsColor.js

If you put the scripts in the header of your document and try to initialize right away, please make shure that you wrap it in some kind of document.ready wrapper or just put the scripts on the bottom of your document.

All the WCAG 2.0 calculations for readability are also based on opacity levels of all layers
Supported color spaces are: (* also displayed as colors in realtime)
rgb *, hsv(b) *, hsl *, cmyk, cmy, Lab, XYZ, HEX

Description of files

  • colors.js - the color calculation library
  • colorPicker.data.js - HTMLS / CSS and images used by the UI
  • colorPicker.js - the UI (but not the implementation)

Those three files are used to build the color picker UI and calculate colors as you use it from the UI or from outside, just like shown on the demo page. colors.js doesn't have any dependencies and can be used standalone to build your own color picker or some other app... Those 3 files are combined and minified in a file named: color.all.min.js

If you want to use colorPicker as a plugin that opens on clicks on input fields, remembers colors and it's current size etc. then you need to additionally use the implementations, either

  • javascript_implementation/jsColor.js or
  • jQuery_implementation/jqColor.js

This is all seperated so you can write your own implementations if you have any special requirements not covered by those quite experimental implementations...

Those folders also include a 'whole package' file so you can go for only one file and don't need to include the others:

  • jsColorPicker.min.js
  • jQueryColorPicker.min.js

Those include colors.js, colorPicker.data.js, colorPicker.js and either jsColor.js or jqColor.js depending of which implementation you chose.

colors.js

var myColors = new Colors({ // all options have a default value...
    color: 'rgba(204, 82, 37, 0.8)', // initial color (#RGB, RGB, #RRGGBB, RRGGBB, rgb(r, g, b), ...)
    XYZMatrix: ..., // Observer = 2° (CIE 1931), Illuminant = D65  --- see source for dedtails
    XYZReference: ..., // back reference to XYZMatrix --- see source for dedtails
    grey: {r: 0.298954, g: 0.586434, b: 0.114612}, // CIE-XYZ 1931
    luminance: {r: 0.2126, g: 0.7152, b: 0.0722}, // W3C 2.0
    valueRanges: {rgb: {r: [0, 255], g: [0, 255], b: [0, 255]}, hsv:...}, // skip ranges if no conversion required
    customBG: '#808080' // the solid bgColor behind the chosen bgColor (saved color)
    convertCallback: function(colors, type){}, // callback function after color convertion for further calculations...
    toString: function('rgb' || 'hsl' || 'hex' || '' -> 'rgb', forceAlpha) {},
    allMixDetails: false // if set to true, Colors deliveres some more mixed layer informations for all color layers
});

colorPicker.js

colorPicker uses an instance of Colors and passes the options to it, so some values are the same:

var myColorPicker = new ColorPicker({
    color: ..., // see Colors...
    mode: 'rgb-b', // initial mode the color picker is starting with
    fps: 60, // the framerate colorPicker refreshes the display if no 'requestAnimationFrame'
    delayOffset: 8, // pixels offset when shifting mouse up/down inside input fields before it starts acting as slider
    CSSPrefix: 'cp-', // the standard prefix for (almost) all class declarations (HTML, CSS)
    size: 0, // one of the 4 sizes: 0 = XXS, 1 = XS, 2 = S, 3 = L (large); resize to see what happens...
    allMixDetails: true, // see Colors...
    alphaBG: 'w' // initial 3rd layer bgColor (w = white, c = custom (customBG), b = black);
    customBG: '#808080' // see Colors...
    noAlpha: true, // disable alpha input (all sliders are gone and current alpha therefore locked)
    cmyOnly: false, // display CMY instead of CMYK
    memoryColors: [{r: 100, g: 200, b: 10, a: 0.8}, ...] // array of colors in memory section
    opacityPositionRelative: undefined, // render opacity slider arrows in px or %
    customCSS: undefined, // if external stylesheet, internal will be ignored...
    appendTo: document.body, // the HTMLElement the colorPicker will be appended to on initialization
    noRangeBackground: false, // performance option: doesn't render backgrounds in input fields if set to false
    textRight: false, // not supported yet. Make numbers appear aligned right
    noHexButton: false, // button next to HEX input could be used for some trigger...
    noResize: false, // enable / disable resizing of colorPicker
    noRGBr: false, // active / passive button right to RGB-R display. Disables rendering of 'real' color possibilities...
    noRGBg: false, // same as above
    noRGBb: false, // same as above
    CSSStrength: 'div.', // not in use
    XYZMatrix: ..., // see Colors...
    XYZReference: ..., // see Colors...
    grey: ..., // see Colors...
    luminance: ..., // see Colors...
    devPicker: false // uses existing HTML instead of internal template for developing
    renderCallback: function(colors, mode){}, // callback on after rendering (for further rendering outside colorPicker)
    actionCallback: function(e, action){}, // callback on any action within colorPicker (buttons, sliders, ...)
    convertCallback: function(colors, type){}, // see Colors...
});

The color model, the methods and more

After initializing Color or ColorPicker you'll get a clean but rich model of the instance:

myColors: {
    colors: { all kinds of color values...  see later},
    options: { all the options you set or that are set as default... },
    __proto__: { // all methods Color uses
        setColor: function(newCol, type, alpha) {},
        getColor: function(type) {},
        setCustomBackground: function(col) {},
        saveAsBackground: function() {},
        convertColor: function(color, type) {} // String type: 'rgb2HSL';... converts 182 different combinations
    }
}
myColorPicker: {
    color: { // instance of Color inside colorPicker
        colors: { all kinds of color values... see later},
        options: { all the options you set or that are set as default... },
        __proto__: { all methods Color uses ... see above}
    },
    nodes: { all kinds of cashed nodes, textNodes and styles, etc... },
    __proto__: { // all methods ColorPicker uses
        setColor: function(newCol, type, alpha, forceRender) {},
        startRender: function(oneTime) {},
        stopRender: function() {},
        setCustomBackground: function(col) {}, // 3rd layer solid bg-color
        saveAsBackground: function() {}, // save current color as bg-color to compare
        setMode: function(mode) {},
        renderMemory: function(memory) {}, // dynamically manipulate memory squares
        destroyAll: function() {}
    }
}

The klass ColorPicker has some functions attached, used inside, exported for convenience...

ColorPicker.addEvent = function(obj, type, func){}; // with built in cashe
ColorPicker.removeEvent = function(obj, type, func){};
ColorPicker.getOrigin = function(elm){};
ColorPicker.limitValue = function(value, min, max){};
ColorPicker.changeClass = function(elm, cln, newCln){}; // a bit tricky to use...

If allMixDetails in options is set to true you'll get the following color model

HEX: // current color as HEX (upper case, 6 digits)
rgb: // current RGB color as normalized values (0 - 1)
    r: // red
    g: // green
    b: // blue
hsv: // current color values in normalized HSV (HSB) model
    h: // hue
    s: // saturation
    v: // value (brightness)
hsl: // current color values in normalized HSL model
    h: // hue
    s: // saturation
    l: // lightness
cmy: // current color values in normalized CMY model
    c: // cyan
    m: // magenta
    y: // yellow
cmyk: // current color values in normalized CMYK model
    c: // cyan
    m: // magenta
    y: // yellow
    k: // black
Lab: // current color values in normalized CIE 1976 L* a* b* (or CIELAB) model
    L: // lightness
    a: // color-opponent dimension
    b: // color-opponent dimension
XYZ: // current color values in normalized CIE 1931 XYZ model
    X: // mix (a linear combination) of cone response curves (LMS)
    Y: // luminance
    Z: // quasi-equal to blue stimulation (S)
RND: // all above colors in their defined ranges
    rgb: // current RGB color, rounded between 0 and 255
        r: // red (0 - 255)
        g: // green (0 - 255)
        b: // blue (0 - 255)
    hsv: // see above
        h: // hue (0 - 360 degrees)
        s: // saturation (0 - 100 %)
        v: // value (brightness) (0 - 100 %)
    hsl: // see above
        h: // hue (0 - 360 degrees)
        s: // saturation (0 - 100 %)
        l: // lightness (0 - 100 %)
    cmy: // see above
        c: // cyan (0 - 100 %)
        m: // magenta (0 - 100 %)
        y: // yellow (0 - 100 %)
    cmyk: // see above
        c: // cyan (0 - 100 %)
        m: // magenta (0 - 100 %)
        y: // yellow (0 - 100 %)
        k: // black (0 - 100 %)
    Lab: // see above
        L: // lightness (0 - 100 %)
        a: // color-opponent dimension (-128 - 127)
        b: // color-opponent dimension (-128 - 127)
    XYZ: // see above (values might be slightly above 100, dependent on matrix)
        X: // mix (a linear combination) of cone response curves (LMS) (0 - 100)
        Y: // luminance (0 - 100)
        Z: // quasi-equal to blue stimulation (S) (0 - 100)
background: // saved (background) color (saveAsBackground(){})
    rgb: // color in RGB model
        r: // red
        g: // green
        b: // blue
    RGB: // RGB color, rounded between 0 and 255
        r: // red (0 - 255)
        g: // green (0 - 255)
        b: // blue (0 - 255)
    alpha: // alpha or opacity value (0 - 1)
    equivalentGrey: // r = g = b = (0 - 255)
    rgbaMixBlack: // saved (background) color mixed with solid black color
        r: // red
        g: // green
        b: // blue
        a: // resulting alpha or opacity value (0 - 1)
        luminance: // luminance of resulting mix (0 - 1)
    rgbaMixCustom: // saved (background) color mixed with custom (solid) color
        r: // red
        g: // green
        b: // blue
        a: // resulting alpha or opacity value (0 - 1)
        luminance: // luminance of resulting mix (0 - 1)
    rgbaMixWhite: // saved (background) color mixed with solid white color
        r: // red
        g: // green
        b: // blue
        a: // resulting alpha or opacity value (0 - 1)
        luminance: // luminance of resulting mix (0 - 1)
alpha: // alpha or opacity value (0 - 1) of current color
equivalentGrey: // r = g = b = (0 - 1)
HUELuminance: // luminance of hue (in full brightnes and saturation) (0 - 1)
RGBLuminance: // luminance of the current color
hueRGB: // rounded integer value of current color in rgb model with full saturation and brightness
    r: // red (0 - 255)
    g: // green (0 - 255)
    b: // blue (0 - 255)
saveColor: // '' or 'web smart' or 'web save', if so.
webSave: // closest web-save color
    r: // red (0 - 255)
    g: // green (0 - 255)
    b: // blue (0 - 255)
webSmart: // closest web-smart color
    r: // red (0 - 255)
    g: // green (0 - 255)
    b: // blue (0 - 255)
rgbaMixBG: // color mix result: current color above saved (background) color
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
rgbaMixBGMixBlack: // color mix result: current color above saved (background) color above solid black
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
    luminanceDelta: // luminance difference between current color and resulting saved-black mix (0 - 1)
    hueDelta: // hue difference between current color and resulting custom-black mix (0 - 1)
    WCAG2Ratio: // readability vale (1 - 21, 1:1 to 21:1)
rgbaMixBGMixCustom: // color mix result: current color above saved (background) color above solid custom color
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
    luminanceDelta: // luminance difference between current color and resulting saved-custom mix (0 - 1)
    hueDelta: // hue difference between current color and resulting saved-custom mix (0 - 1)
    WCAG2Ratio: // readability vale (1 - 21, 1:1 to 21:1)
rgbaMixBGMixWhite: // color mix result: current color above saved (background) color above solid white
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
    luminanceDelta: // luminance difference between current color and resulting saved-white mix (0 - 1)
    hueDelta: // hue difference between current color and resulting saved-white mix (0 - 1)
    WCAG2Ratio: // readability vale (1 - 21, 1:1 to 21:1)
rgbaMixBlack: // color mix result: current color above solid black
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
    WCAG2Ratio: // readability vale (1 - 21, 1:1 to 21:1)
rgbaMixCustom: // color mix result: current color above solid custom color
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
    WCAG2Ratio: // readability vale (1 - 21, 1:1 to 21:1)
rgbaMixWhite: // color mix result: current color above solid white
    r: // red (0 - 1)
    g: // green (0 - 1)
    b: // blue (0 - 1)
    a: // resulting alpha or opacity value (0 - 1)
    luminance: // luminance of resulting mix (0 - 1)
    WCAG2Ratio: // readability vale (1 - 21, 1:1 to 21:1)

colorpicker's People

Contributors

lafsar avatar madewithlinux avatar pitpik avatar t-mw avatar tmcw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorpicker's Issues

[Suggestion] Please make a simple example on vanilla JS and some explaination

I'm trying to implement this in my project and found it a bit difficult to work with.

I was expecting to link ONE js file and ONE css file, give it an initialization and I'm good, but I'm getting some errors, I have no idea

colorPicker.js?ver=4.2.2:17 Uncaught TypeError: Cannot read property 'style' of null

a problem on how you finished your demo

hi, your work is just what I want to use in my page. The examples you show seems difficult for me to understand. Could you tell me the demo on the right one you show is just finished with colors.js? Or could you provide me with a more detail documentation. Thanks!

How initialize colorPickers without clicking on element

Hello!
Thank you for great job!
In my project i use yours colorPicker from jsColorPicker.min.js.
Can you tell, how initialize window.jsColorPicker.colorPickers objects without clicking on input element?
Is there some method wich need to call and how it call?

[Question] Hook into color update?

I was searching your doc and cound't find any clue, basically what I'm after is similar to

init: function(elem,colors){
//do some stuff
}

Yes, there is this

actionCallback: function(e,action) {}

But I don't know what are those function attributes for.

So yes, I would need to do some stuff on update.

Thanks so much.

allMixDetails: false not working

When I try to set allMixDetails: false, the whole script just stops working. I tried to set it both on my page and in the colorPicker.js. I get the same result. I am trying to get the size 3 window to show up without the extra color details/buttons on the right, so the UI is bigger on the mobile displays! Can you pls help me!?

Setting Memory Colours programatically

Hi

First of all, thanks for the amazing colour picker, it's got all the features I need (and more) which can't be said for others. But I was hoping you could help me out with something.

I am initialising the plugin using JQuery as so

$('#addNewColourInput').colorPicker({ memoryColors: ff.global.memoryColors, actionCallback: actionCallback )};

which works fine, but I am trying to add new memory colours after a selection has been made. I was hoping to keep my own list of colours and then just reset the memory colours object when I need to, however, I'm haping trouble doing this. Could you supply a snippet showing how I can set the memoryColours? If this isn't possible then how else could I achieve this?

Thank you for your time.

Error

TypeError: document.body is null
_doesOpacity = typeof document.body.style.opacity !== 'undefined',

Questions about stability and use

Hello.

I am interested in use this library in a javascript library for color themes that I am developing. I have this questions:

  • Which is the license of this project? I think that is double licensed as the 0.9 version, but I am not sure. If this is correct I can use this project only indicating that this project has the MIT license, no?
  • How can I use this project? I suppose that it can be used like previous versions, but examples use jQuery and I think that it is not necessary. Can it be used like previous versions (http://www.dematte.at/colorPicker)?
  • Finally, I want to know how much stable is this version, because I want to finish my project soon.

Thank you very much!

Initial set the color of the inputs

Why are the input backgrounds not set when you initialize the color picker? You even do this manually in your examples. Seems like 90% of people usi
ng this library would want that to be the default.

This code is taken from this example.

var $colors = $('input.color').colorPicker({
    customBG: '#222',
    readOnly: true,
    init: function(elm, colors) { // colors is a different instance (not connected to colorPicker)
      elm.style.backgroundColor = elm.value;
      elm.style.color = colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd';
    }
  }).each(function(idx, elm) {
        // $(elm).css({'background-color': this.value})
    });

[question] + [suggestions]

  • do you consider developing a palettes generator? (10 shims, complimentary, see here what I mean/like)
  • Don't waste time with jQuery!!
  • currently has the option to exclude rgba?

Thanks!!

Android web views and Chrome bad rendering

Chrome for Android does not implement completely background-position. Therefore, color picker is rendered bad as can be seen in the attached image. Maybe the problem is not background-position, but I have deduced it because debugging Android web view in Chrome for desktop the color picker is shown correctly in the desktop and bad in the mobile.

I only have tried JavaScript implementation, but I suppose that the issue also happens in jQuery implementation.

Thanks.

colorpicker_android_issue

jqColor repeat call renderCallback

i console.log in renderCallBack it will repeate output when click one time in color picker area.

for prevent repeart call renderCallback. I write a bad code:

.....
    $.fn.extend({
        colorPicker: function(config) {
            var timestamp = new Date().getTime();
            var renderCallback = function(colors, mode) {
                    if(Date.now() - timestamp < 500){
                        return;
                    }else{
                        timestamp = Date.now();
                    }
.....

Is there any good way to solve it?

Reset all pickers with a single button click [jQuery version]

Hi,

I'm using the jQuery version and have multiple pickers on the page, like:

var cp_picker = cp_input.colorPicker({ ... }),
cp_picker2 = cp_input2.colorPicker({ ... }),
...

Then I would like to add a <input type="button" ... /> at the bottom of the page to reset all these pickers to their default colors.

How this can be acheived please ?

Weird bugs in jQuery implementation

If I write this:

$('input.color').colorPicker();

colorPicker throws an error (Cannot read property 'customBG' of undefined (looks like it always require a config object)). If I pass any object, even

$('input.color').colorPicker({});

It throws another error (undefined is not a function). This points to function "convertColors", at this line (217 in colors.js file):

colors[typ] = convert[from + '2' + typ](colors[from]);

What should we do??

Typing mistake (appendTo property)

Hi, the "appendTo" property cannot works because of a typing error :

jsColor.js - line 118

(options.appenTo || document.body).appendChild(colorPickerUI);

Just replace "appenTo" by "appendTo" to fix it. :)

Verticle Stretching on first use

So on the first use of the jquery implementation color picker it stretches vertically and then resizes.
This only happens on firefox as far as I can tell.

This happens on your demo page also:

Demo Page Issue

Is it possible to stop this behavior somehow?

potential failures with "document"

Hi,
First of all: thanks for this great color picker.

I think there are some potential failures if using it in an sandbox or across an iframe.
Because:

"window" is passed to "ColorPicker", but inside, it uses directly "document"
If we look at the code of jquery, it set "document" with:
var document = window.document;
So, "ColorPicker" must also set it from the beginning of the code.
Otherwise, it uses the current "window.document" and not the "document" of the provided "window".

I don't take time to write a test code, I only analyse the code.

Thanks again,
ARuben

appendTo different from document.body causes wrong placement using jsColorPicker

If I pass jsColorPicker() an appendTo element that is different from document.body and does is not placed at (0,0), the created color picker popup will be placed in an offset from where its supposed to be, the same offset the appendTo element is from (0,0)
The fix is (jsColor.js)
line 109: add
var atrect = (options.appendTo || document.body).getBoundingClientRect();

line 112:
'left:' + (position.left + options.margin.left - atrect.left) + 'px;' +
'top:' + (position.top + +input.offsetHeight + options.margin.top - atrect.top) + 'px;';

Cursor goes to wrong position when scroll

I'm using the colorwheel picker from the demo page, and I came up with a problem. When I add text above the color wheel, then scroll down and change the colorwheels color, the colorwheels cursor isn't contained in the actual circle. (It makes an imaginary circle in another place, and the colorwheels cursor is constrained in that imaginary circle.)

Another issue, which might be related to the first one is that if you zoom up in the browser, (in chrome: ctrl +) the colorwheels cursor stays position like a fixed element, it follows the scrolling.

How can I get the colorwheels cursor to always stay in the circle?

I think the relevant code is the function of getOrigin

JSFiddle

More implementation examples

To make it easier for developers to use colorPicker there should be some little 'kick-start' scripts to implement colorPicker such as: $('.color').choseColor(); that also appends/places colorPicker at the right spot (maybe also drag&drop,...) with minimum afford. This script should also contain memory functionality (such as cookies or web-storage) for saved memory-colors, app-size, last used mode, etc...

How to use setColor? Can't find examples, can't figure it out

Hey, I like your plugin, and I want to use it in a package I'm writing in R (programming language). One thing I can't figure out is how to set the color of an existing input? I see that you can somehow "extend" with proto, but I can't figure out - can you show an example?

Gradients Suggestion

The color picker is amazing. Lightning fast, simple to use. I have over 200 running on one page and performance is fine (its why I coudn't use Spectrum - too heavy).

I'd like to let the user build a gradient somehow using this color picker. I know I can just give them multiple pickers and build a gradient from the two colors, but how cool would it be if the picker had gradients built in, where you could add gradient breaks and everything. I think something like https://github.com/greggman/gradient-editor combined with this would be awesome.

Any advice before I start?

Support webcomponents

Hi,

I've been searching for a simple, lightweight color picker written in vanilla javascript for ages and gladly I've found your colorPicker. However, no matter how hard I try I can't initalize your color picker on inputs wrapped in Google Polymer components. No errors, no output on the console.

Would you please guide me on how to bind the colorPicker to inputs in components if there's a way to do that?

Bug with colors without hue.

Hello.

I have tested new version with init color text in function of luminance and this funcionality works very well.

However, picker is not shown in some inputs until you enter in another input with hue, picker is shown for this input and then is shown for whatever. I think that this issue happens with colors without hue (blacks, whites and greys).

If I have not explained well, here are the steps done in tests:

  • Select black input. -> Picker is not shown
  • Select white input. -> Picker is not shown
  • Select grey input. -> Picker is not shown
  • Select blue input. -> Picker is shown perfectly
  • Select black input. -> Picker is shown perfectly
  • Select white input. -> Picker is shown perfectly
  • Select grey input. -> Picker is shown perfectly

Thank you very much and congratulations for your great work. I hope these issues were more helpful than painful :)

transfer _bgs.png into _horizontal.png

Make alpha background (256px and 128px) and rasters for memory patches (256px and 128px) part of _horizontal.png (at the end) and make according changes in colorPicker.css

transparent cursor for IE11

function 'buildView' replaces _data._cssMain with IE specific stuff: also replace('_blank.png', !_isIE ? ... gets replaced which is probably not valid for IE11

WebGL support idea

Hello. I suggest to add webgl support. I also made low-level utility (color-nuker project) that can be helped with coordinates and visualization. I have too many combinations and forms by pure webgl. I enabled anti-aliasing, triangle and etc...

Initial text color of input in javascript implementation

When your click in input to show picker, the CSS color of input is changed in function of the luminance of its background-color. However, before click text color is always black instead of being correct color in function of luminance.

Correcting it would be great and low-cost I think.

Thanks and congratulations, the picker is really good!

Is it supported by mpbile device?

hi.
could you tell me how can I let it can work well in the mobile device? I have tried but failed. Maybe I initialized it in a way way. Could you tell me the right way? Thanks.

Erroron bower

I am getting the following error when I do a bower install

Error Message: enotfound package colorPicker not found

positionCallback

does this colorpicker have a positionCallback, or only the tiny version??

Documentation

There has to be more documentation for the API and usage for developers and end-users.

Two separate repository for color.js and colorPicker.js

Hey there! Really like this color picker!! (Though it would be a lot nicer with docs. As mentioned earlier.)

I just want to make a suggestion. I think you should separate the colorPicker.js and color.js in two separate (I think it's called) repository. (Just like brgins did with spectrumColorPicker and tinyColor.) This way if someone would like to just use color.js, it would be easier to access, and would have its own documentation.

How to set color?I use html input

I use html input

input class="color no-alpha" value="#B6BD79" id="color1"/

$('#color1').val("#FF0000");
use the code can change the color code, but the background color do not change

Could someone know how to set color for html input with color-class?

How to access colorPicker object?

From your jQuery example:

$myColorPicker = $('input.color').colorPicker({
		customBG: '#222',
		readOnly: true,
		init: function(elm, colors) { // colors is a different instance (not connected to colorPicker)
			elm.style.backgroundColor = elm.value;
			elm.style.color = colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd';
		},
		// appendTo: document.querySelector('.the-paragraph')
		// renderCallback: function(colors, mode) {
		// 	console.log(mode);
		// }
		// memoryColors: memoryColors,
		// actionCallback: function(event, type) {
		// 	if (type === 'toMemory') {
		// 		// $myColorPicker.renderMemory(memoryColors);
		// 	}
		// }
	}).each(function(idx, elm) {
		// $(elm).css({'background-color': this.value})
	});

I would think doing console.log($myColorPicker) would return the instance of the colorPicker - but it is returning an array. How do I access the colorPicker object (so I can access it's methods, setColor, etc..)?

Thanks!

Add Lab Color Sliders not working

When I add Lab divs in the html in index.html (from the documentation page), the JavaScript should create the sliders and everything in the renderColorSliders function. But run it and try it out, the Lab color sliders don't move.

I think the problem is at line 118 (in the codePen bellow), or it's on line 102.

Here's a code sample of what I mean:

CodePen

Plugin crashes when js files are called from html's head tag instead of body

All in the title. Although, I only tested the jQuery version, not the simple JS version

This doesn't work and return the following error: Uncaught TypeError: Cannot read property 'style' of null jQueryColorPicker.min.js:3:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link href="jqColor.css" media="all" rel="stylesheet" type="text/css" />
        <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
        <script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
        <script type="text/javascript" src="jQueryColorPicker.min.js"></script>
        <script type="text/javascript" src="main.js"></script>
    </head>
    <body>
    </body>
</html>

main.js is where I do cp_picker = new ColorPicker({...}) on DOM ready.

On the other hand, this works great:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link href="jqColor.css" media="all" rel="stylesheet" type="text/css" />
        <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
        <script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
    </head>
    <body>
        <script type="text/javascript" src="jQueryColorPicker.min.js"></script>
        <script type="text/javascript" src="main.js"></script>
    </body>
</html>

Where could be the problem please ?

simple jsFiddle with realistic example

Hi @PitPik,

first of all: Thanks for your work! Your colorPicker looks amazing.
Perhaps i dont get it and its the wrong Picker for my scenario, so please dont mind if i didnt understand your intention.

I looked at your examples and the demo page but i still dont get it.

This is what i try to get:
You have a button which opens the colorPicker on click.
It can have an initial color (eg by comming from a database or cookie).
When you change the color with the picker i want to execute a function (eg. an ajax call or a function which updates styles of some elements with the new color).
But i still dont get how to initialize it neighter how to listen to events.

Can you provide a simple jsFiddle?

Kind regards

ColorWheel Picker from doc

I'm trying to get the colorWheel picker on it's own, i.e. without the other color picker; from the documentation file. What should I delete? (Maybe you can send me the final files using dropbox, or fileDropper.)

Convert Color

How can I make a simple conversion? Say from HSV to HSL?

I tried the following:

var myColor = new Colors();
var hslColor = myColor.convertColor({
    h: 100,
    s: 100,
    v: 100
},'hsv2hsl')
console.log(hslColor);

And I get the folloinwg output:

Object {h: 100, s: -1.0204081632653061, l: -4900}

How can I get regular output?

Z-index of color picker in javascript implementation

Color picker can be hidden by other elements because it hasn't z-index CSS property. This can be easily resolved adding this rule to line 12 of index.css :):

.cp-app {
position: relative;
float: left;
margin: 10px 0 0 10px;
z-index: 15000;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.