Color Picker (OF v0.8.4, VS 2012)

Hi guys,

I just created a simple color picker to use with any OF project.
Currently you can only pick two different colors, but it already fits its purpose on my projects.

If you wanna check, here it is: https://github.com/filipemsbaptista/Color-Picker

Hope it’s useful for you as well.

Cheers

Hy guy, thank you for share your work !

It’s a nice idea to create a simple color picker.

Your files are currently very heavy (more than 40 mo), and if you want to be more efficient and have more feedback, you have to look on the addons guidelines, so your work can be listed in the addons page.

http://www.ofxaddons.com/pages/howto

I might give you a little advice!
instead of an image,use a ofImage to draw the picking area:

something like that:

ofImage getPicker(float _w=250,float _h=250){
        float w=_w;
        float h=_h;
        float cx = w/2;
        float cy = h/2;

        p.allocate(w,h,OF_IMAGE_COLOR);
        for (float y=0; y<h; y++) {
            for (float x=0; x<w; x++) {
                float angle = atan2(y-cy,x-cy)+PI;
                float dist = ofDist(x,y,cx,cy);
                float hue = angle/TWO_PI*255;
                float sat = ofMap(dist,0,w/4,0,255,true);
                float bri = ofMap(dist,w/4,w/2,255,0,true);
            p.setColor(x,y,ofColor::fromHsb(hue,sat,bri));
            }
        }
        p.reloadTexture();
        return p;
}

I wish you good work :slight_smile:

Dario

Yeah your’re right, I simply pushed my whole folder to the repository and didn’t invested time in making it a proper addon.
But I’ll give it a look and fix that on my free time.
Thanks for the feedback!

I first tried to make a color picker that way but if you don’t have a 1:1 aspect ratio the color gradient doesn’t render well (its center is not actually the center of the area he occupies).
I could fix that by creating an 1x1 fbo inside the fbo reserved for the color picker display, but I found the ofImage a faster solution to implement (this was to use in a large scale project using OF so I really wanted to spend less time possible with the color picker :P)
But I’ll try to make that as well when I return to it.

Thanks for the response!

1 Like

He just wanted to be a little advice, what I built for ofxGLSLMaterial, use this technique, now I’m trying to hook this to ofxGui for the panel to drag.

Good Day and good work :slight_smile:
Dario

That color picker is really nice :smiley:
I’ll try to make that one as well when I return to GUI programming (I’m now trying to program for Kinect)
Thanks for sharing your work

Have a good day :slight_smile: