1#ifdef NANOGUI_PYTHON
2
3#include "python.h"
4
5void register_eigen(py::module &m) {
6 py::class_<Color>(m, "Color", D(Color))
7 .def(py::init<int, int, int, int>(), D(Color, Color, 7))
8 .def(py::init<int, int>(), D(Color, Color, 5))
9 .def(py::init<float, float, float, float>(), D(Color, Color, 7))
10 .def(py::init<float, float>(), D(Color, Color, 5))
11 .def("contrastingColor", &Color::contrastingColor,
12 D(Color, contrastingColor))
13 .def_property("r", [](const Color &c) { return c.r(); },
14 [](Color &c, float v) { c.r() = v; }, D(Color, r))
15 .def_property("g", [](const Color &c) { return c.g(); },
16 [](Color &c, float v) { c.g() = v; }, D(Color, g))
17 .def_property("b", [](const Color &c) { return c.b(); },
18 [](Color &c, float v) { c.b() = v; }, D(Color, b))
19 .def_property("w", [](const Color &c) { return c.w(); },
20 [](Color &c, float v) { c.w() = v; }, "Return a reference to the alpha channel.")
21 .def("__repr__", [](const Color &c) {
22 std::ostringstream oss;
23 oss << c.transpose();
24 return oss.str();
25 });
26}
27#endif
28