Re: [Vala] Convert RGB color value to HEX

Thanks for all the help. really grateful. Here is the code if someone wants
to review.

On Monday, September 3, 2012, Jonas Kulla wrote:

2012/9/3 Satyajit Sahoo <satyajit happy gmail com <javascript:;>>

Hi. I need to get color value in HEX in my vala program.

Basically, I get a color expression like this,

rgb(red, green, blue) or rgba(red, green, blue, alpha)

But I need to convert it into a format #rrggbb

I cannot seem to understand how to do it.

using Gtk;
using Gdk;

void main(string[] args)
    Gtk.init(ref args);

    var win = new Gtk.Window(Gtk.WindowType.TOPLEVEL);

    var b = new ColorButton();
    b.use_alpha = true;
    b.color_set.connect( (b) =>
        Gdk.RGBA c = b.get_rgba();
        string s =
        stdout.printf("%s\n", s);



Satyajit Sahoo
Blog - Funsurf <>
Profile - Facebook <>,
Twitter - @satya164 <>
Artwork - DeviantArt <>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]