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.23 1999/06/19 20:24:42 hubbe Exp $ + **! $Id: colors.c,v 1.24 1999/06/22 19:25:57 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:63:   **! and saturation and value is given in percent. <i>This is not   **! the same as returned or given to the <ref>hsv</ref>() methods!</i>   **!   **!   **! <add_appendix name="colors" title="Image.Color colors"><execute>   **!   **! import Image;   **!   **! constant modifiers=({"neon","light","dark","bright","dull"});   **! - **! mixed color_info(object c) + **! object F=Font(); + **! + **! mixed color_info(array(object) ac)   **! { - **! begin_tag("tr"); +    **! - **! begin_tag("td",(["valign":"center"])); - **! begin_tag("tt",(["valign":"center","align":"left"])); - **! write(c->name()); - **! write(end_tag()); - **! write(end_tag()); - **! +    **! #define YZ 14 -  + **! #define YZz (YZ+1)   **! #define MODX 32 - **! #define CXZ 32 + **! #define CXZ 64   **! #define CSP 8   **! #define MSP 4   **! #define LSP 4 - **! #define XZ (MODX+CSP+(MSP+MODX)*sizeof(modifiers)-MSP) + **! #define XTEXT 100 + **! #define XSP 4 + **! #define cPOS (XTEXT+XSP) + **! #define tPOS 0 + **! #define txPOS(t) (XSP*2) + **! #define XZ (CXZ+CSP+(MSP+MODX)*sizeof(modifiers)-MSP)   **! - **! object i=Image(XZ,YZ,Color.black); - **! object a=Image(XZ,YZ,Color.black); - **! i->box(0,0,CXZ-1,YZ,c); - **! i->box(CXZ,YZ-LSP,XZ,YZ,c); - **! a->box(0,0,CXZ-1,YZ,Color.white); - **! a->box(CXZ,YZ-LSP,XZ,YZ,Color.white); + **! object i=Image(XZ+XTEXT,YZz*sizeof(ac),Color.black); + **! object a=Image(XZ+XTEXT,YZz*sizeof(ac),Color.black);   **! - **! int x=CXZ+CSP; - **! foreach (modifiers,string mod) + **! int y=0; + **! foreach (ac,object c)   **! { - **! i->box(x,0,x+MODX-1,YZ-LSP-1,c[mod]()); - **! a->box(x,0,x+MODX-1,YZ-LSP-1,Color.white); - **! x+=MSP+MODX; + **! i->box(cPOS+0, y, cPOS+CXZ-1,y+YZ-1,c); + **! i->box(cPOS+CXZ,y+YZ-LSP,cPOS+XZ, y+YZ-1,c); + **! a->box(cPOS+0, y, cPOS+CXZ-1,y+YZ-1,Color.white); + **! a->box(cPOS+CXZ,y+YZ-LSP,cPOS+XZ, y+YZ-1,Color.white); + **! + **! int x=CXZ+CSP+cPOS; + **! foreach (modifiers,string mod) + **! { + **! i->box(x,y,x+MODX-1,y+YZ-LSP-1,c[mod]()); + **! a->box(x,y,x+MODX-1,y+YZ-LSP-1,Color.white); + **! x+=MSP+MODX; + **! } + **! i->box(tPOS,y,tPOS+XTEXT-XSP-1,y+YZ-1, + **! c->neon()->dark()->dark()->dark()); + **! a->box(tPOS,y,tPOS+XTEXT-XSP-1,y+YZ-1,Color.white); + **! i->paste_alpha_color(F->write(c->name()), Color.white, + **! txPOS(c->name()),y+1); + **! y+=YZz;   **! }   **! - **! begin_tag("td",(["valign":"center"])); +    **! write(illustration(i,a)); - **! write(end_tag()); - **! - **! begin_tag("td",(["valign":"center","align":"left"])); - **! begin_tag("tt",(["valign":"center","align":"left"])); - **! write(replace(" "+c->hex(2) + - **! sprintf(" %4.2f %4.2f %4.2f ",@c->rgbf()) + - **! sprintf("%3g° %4.2f %4.2f",@c->hsvf()), - **! " ","&nbsp;")); - **! write(end_tag()); - **! write(end_tag()); - **! - **! return end_tag(); + **! write(mktag("br"));   **! }   **!   **! void main()   **! {   **! array cs=values(Color); - **! begin_tag("table",(["cellspacing":1,"cellpadding":0,"border":0])); +    **!   **! array orig=({Color.black,Color.red,Color.green,Color.yellow,   **! Color.blue,Color.violet,Color.cyan,Color.white});   **! cs-=orig;   **!   **! array grey=Array.filter(cs,lambda(object c) { return c->s==0; });   **! array colored=cs-grey;   **!   **! sort(grey->v,grey);   **! sort(Array.map(colored,lambda(object c)   **! {   **! return (c->h*50-c->s)*10+c->v;   **! }),colored);   **! - **! write(@Array.map(orig,color_info)); - **! write(mktag("tr",0,mktag("td",(["colspan":2]),"&nbsp;"))); - **! write(@Array.map(grey,color_info)); - **! write(mktag("tr",0,mktag("td",(["colspan":2]),"&nbsp;"))); - **! write(@Array.map(colored,color_info)); - **! - **! write(end_tag()); + **! Array.map(({orig}),color_info); + **! write(mktag("hr")); + **! Array.map(({grey}),color_info); + **! write(mktag("hr")); + **! Array.map(colored/8.0,color_info);   **! }   **!   **! </execute>   **! </add_appendix>   **!   **! see also: Image.Color.Color->name, Image.Color.Color->rgb, colors   **!   **! added:   **! pike 0.7   **!
pike.git/src/modules/Image/colors.c:175:   **! 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.23 1999/06/19 20:24:42 hubbe Exp $"); + RCSID("$Id: colors.c,v 1.24 1999/06/22 19:25:57 mirar Exp $");      #include "image_machine.h"      #include <math.h>      #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"