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.37 2000/08/11 19:25:53 grubba Exp $ + **! $Id: colors.c,v 1.38 2000/08/11 19:28:39 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.37 2000/08/11 19:25:53 grubba Exp $"); + RCSID("$Id: colors.c,v 1.38 2000/08/11 19:28:39 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:1252:    sp[-1].u.array->size==3)    {    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)); +  push_int(DOUBLE_TO_INT(h/360.0*256.0)); +  push_int(DOUBLE_TO_INT(s/100.0*255.4)); +  push_int(DOUBLE_TO_INT(v/100.0*255.4));    image_make_hsv_color(3);    return;    }    pop_stack();    }    if (sp[-1].u.string->len>=4 &&    sp[-1].u.string->str[0]=='%')    {    /* @c,m,y,k; 0..100 */    stack_dup();
pike.git/src/modules/Image/colors.c:1281:    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]) && +  if (sp[-1].u.string->len>(ptrdiff_t)strlen(callables[n]) &&    memcmp(sp[-1].u.string->str,callables[n],strlen(callables[n]))==0)    {    push_int(DO_NOT_WARN(strlen(callables[n])));    push_int(1000000);    f_index(3);    image_get_color(1);    if (sp[-1].type!=T_OBJECT) return; /* no way */    safe_apply(sp[-1].u.object,callables[n],0);    stack_swap();    pop_stack();
pike.git/src/modules/Image/colors.c:1486:       h = (hi/((double)COLORMAX))*(360.0/60.0);    s = si/((double)COLORMAX);    v = vi/((double)COLORMAX);    }    else    {    get_all_args("Image.Color.hsv()",args,"%f%f%f",    &h,&s,&v);    pop_n_elems(args); -  if (h<0) h=360+h-(((int)h/360)*360); -  if (h>360.0) h-=(((int)h/360)*360); +  if (h<0) h = 360 + h - ((DOUBLE_TO_INT(h)/360)*360); +  if (h>360.0) h -= ((DOUBLE_TO_INT(h)/360)*360);    h/=60;    }       if(s==0.0)    {    r = g = b = v;    } else {   #define i floor(h)   #define f (h-i)   #define p (v * (1 - s))