pike.git / src / modules / Image / colors.c

version» Context lines:

pike.git/src/modules/Image/colors.c:1:   /*   **! module Image   **! note - **! $Id: colors.c,v 1.17 1999/05/23 17:46:38 mirar Exp $ + **! $Id: colors.c,v 1.18 1999/05/24 12:09:35 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.17 1999/05/23 17:46:38 mirar Exp $"); + RCSID("$Id: colors.c,v 1.18 1999/05/24 12:09:35 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:939:    return 1;    }    }    else if (v->type==T_STRING)    {    push_svalue(v);    image_make_color(1);    if (sp[-1].type==T_OBJECT)    {    struct color_struct *cs=(struct color_struct*) -  get_storage(v->u.object,image_color_program); +  get_storage(sp[-1].u.object,image_color_program);    *rgb=cs->rgb;    pop_stack();    return 1;    }    pop_stack();    }    return 0;   }      int image_color_arg(INT32 args,rgb_group *rgb)
pike.git/src/modules/Image/colors.c:988:    struct svalue s;    int n;    static char *callables[]={"light","dark","neon","dull","bright"};       if (args!=1)    error("Image.Color[]: illegal number of args");       if (!colors)    make_colors();    +  if (sp[-1].type==T_STRING) +  {    mapping_index_no_free(&s,colors,sp-1); -  if (s.type==T_INT) +  if (s.type==T_OBJECT)    { -  object_index_no_free2(&s,THISOBJ,sp-1); -  if (s.type!=T_INT) -  { +     pop_stack();    *(sp++)=s;    return;    } -  +  else +  free_svalue(&s); +  }       if (sp[-1].type==T_STRING &&    sp[-1].u.string->size_shift==0)    {    if (sp[-1].u.string->len>=4 &&    sp[-1].u.string->str[0]=='#')    {    /* #rgb, #rrggbb, #rrrgggbbb, etc */       unsigned long i=sp[-1].u.string->len-1,j,k,rgb[3];
pike.git/src/modules/Image/colors.c:1139:    }       /* try other stuff here */       pop_stack();    push_int(0);    sp[-1].subtype=NUMBER_UNDEFINED;    return;    }    -  pop_stack(); -  *(sp++)=s; - } -  +    static void image_guess_color(INT32 args)   {    struct svalue s;       if (args!=1 && sp[-args].type!=T_STRING)    error("Image.Color->guess(): illegal argument(s)\n");       f_lower_case(1);    push_text(" ");    o_subtract();
pike.git/src/modules/Image/colors.c:1170:    return;    }    pop_stack();    push_text("#");    stack_swap();    f_add(2);       image_get_color(1);   }    + static void image_colors_index(INT32 args) + { +  struct svalue s; +  object_index_no_free2(&s,THISOBJ,sp-1); +  if (s.type!=T_INT) +  { +  pop_stack(); +  *(sp++)=s; +  return; +  } +  image_get_color(args); + } +    static void image_make_color(INT32 args)   {    struct svalue s;       if (args==1 && sp[-args].type==T_STRING)    {    image_get_color(args);    return;    }    image_make_rgb_color(args);
pike.git/src/modules/Image/colors.c:1469:    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();       /* 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("`[]",image_colors_index,tFunc(tStr,tObj),0); +  ADD_FUNCTION("`()",image_make_color, +  tOr(tFunc(tStr,tObj), +  tFunc(tInt tInt 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);