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.34 2000/08/09 17:42:13 grubba Exp $ + **! $Id: colors.c,v 1.35 2000/08/10 09:51:53 per 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.34 2000/08/09 17:42:13 grubba Exp $"); + RCSID("$Id: colors.c,v 1.35 2000/08/10 09:51:53 per 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:427:   {    pop_n_elems(args);    push_float(COLORL_TO_FLOAT(THIS->rgbl.r));    push_float(COLORL_TO_FLOAT(THIS->rgbl.g));    push_float(COLORL_TO_FLOAT(THIS->rgbl.b));    f_aggregate(3);   }      static void image_color_greylevel(INT32 args)   { -  INT32 r,g,b; +  INT_TYPE r,g,b;    if (args==0)    {    r=87;    g=127;    b=41;    }    else    {    get_all_args("Image.Color.Color->greylevel()",args,"%i%i%i",&r,&g,&b);    }
pike.git/src/modules/Image/colors.c:573:   **! the color, or the <ref>hex</ref>(2) if it isn't one   **! of the 16 <tt>HTML</tt> colors.   **!   **! returns a new <ref>Image.Color.Color</ref> object   **! see also: rgb, hsv, Image.Color   */      static void image_color_hex(INT32 args)   {    char buf[80]; -  INT32 i=sizeof(COLORTYPE)*2; +  INT_TYPE i=sizeof(COLORTYPE)*2;       if (args)    get_all_args("Image.Color.Color->hex()",args,"%i",&i);       pop_n_elems(args);    if (i<1)    {    push_text("#"); /* stupid */    return;    }
pike.git/src/modules/Image/colors.c:1077:    {    sp[-2].u.float_number+=0.2;    sp[-1].u.float_number+=0.2;    }    image_make_hsv_color(3);   }         static void image_color_mult(INT32 args)   { -  float x=0.0; +  FLOAT_TYPE x=0.0;    get_all_args("Image.Color.Color->`*",args,"%f",&x);    pop_n_elems(args);    _image_make_rgb_color((int)(THIS->rgb.r*x),    (int)(THIS->rgb.g*x),    (int)(THIS->rgb.b*x));   }      int image_color_svalue(struct svalue *v,rgb_group *rgb)   {    if (v->type==T_OBJECT)
pike.git/src/modules/Image/colors.c:1243:    if (sp[-1].u.string->len>=4 &&    sp[-1].u.string->str[0]=='@')    {    /* @h,s,v; h=0..359, s,v=0..100 */    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; +  FLOAT_TYPE 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));
pike.git/src/modules/Image/colors.c:1452:    get_storage(sp[-1].u.object,image_color_program);       cs->rgb.r=(COLORTYPE)r;    cs->rgb.g=(COLORTYPE)g;    cs->rgb.b=(COLORTYPE)b;    RGB_TO_RGBL(cs->rgbl,cs->rgb);   }      static void image_make_rgb_color(INT32 args)   { -  INT32 r=0,g=0,b=0; +  INT_TYPE r=0,g=0,b=0;       get_all_args("Image.Color.rgb()",args,"%i%i%i",&r,&g,&b);       _image_make_rgb_color(r,g,b);   }      static void image_make_hsv_color(INT32 args)   { -  double h,s,v; -  double r=0,g=0,b=0; /* to avoid warning */ +  FLOAT_TYPE h,s,v; +  FLOAT_TYPE r=0,g=0,b=0; /* to avoid warning */       if (args && sp[-args].type==T_INT)    { -  INT32 hi,si,vi; +  INT_TYPE hi,si,vi;    get_all_args("Image.Color.hsv()",args,"%i%i%i",    &hi,&si,&vi);    pop_n_elems(args);       if (hi<0) hi=(hi%COLORMAX)+COLORMAX;    else if (hi>COLORMAX) hi%=COLORMAX; /* repeating */    if (si<0) si=0; else if (si>COLORMAX) si=COLORMAX;    if (vi<0) vi=0; else if (vi>COLORMAX) vi=COLORMAX;       h = (hi/((double)COLORMAX))*(360.0/60.0);
pike.git/src/modules/Image/colors.c:1523:   #undef f   #undef p   #undef q   #undef t       _image_make_rgbf_color(r,g,b);   }      static void image_make_cmyk_color(INT32 args)   { -  float c,m,y,k,r,g,b; +  FLOAT_TYPE c,m,y,k,r,g,b;    get_all_args("Image.Color.cmyk()",args,"%F%F%F%F",&c,&m,&y,&k);    pop_n_elems(args);       r=100-(c+k);    g=100-(m+k);    b=100-(y+k);       _image_make_rgbf_color(r*0.01,g*0.01,b*0.01);   }      static void image_make_greylevel_color(INT32 args)   { -  INT32 i; +  INT_TYPE i;       get_all_args("Image.Color.greylevel()",args,"%i",&i);    pop_n_elems(args);       _image_make_rgb_color(i,i,i);   }      static void image_make_html_color(INT32 args)   {    int i;