pike.git
/
src
/
modules
/
Image
/
colors.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/Image/colors.c:1:
/* **! module Image **! note
-
**! $Id: colors.c,v 1.
16
1999/05/
20
17:
07
:
00
mirar Exp $
+
**! $Id: colors.c,v 1.
17
1999/05/
23
17:
46
:
38
mirar Exp $
**! submodule Color **! **! This module keeps names and easy handling **! for easy color support. It gives you an easy **! way to get colors from names. **! **! A color is here an object, containing color **! information and methods for conversion, see below. **! **! <ref>Image.Color</ref> can be called to make a color object.
pike.git/src/modules/Image/colors.c:90:
**! This is the color object. It has six readable variables, **! <tt>r</tt>, <tt>g</tt>, <tt>b</tt>, for the <i>red</i>, **! <i>green</i> and <i>blue</i> values, **! and <tt>h</tt>, <tt>s</tt>, <tt>v</tt>, for **! the <i>hue</i>, <i>saturation</i> anv <i>value</i> values. */ #include "global.h" #include <config.h>
-
RCSID("$Id: colors.c,v 1.
16
1999/05/
20
17:
07
:
00
mirar Exp $");
+
RCSID("$Id: colors.c,v 1.
17
1999/05/
23
17:
46
:
38
mirar Exp $");
#include "config.h" #include <math.h> #include "stralloc.h" #include "pike_macros.h" #include "object.h" #include "constants.h" #include "interpret.h"
pike.git/src/modules/Image/colors.c:1424:
str_string=make_shared_string("string"); str_r=make_shared_string("r"); str_g=make_shared_string("g"); str_b=make_shared_string("b"); str_h=make_shared_string("h"); str_s=make_shared_string("s"); str_v=make_shared_string("v"); no_name=make_shared_string("");
+
/* make color object program */
+
start_new_program(); ADD_STORAGE(struct color_struct); set_init_callback(init_color_struct); set_exit_callback(exit_color_struct); /* color info methods */ ADD_FUNCTION("cast",image_color_cast,tFunc(tStr,tOr(tArray,tStr)),0); ADD_FUNCTION("`[]",image_color_index,tFunc(tOr(tStr,tInt),tOr(tInt,tFunction)),0);
pike.git/src/modules/Image/colors.c:1465:
ADD_FUNCTION("dark",image_color_dark,tFunc(,tObj),0); ADD_FUNCTION("neon",image_color_neon,tFunc(,tObj),0); ADD_FUNCTION("bright",image_color_bright,tFunc(,tObj),0); ADD_FUNCTION("dull",image_color_dull,tFunc(,tObj),0); ADD_FUNCTION("`*",image_color_mult,tFunc(tFlt,tObj),0); ADD_FUNCTION("`+",image_color_add,tFunc(tObj,tObj),0); image_color_program=end_program();
-
start_new_program();
+
/* this is the Image.Color stuff */
+
ADD_FUNCTION("`[]",image_get_color,tFunc(tStr,tObj),0); ADD_FUNCTION("`()",image_make_color,tFuncV(,tOr(tStr,tInt),tObj),0); ADD_FUNCTION("rgb",image_make_rgb_color,tFunc(tInt tInt tInt,tObj),0); ADD_FUNCTION("hsv",image_make_hsv_color, tOr(tFunc(tInt tInt tInt,tObj), tFunc(tFlt tFlt tFlt,tObj)) ,0); ADD_FUNCTION("cmyk",image_make_cmyk_color,tFunc(tOr(tInt,tFlt) tOr(tInt,tFlt) tOr(tInt,tFlt) tOr(tInt,tFlt),tObj), 0); ADD_FUNCTION("html",image_make_html_color,tFunc(tStr,tObj),0); ADD_FUNCTION("guess",image_guess_color,tFunc(tStr,tObj),0); ADD_FUNCTION("greylevel",image_make_greylevel_color,tFunc(tInt,tObj),0); ADD_FUNCTION("_indices",image_colors_indices,tFunc(,tArr(tStr)),0); ADD_FUNCTION("_values",image_colors_values,tFunc(,tArr(tObj)),0); add_program_constant("Color",image_color_program,0);
-
-
prg=end_program();
-
push_object(clone_object(prg,0));
-
free_program(prg);
-
str=make_shared_string("Color");
-
add_constant(str,sp-1,0);
-
free_string(str);
-
pop_stack();
+
} void exit_image_colors(void) {
-
if (image_color_program)
-
{
+
free_program(image_color_program);
-
image_color_program=NULL;
-
}
+
if (colors) { int i; free_mapping(colors); free_object(colortable); free_array(colornames); colors=NULL; colortable=NULL;