Пример #1
0
    def test_DisplayGamma(self):
        # Check that the display gamma functions work too
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec3f(.5, .5, .5), 2.2) ==
            Gf.ConvertDisplayToLinear(Gf.Vec3f(.5, .5, .5)))
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec3d(.5, .5, .5), 2.2) ==
            Gf.ConvertDisplayToLinear(Gf.Vec3d(.5, .5, .5)))
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec4f(.5, .5, .5, .8), 2.2) ==
            Gf.ConvertDisplayToLinear(Gf.Vec4f(.5, .5, .5, .8)))
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec4d(.5, .5, .5, .8), 2.2) ==
            Gf.ConvertDisplayToLinear(Gf.Vec4d(.5, .5, .5, .8)))

        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec3f(.5, .5, .5), 1.0 / 2.2) ==
            Gf.ConvertLinearToDisplay(Gf.Vec3f(.5, .5, .5)))
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec3d(.5, .5, .5), 1.0 / 2.2) ==
            Gf.ConvertLinearToDisplay(Gf.Vec3d(.5, .5, .5)))
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec4f(.5, .5, .5, .8), 1.0 / 2.2) ==
            Gf.ConvertLinearToDisplay(Gf.Vec4f(.5, .5, .5, .8)))
        self.assertTrue(
            Gf.ApplyGamma(Gf.Vec4d(.5, .5, .5, .8), 1.0 / 2.2) ==
            Gf.ConvertLinearToDisplay(Gf.Vec4d(.5, .5, .5, .8)))
 def _OnPushed(self):
     if self.valueType.dimension in (3, 4):
         options = QtWidgets.QColorDialog.ColorDialogOptions()
         displayColor = QtGui.QColor(
             *[255 * v for v in Gf.ConvertLinearToDisplay(self.value)])
         if self.valueType.dimension == 4:
             options = QtWidgets.QColorDialog.ShowAlphaChannel
         newColor = QtWidgets.QColorDialog.getColor(displayColor, self,
                                                    unicode(self.valueType),
                                                    options)
         if newColor.isValid():
             if self.valueType.dimension == 3:
                 value = (newColor.red(), newColor.green(), newColor.blue())
             elif self.valueType.dimension == 4:
                 value = (newColor.red(), newColor.green(), newColor.blue(),
                          newColor.alpha())
             value = self.valueType(*(v / 255.0 for v in value))
             value = Gf.ConvertDisplayToLinear(value)
             self.value = self.valueType(*(round(v, 2) for v in value))
             self._changed = True
 def _ConvertColorsToLinear(self, colors):
     results = []
     for color in colors:
         results.append(Gf.ConvertDisplayToLinear(color))
     return results
Пример #4
0
def _Color(r, g, b):
    # for this tutorial, the colors i got are not in linear space.
    from pxr import Gf
    return Gf.ConvertDisplayToLinear(Gf.Vec3f(r, g, b))