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.29 1999/12/06 21:06:46 mirar Exp $ + **! $Id: colors.c,v 1.30 2000/02/03 19:02:22 grubba 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:172:   **! class Color   **! 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"    - RCSID("$Id: colors.c,v 1.29 1999/12/06 21:06:46 mirar Exp $"); + RCSID("$Id: colors.c,v 1.30 2000/02/03 19:02:22 grubba Exp $");      #include "image_machine.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:274:    get_storage(sp[-1].u.object,image_color_program);    cs->rgb.r=(COLORTYPE)c[i].r;    cs->rgb.g=(COLORTYPE)c[i].g;    cs->rgb.b=(COLORTYPE)c[i].b;    RGB_TO_RGBL(cs->rgbl,cs->rgb);    copy_shared_string(cs->name,c[i].pname);    }    f_aggregate_mapping(n*2);    colors=sp[-1].u.mapping;    sp--; +  dmalloc_touch_svalue(sp);       for (i=0;i<n;i++)    {    push_int(c[i].r);    push_int(c[i].g);    push_int(c[i].b);    f_aggregate(3);    }    f_aggregate(n);    colortable=clone_object(image_colortable_program,1);
pike.git/src/modules/Image/colors.c:300:    push_int(1);    safe_apply(colortable,"cubicles",4);    pop_stack();       for (i=0;i<n;i++)    push_string(c[i].pname);    f_aggregate(n);       colornames=sp[-1].u.array;    sp--; +  dmalloc_touch_svalue(sp);   }      #ifdef THIS   #undef THIS /* Needed for NT */   #endif   #define THIS ((struct color_struct*)(fp->current_storage))   #define THISOBJ (fp->current_object)      static void init_color_struct(struct object *dummy)   {
pike.git/src/modules/Image/colors.c:982:   **! <ref>Image.Color</ref>.white-><ref>dark</ref>(), since   **! white can't get any <ref>light</ref>er.   */         static void image_color_light(INT32 args)   {    pop_n_elems(args);    image_color_hsvf(0);    sp--; +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array); /* frees */    sp[-1].u.float_number+=+0.2;    if (sp[-1].u.float_number>=1.0)    sp[-2].u.float_number-=sp[-1].u.float_number-1.0;       image_make_hsv_color(3);   }      static void image_color_dark(INT32 args)   {    pop_n_elems(args);    image_color_hsvf(0);    sp--; -  +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array); /* frees */    sp[-1].u.float_number-=0.2;    if (sp[-1].u.float_number<0.0)    sp[-2].u.float_number-=sp[-1].u.float_number;    image_make_hsv_color(3);   }      static void image_color_neon(INT32 args)   {    pop_n_elems(args);    image_color_hsvf(0);    sp--; -  +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array); /* frees */       if (sp[-1].u.float_number==0.0 ||    sp[-2].u.float_number==0.0)    {    if (sp[-1].u.float_number<0.5)    sp[-1].u.float_number=0.0;    else    sp[-1].u.float_number=1.0;    }
pike.git/src/modules/Image/colors.c:1031:    }    image_make_hsv_color(3);   }      static void image_color_dull(INT32 args)   {    pop_n_elems(args);       image_color_hsvf(0);    sp--; +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array); /* frees */       if (sp[-2].u.float_number==0.0)    {    sp[-1].u.float_number-=0.2;    }    else    {    sp[-2].u.float_number-=0.2;    sp[-1].u.float_number-=0.2;    }    image_make_hsv_color(3);   }      static void image_color_bright(INT32 args)   {    pop_n_elems(args);    image_color_hsvf(0);    sp--; -  +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array); /* frees */       if (sp[-2].u.float_number==0.0)    {    sp[-1].u.float_number+=0.2;    }    else    {    sp[-2].u.float_number+=0.2;    sp[-1].u.float_number+=0.2;
pike.git/src/modules/Image/colors.c:1179:       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]; -  unsigned char *src=sp[-1].u.string->str+1; +  unsigned char *src=(unsigned char *)sp[-1].u.string->str+1;    if (!(i%3))    {    i/=3;    for (j=0; j<3; j++)    {    unsigned INT32 z=0;    for (k=0; k<i; k++)    {    if (HEXTONUM(*src)==-1)    {
pike.git/src/modules/Image/colors.c:1237:    stack_dup();    push_text("@%f,%f,%f\n");    f_sscanf(2);    if (sp[-1].type==T_ARRAY &&    sp[-1].u.array->size==3)    {    float h,s,v;    stack_swap();    pop_stack();    sp--; +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array);    get_all_args("Image.Color()",3,"%f%f%f",&h,&s,&v);    pop_n_elems(3);    push_int((INT32)(h/360.0*256.0));    push_int((INT32)(s/100.0*255.4));    push_int((INT32)(v/100.0*255.4));    image_make_hsv_color(3);    return;    }    pop_stack();
pike.git/src/modules/Image/colors.c:1261:    /* @c,m,y,k; 0..100 */    stack_dup();    push_text("%%%f,%f,%f,%f\n");    f_sscanf(2);    if (sp[-1].type==T_ARRAY &&    sp[-1].u.array->size==4)    {    stack_swap();    pop_stack();    sp--; +  dmalloc_touch_svalue(sp);    push_array_items(sp->u.array);    image_make_cmyk_color(4);    return;    }    pop_stack();    }    for (n=0; (size_t)n<sizeof(callables)/sizeof(callables[0]); n++)    if (sp[-1].u.string->len>(INT32)strlen(callables[n]) &&    memcmp(sp[-1].u.string->str,callables[n],strlen(callables[n]))==0)    {