41
43
void export_color ()
43
45
using namespace boost::python;
44
class_<color>("Color",init<int,int,int,int>())
45
.def(init<int,int,int>())
46
.def(init<std::string>())
47
.add_property("r",&color::red,&color::set_red)
48
.add_property("g",&color::green,&color::set_green)
49
.add_property("b",&color::blue,&color::set_blue)
50
.add_property("a",&color::alpha,&color::set_alpha)
52
.def_pickle(color_pickle_suite())
53
.def("__str__",&color::to_string)
54
.def("to_hex_string",&color::to_hex_string)
46
class_<color>("Color", init<int,int,int,int>(
47
( arg("r"), arg("g"), arg("b"), arg("a") ),
48
"Creates a new color from its RGB components\n"
49
"and an alpha value.\n"
50
"All values between 0 and 255.\n")
52
.def(init<int,int,int>(
53
( arg("r"), arg("g"), arg("b") ),
54
"Creates a new color from its RGB components.\n"
55
"All values between 0 and 255.\n")
57
.def(init<std::string>(
58
( arg("color_string") ),
59
"Creates a new color from its CSS string representation.\n"
60
"The string may be a CSS color name (e.g. 'blue')\n"
61
"or a hex color string (e.g. '#0000ff').\n")
66
"Gets or sets the red component.\n"
67
"The value is between 0 and 255.\n")
71
"Gets or sets the green component.\n"
72
"The value is between 0 and 255.\n")
76
"Gets or sets the blue component.\n"
77
"The value is between 0 and 255.\n")
81
"Gets or sets the alpha component.\n"
82
"The value is between 0 and 255.\n")
84
.def_pickle(color_pickle_suite())
85
.def("__str__",&color::to_string)
86
.def("to_hex_string",&color::to_hex_string,
87
"Returns the hexadecimal representation of this color.\n"
90
">>> c = Color('blue')\n"
91
">>> c.to_hex_string()\n"