view doodle/tk/color.d @ 100:a274d16ab6ce

struct initialisers
author David Bryant <bagnose@gmail.com>
date Mon, 18 Oct 2010 18:10:02 +1030
parents 535bae7a7305
children 523269b36711
line wrap: on
line source

module doodle.tk.color;

struct Color {
    static immutable Color DEFAULT = Color(0.0, 0.0, 0.0, 1.0);

    this(in double r, in double g, in double b, in double a) {
        // XXX how to deal with out of range? Clamp/assert
        _r = r;
        _g = g;
        _b = b;
        _a = a;
    }

    // TODO
    // hsv, grey, etc.

    double r() const { return _r; }
    double g() const { return _g; }
    double b() const { return _b; }
    double a() const { return _a; }

    private {
        double _r, _g, _b, _a;
    }
}