Next: , Previous: , Up: Classes   [Index]


RGBAColor

RGBAColor Class

RGBAColor objects store red, green, blue, and alpha color information, and also the names of X11 colors and their X11 pixel values, if appropriate.

The class also provides methods for looking up X colors either by their color name or their RGB specification, as well as the alpha channel.

The rgb(1) program lists the color names supported by X displays. RGB color specifications may have the following forms.


#rgb, #rrggbb, #rrrrgggbbb, #rrrrggggbbbb

rgb:r/g/b, rgb:rr/gg/bb, rgb:rrr/ggg/bbb, rgb:rrrr/gggg/bbbb


r|g|b == hexadecimal digits, either case

The XParseColor(3) manual page describes all of the color specification formats used by X display servers.

Instance Variables

alpha

The value used for blending the color with its background; in the range 0 (completely transparent) to 65535 (completely opaque).

red
green
blue

The red, green, and blue components of the colors. For X displays, these values are unsigned short ints, with values of 1 ... 255. Because the class uses XAllocNamedColor(3) and XParseColor(3) internally, red, green and blue values, if given, are scaled to the X server’s RGB range.

x11Name

A String that contains a color name supported by the X server, if appropriate, or a RGB color specification that X11 uses. Refer to See X11RGBSpec.

x11Pixel

The value of the pixel color allocated by the X display.

Instance Methods

namedX11Color (String color_name)

Looks up the color given by color_name and fills in the receiver’s returns the color’s red, green, blue, and pixel values, and sets its x11Name to color_name.

The rgb(1) program lists by name the colors that the X server supports.

If color_name is suppored by the X server, the method returns 0 (SUCCESS). If the color is not supported, the method returns -1 (ERROR), and sets the red, green, and blue returns to 0. In addition, it sets pixel_out to the server’s black pixel, and raises an exception.

new (String object_name)

The class needs its own constructor because the primitive constructor internals have added an OBJECT_VALUE_IS_BIN_INT attribute to all of the new object’s instance variables, because RGBAColor's superclass is Integer. But this method needs to do a fixup and remove the attribute from the x11Name instance variable, which has a value of String. The contructor internals don’t, at the present time, recognize this semantic factor on a generalized basis, so we need to handle cases like these individually.

rgbX11Color (String color_spec)

Returns the color values and pixel value of color_spec. RGB color specifications are described more fully in the XParseColor(3) manual page.

If color_spec is suppored by the X server, the method returns 0 (SUCESS), and retrieves the red, green, blue, and pixel values provided by the server. If the color is not supported, the method returns -1 (ERROR), and sets the red, green, and blue returns to 0. In addition, it sets pixel_out to the server’s black pixel, and raises an exception.

x11Color (String color_spec)

A convenience method that calls either namedX11Color or rgbX11Color depending on the format of color_spec.


Next: , Previous: , Up: Classes   [Index]