Class: Rixmap::Palette::WebSafe

Inherits:
Rixmap::Palette show all
Defined in:
src/rixmapcore.cxx,
src/rixmapcore.cxx

Overview

216色 ウェブセーフカラーパレットクラス.

Instance Method Summary collapse

Methods inherited from Rixmap::Palette

#==, #[], #[]=, #each, #export, #import!, #initialize_copy, #inspect, #map, #map!, #size, #to_a

Constructor Details

#initializeObject (private)

Rixmap::Palette::WebSafe {{{



1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
# File 'src/rixmapcore.cxx', line 1783

static VALUE WebSafePalette_initialize(VALUE self) {
    // 色要素
    static uint8_t _levels[6] = {0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF};

    // 216色パレット
    {
        VALUE args[1];
        args[0] = INT2FIX(216);
        rb_call_super(1, args);
    }

    // 色を設定
    Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self);

    int num = 0;
    for (int ri = 0; ri < 6; ri++) {
        for (int gi = 0; gi < 6; gi++) {
            for (int bi = 0; bi < 6; bi++) {
                _this->set(num++, Rixmap::Color(_levels[ri], _levels[gi], _levels[bi]));
            }
        }
    }

    // 凍結
    OBJ_FREEZE(self);

    return self;
}