Next: , Previous: Color Data Members, Up: Color Reference


16.2 Constructors and Setting Functions

— Default constructor: void Color (void)

Creates a Color and initializes its red_part, green_part, and blue_part to 0. use_name and on_free_store are set to false.

— Copy constructor: void Color (const Color& c, [const string n = "", [const bool u = true]])

Creates a Color and makes it a copy of c. If n is not the empty string and u is true, use_name is set to true. Otherwise, its set to false.

— Constructor: void Color (const string n, const unsigned short r, const unsigned short g, const unsigned short b, [const bool u = true])

Creates a Color with name n. Its red_part, green_part, and blue_part are set to r/255.0, g/255.0, and b/255.0, respectively. use_name is set to u.

— Setting function: void set (const string n, const unsigned short r, const unsigned short g, const unsigned short b, [const bool u = false])

Corresponds to the constructor above, except that u is false by default.

— Constructor: void Color (const real r, const real g, const real b)

Creates an unnamed Color using the real values r, g, and b for its red_part, green_part, and blue_part, respectively.

— Setting function: void set (const real r, const real g, const real b)

Corresponds to the constructor above.

— Template specializations: Color* create_new<Color> (const Color* c)
— : Color* create_new<Color> (const Color& c)

Pseudo-constructors for dynamic allocation of Colors. They create a Color on the free store and allocate memory for it using new(Color). They return a pointer to the new Color.

If c is a non-zero pointer or a reference, the new Color will be a copy of c. If the new object is not meant to be a copy of an existing one, ‘0’ must be passed to create_new<Color>() as its argument. See Dynamic Allocation of Shapes, for more information.

This function is used in the drawing and filling functions for Path and Solid. Point::drawdot() should be changed to use it too, but I haven't gotten around to doing this yet.