@@ -2042,6 +2042,50 @@ static int glyph_available (lua_State *L)
2042
2042
2043
2043
} // end of glyph_available
2044
2044
2045
+ extern COLORREF xterm_256_colours [256 ];
2046
+
2047
+ static int colourcube (lua_State *L) {
2048
+ int which = luaL_checknumber (L, 1 );
2049
+ int red, green, blue;
2050
+ const BYTE values [6 ] = {
2051
+ 0 ,
2052
+ 95 ,
2053
+ 95 + 40 ,
2054
+ 95 + 40 + 40 ,
2055
+ 95 + 40 + 40 + 40 ,
2056
+ 95 + 40 + 40 + 40 + 40
2057
+ };
2058
+ const BYTE colour_increment = 255 / 5 ; // that is, 51 (0x33)
2059
+
2060
+ switch (which)
2061
+ {
2062
+
2063
+ case 1 : // Xterm colour cube (the default - favours brighter colours)
2064
+ for (red = 0 ; red < 6 ; red++)
2065
+ for (green = 0 ; green < 6 ; green++)
2066
+ for (blue = 0 ; blue < 6 ; blue++)
2067
+ xterm_256_colours [16 + (red * 36 ) + (green * 6 ) + blue] =
2068
+ RGB (values [red], values [green], values [blue]);
2069
+
2070
+ break ;
2071
+
2072
+ case 2 : // Netscape colour cube - evenly spaced colour cube
2073
+ for (red = 0 ; red < 6 ; red++)
2074
+ for (green = 0 ; green < 6 ; green++)
2075
+ for (blue = 0 ; blue < 6 ; blue++)
2076
+ xterm_256_colours [16 + (red * 36 ) + (green * 6 ) + blue] =
2077
+ RGB (red * colour_increment,
2078
+ green * colour_increment,
2079
+ blue * colour_increment);
2080
+
2081
+ break ;
2082
+
2083
+ default : luaL_error (L, " Unknown option" );
2084
+ } // end of switch
2085
+
2086
+ return 0 ; /* no return */
2087
+ }
2088
+
2045
2089
#if 0
2046
2090
static int registry (lua_State *L)
2047
2091
{
@@ -2071,6 +2115,7 @@ static const struct luaL_Reg xmllib [] =
2071
2115
{" appendtonotepad" , appendtonotepad},
2072
2116
{" callbackslist" , callbackslist},
2073
2117
{" choose" , choose},
2118
+ {" colourcube" , colourcube},
2074
2119
{" directorypicker" , directorypicker},
2075
2120
{" edit_distance" , edit_distance},
2076
2121
{" editbox" , editbox},
0 commit comments