Browse Source

python: adapt to Magnum changes.

Which means the API gets renamed, so a breaking change.
next
Vladimír Vondruš 3 years ago
parent
commit
dddef56c87
  1. 12
      src/python/magnum/math.vector.h
  2. 8
      src/python/magnum/test/test_math.py

12
src/python/magnum/math.vector.h

@ -575,8 +575,8 @@ template<class T> void color3(py::class_<Math::Color3<T>, Math::Vector3<T>>& c)
.def_static("from_hsv", [](Degd hue, typename Math::Color3<T>::FloatingPointType saturation, typename Math::Color3<T>::FloatingPointType value) {
return Math::Color3<T>::fromHsv({Math::Deg<T>(hue), saturation, value});
}, "Create RGB color from HSV representation", py::arg("hue"), py::arg("saturation"), py::arg("value"))
.def_static("from_srgb", [](UnsignedInt srgb) {
return Math::Color3<T>::fromSrgb(srgb);
.def_static("from_srgb_int", [](UnsignedInt srgb) {
return Math::Color3<T>::fromSrgbInt(srgb);
}, "Create linear RGB color from 24-bit sRGB representation", py::arg("srgb"))
.def_static("from_xyz", &Color3::fromXyz,
"Create RGB color from CIE XYZ representation", py::arg("xyz"))
@ -638,11 +638,11 @@ template<class T> void color4(py::class_<Math::Color4<T>, Math::Vector4<T>>& c)
return Math::Color4<T>::fromHsv({Math::Deg<T>(hue), saturation, value}, alpha);
}, "Create RGB color from HSV representation", py::arg("hue"), py::arg("saturation"), py::arg("value"), py::arg("alpha") = Math::Implementation::fullChannel<T>())
.def_static("from_srgb_alpha", [](UnsignedInt srgbAlpha) {
return Math::Color4<T>::fromSrgbAlpha(srgbAlpha);
.def_static("from_srgb_alpha_int", [](UnsignedInt srgbAlpha) {
return Math::Color4<T>::fromSrgbAlphaInt(srgbAlpha);
}, "Create linear RGBA color from 32-bit sRGB a alpha representation", py::arg("srgb_alpha"))
.def_static("from_srgb", [](UnsignedInt srgb, T a) {
return Math::Color4<T>::fromSrgb(srgb, a);
.def_static("from_srgb_int", [](UnsignedInt srgb, T a) {
return Math::Color4<T>::fromSrgbInt(srgb, a);
}, "Create linear RGBA color from 32-bit sRGB a alpha representation", py::arg("srgb"), py::arg("a") = Math::Implementation::fullChannel<T>())
.def_static("from_xyz", &Color4::fromXyz,
"Create RGBA color from CIE XYZ representation", py::arg("xyz"), py::arg("a") = Math::Implementation::fullChannel<T>())

8
src/python/magnum/test/test_math.py

@ -477,7 +477,7 @@ class Color3_(unittest.TestCase):
def test_srgb(self):
# Cross-checked with C++ tests
a = Color3.from_srgb(0xf32a80)
a = Color3.from_srgb_int(0xf32a80)
self.assertEqual(a, Color3(0.896269, 0.0231534, 0.215861))
self.assertEqual(a.to_srgb_int(), 0xf32a80)
@ -547,15 +547,15 @@ class Color4_(unittest.TestCase):
def test_srgb(self):
# Cross-checked with C++ tests
a = Color4.from_srgb(0xf32a80)
a = Color4.from_srgb_int(0xf32a80)
self.assertEqual(a, Color4(0.896269, 0.0231534, 0.215861, 1.0))
self.assertEqual(a.to_srgb_alpha_int(), 0xf32a80ff)
def test_srgb_alpha(self):
# Cross-checked with C++ tests
a = Color4.from_srgb(0xf32a80, a=0.137255)
b = Color4.from_srgb_alpha(0xf32a8023)
a = Color4.from_srgb_int(0xf32a80, a=0.137255)
b = Color4.from_srgb_alpha_int(0xf32a8023)
self.assertEqual(a, Color4(0.896269, 0.0231534, 0.215861, 0.137255))
self.assertEqual(b, Color4(0.896269, 0.0231534, 0.215861, 0.137255))

Loading…
Cancel
Save