Code Monkey home page Code Monkey logo

Comments (5)

claviska avatar claviska commented on May 26, 2024

Check the readme and the source of the demo. In the callbacks you have hex, rgb, and opacity. You can also use the opacity method mentioned in the readme.

On Sep 16, 2012, at 5:08 PM, Andy Fragen [email protected] wrote:

I'm having a problem in figuring out how to change for format of the returned value.

If opacity: true how can I get a return value for rgba(255, 255, 255, 0.5) or whatever value is now selected.

What I find is that the hex color is always returned and I really don't know how to get at the opacity or rgba values.

Is there some setting I'm not understanding for how to return a value in a specific format? I would think being able to specify the returned value as hex, rga or rgba would be ideal.

Help.


Reply to this email directly or view it on GitHub.

from jquery-minicolors.

afragen avatar afragen commented on May 26, 2024

I'm clearly not understanding what's in the readme and demo. I really have looked at them. Specifically, I want a generic miniColors picker to return the value as rgb ( or rgba if opacity: true).

Here's my init code.

jQuery(document).ready( function() { 
    jQuery(".color-picker").miniColors({
        opacity: true,
        change: function(hex, rgb, opacity) { }
    });     
});

It works fine for setting the hex value of multiple input tags. What I can't figure out is how to have it return the rgb value or rgba value.

from jquery-minicolors.

claviska avatar claviska commented on May 26, 2024

$('INPUT.colorPicker').miniColors({
opacity: true,
change: function(hex, rgb, opacity) {
var rgba = 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + opacity + ')';
console.log(rgba);
}
});

It's likely that I'll update the rob argument to include the opacity as rgb.a, but until then you can use opacity instead.

On Sunday, September 16, 2012 at 6:58 PM, Andy Fragen wrote:

I'm clearly not understanding what's in the readme and demo. I really have looked at them. Specifically, I want a generic miniColors picker to return the value as rgb ( or rgba if opacity: true).
Here's my init code.
jQuery(document).ready( function() {
jQuery(".color-picker").miniColors({ opacity: true, change: function(hex, rgb, opacity) { } });
});
It works fine for setting the hex value of multiple input tags. What I can't figure out is how to have it return the rgb value or rgba value.


Reply to this email directly or view it on GitHub (#29 (comment)).

from jquery-minicolors.

claviska avatar claviska commented on May 26, 2024

Download the latest update and check out the updated readme. I've merged the opacity argument with the RGB argument so you can access it like this. It seems to make more sense this way:

// Get RGBA values on change
$([selector]).miniColors({
    opacity: true,
    change: function(hex, rgba) {
        console.log('rgba(' + rgba.r + ', ' + rgba.g + ', ' + rgba.b + ', ' + rgba.a + ')');
    }
});

from jquery-minicolors.

afragen avatar afragen commented on May 26, 2024

OK, my problem solved, mostly. Here's what I did to get this working.

$([selector]).miniColors({
    opacity: true,
    change: function(hex, rgba) {
        $(this).val('rgba(' + rgba.r + ', ' + rgba.g + ', ' + rgba.b + ', ' + rgba.a + ')');
    }
});

Opacity is great but I really need transparent. I guess it's back to my hybrid selection, unless miniColors will get a transparent checkbox option. ;-)

Cory, thanks for the help and this project is awesome!

from jquery-minicolors.

Related Issues (20)

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.