To contents

12.7.1 Image.Color.Color

CLASS
Image.Color.Color

DESCRIPTION
This is the color object. It has six readable variables, r, g, b, for the red, green and blue values, and h, s, v, for the hue, saturation anv value values.

METHOD
Image.Color.Color.neon,
Image.Color.Color.dull,
Image.Color.Color.dark,
Image.Color.Color.light,
Image.Color.Color.bright

SYNTAX
object light()
object dark()
object neon()
object bright()
object dull()

DESCRIPTION
Color modification methods. These returns a new color.

methodeffect hsvas
light raise light level±0 ±0+50
dark lower light level±0 ±0-50
brightbrighter color ±0+50+50
dull greyer color ±0-50-50
neon set to extreme ±0maxmax

light and dark lower/highers saturation when value is min-/maximised respective.

RETURNS
the new color object

NOTE
The opposites may not always take each other out. The color is maximised at white and black levels, so, for instance Image.Color.white->light()->dark() doesn't give the white color back, but the equal to Image.Color.white->dark(), since white can't get any lighter.

METHOD
Image.Color.Color.cast

SYNTAX
array|string cast()

DESCRIPTION
cast the object to an array, representing red, green and blue (equal to ->rgb()), or to a string, giving the name (equal to ->name()).

RETURNS
the name as string or rgb as array

SEE ALSO
rgb and name

METHOD
Image.Color.Color.greylevel,
Image.Color.Color.hsv,
Image.Color.Color.rgb,
Image.Color.Color.cmyk

SYNTAX
array(int) rgb()
array(int) hsv()
array(int) cmyk()
int greylevel()
int greylevel(int r,  int g,  int b)

DESCRIPTION
This is methods of getting information from an Image.Color.Color object.

They give an array of red, green and blue (rgb) values (color value),
hue, saturation and value (hsv) values (range as color value),
cyan, magenta, yellow, black (cmyk) values (in percent)
or the greylevel value (range as color value).

The greylevel is calculated by weighting red, green and blue. Default weights are 87, 127 and 41, respective, and could be given by argument.

RETURNS
array(int) respective int

SEE ALSO
Image.Color.Color and grey

METHOD
Image.Color.Color.create

SYNTAX
void create(int r, int g, int b)

DESCRIPTION
This is the main Image.Color.Color creation method, mostly for internal use.

METHOD
Image.Color.Color.grey

SYNTAX
object grey()
object grey(int red, int green, int blue)

DESCRIPTION
Gives a new color, containing a grey color, which is calculated by the greylevel method.

RETURNS
a new Image.Color.Color object

SEE ALSO
greylevel

METHOD
Image.Color.Color.name,
Image.Color.Color.hex,
Image.Color.Color.html

SYNTAX
string hex()
string hex(int n)
string name()
string html()

DESCRIPTION
Information methods.

hex() simply gives a string on the #rrggbb format. If n is given, the number of significant digits is set to this number. (Ie, n=3 gives #rrrgggbbb.)

name() is a simplified method; if the color exists in the database, the name is returned, per default is the hex() method use.

html() gives the HTML name of the color, or the hex(2) if it isn't one of the 16 HTML colors.

RETURNS
a new Image.Color.Color object

SEE ALSO
rgb, hsv and Image.Color

METHOD
Image.Color.Color.s,
Image.Color.Color.

SYNTAX
_sprintf(string s,  mapping flags)

DESCRIPTION

METHOD
Image.Color.Color.`==

SYNTAX
int `==(object other_color)
int `==(array(int) rgb)
int `==(int greylevel)
int `==(string name)

DESCRIPTION
Compares this object to another color, or color name. Example:
object red=Image.Color.red;
object other=Image.Color. ...;
object black=Image.Color.black;

if (red==other) ... if (red==({255,0,0})) ... if (black==0) ... if (red=="red") ...

RETURNS
1 or 0

NOTE
The other datatype (not color object) must be to the right!

SEE ALSO
rgb, grey and name

To contents