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.40 2000/09/10 01:23:58 per Exp $ + **! $Id: colors.c,v 1.41 2000/12/01 08:09:58 hubbe 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:145:   **!   **! </execute>   **! </add_appendix>   **!   **! see also: Image.Color.Color->name, Image.Color.Color->rgb, colors   **!   **! added:   **! pike 0.7   **!   **! note: - **! <tt>Image.Color["something"]</tt> will never(!) generate an error, + **! <tt>Image.Color["something"]</tt> will never(!) generate an Pike_error,   **! but a zero_type 0, if the color is unknown. This is enough - **! to give the error "not present in module", if used + **! to give the Pike_error "not present in module", if used   **! as <tt>Image.Color.something</tt>, though.   **!   **! If you are using colors from for instance a webpage, you might   **! want to create the color from <ref>Image.Color.guess</ref>(),   **! since that method is more tolerant for mistakes and errors.   **!   **! <tt>Image.Color</tt>() is case- and space-sensitive.   **! Use <ref>Image.Color.guess</ref>() to catch all variants.   **!   **! and subtract with a space (lower_case(x)-" ") to make
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.40 2000/09/10 01:23:58 per Exp $"); + RCSID("$Id: colors.c,v 1.41 2000/12/01 08:09:58 hubbe 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:475:    b = COLORL_TO_FLOAT(THIS->rgbl.b);       max = MAX3(r,g,b);    min = MIN3(r,g,b);       v = max;       if(max != 0.0)    s = (max - min)/max;    else -  error("internal error, max==0.0\n"); +  Pike_error("internal Pike_error, max==0.0\n");       delta = max-min;       if(r==max) h = (g-b)/delta;    else if(g==max) h = 2+(b-r)/delta;    else /*if(b==max)*/ h = 4+(r-g)/delta;    h *= 60; /* now in degrees. */    if(h<0) h+=360;       push_float(h);
pike.git/src/modules/Image/colors.c:678:    case 1:    sprintf(buf,"#%02x%02x%02x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b);    break;    case 2:    sprintf(buf,"#%04x%04x%04x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b);    break;    case 4:    sprintf(buf,"#%08x%08x%08x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b);    break;    default: -  error("unknown size of colortype\n"); +  Pike_error("unknown size of colortype\n");    }    push_text(buf);   }      static void image_color_html(INT32 args)   {    int i;       if (!colors) make_colors();   
pike.git/src/modules/Image/colors.c:741:    if (sp[-1].u.string==str_array)    {    image_color_rgb(args);    return;    }    if (sp[-1].u.string==str_string)    {    image_color_name(args);    return;    } -  error("Image.Color.Color->cast(): Can't cast to that\n"); +  Pike_error("Image.Color.Color->cast(): Can't cast to that\n");   }      /*   **! method _sprintf(string s, mapping flags)   **!   */      static void image_color__sprintf(INT32 args)   {    int prec,n,x;
pike.git/src/modules/Image/colors.c:835:    return;    }      }      static void image_color_index(INT32 args)   {    struct svalue s;       if (args!=1) -  error("Image.Color[]: illegal number of arguments\n"); +  Pike_error("Image.Color[]: illegal number of arguments\n");       object_index_no_free2(&s,THISOBJ,sp-1);    if (s.type==T_INT && sp[-1].type==T_STRING)    {    if (sp[-1].u.string==str_r)    {    pop_stack();    push_int(THIS->rgb.r);    return;    }
pike.git/src/modules/Image/colors.c:915:   **!   **! returns 1 or 0   **! see also: rgb, grey, name   **! note:   **! The other datatype (not color object) must be to the right!   */      static void image_color_equal(INT32 args)   {    if (args!=1) -  error("Image.Color.Color->`==: illegal number of arguments"); +  Pike_error("Image.Color.Color->`==: illegal number of arguments");       if (sp[-1].type==T_OBJECT)    {    struct color_struct *other;    other=(struct color_struct*)    get_storage(sp[-1].u.object,image_color_program);    if (other&&    other->rgbl.r==THIS->rgbl.r &&    other->rgbl.g==THIS->rgbl.g &&    other->rgbl.b==THIS->rgbl.b)
pike.git/src/modules/Image/colors.c:1217:    ((C)>='a' && (C)<='f')?(C)-'a'+10: \    ((C)>='A' && (C)<='F')?(C)-'A'+10:-1)      static void image_get_color(INT32 args)   {    struct svalue s;    int n;    static char *callables[]={"light","dark","neon","dull","bright"};       if (args!=1) -  error("Image.Color[]: illegal number of args"); +  Pike_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_OBJECT)    {    pop_stack();
pike.git/src/modules/Image/colors.c:1564:   #define t (v * (1 - (s * (1 -f))))    switch(DOUBLE_TO_INT(i))    {    case 6: /* 360 degrees. Same as 0.. */    case 0: r = v; g = t; b = p; break;    case 1: r = q; g = v; b = p; break;    case 2: r = p; g = v; b = t; break;    case 3: r = p; g = q; b = v; break;    case 4: r = t; g = p; b = v; break;    case 5: r = v; g = p; b = q; break; -  default: error("internal error (hue=%d <= hsv[%f,%f,%f])\n", +  default: Pike_error("internal Pike_error (hue=%d <= hsv[%f,%f,%f])\n",    DOUBLE_TO_INT(i), h, s, v);    }    }   #undef i   #undef f   #undef p   #undef q   #undef t       _image_make_rgbf_color(r,g,b);