Ejemplo n.º 1
0
    def test_rgbcurve(self):
        """
        Test the GradingRGBCurve, creation, default value, modification.
        """

        rgbLin = OCIO.GradingRGBCurve(OCIO.GRADING_LIN)

        defLin = OCIO.GradingBSplineCurve(3)
        cpts = defLin.getControlPoints()
        cpts[0] = OCIO.GradingControlPoint(-7, -7)
        cpts[1] = OCIO.GradingControlPoint(0, 0)
        cpts[2] = OCIO.GradingControlPoint(7, 7)
        assertEqualBSpline(self, rgbLin.red, defLin)
        assertEqualBSpline(self, rgbLin.green, defLin)
        assertEqualBSpline(self, rgbLin.blue, defLin)
        assertEqualBSpline(self, rgbLin.master, defLin)

        rgbLog = OCIO.GradingRGBCurve(OCIO.GRADING_LOG)

        defLog = OCIO.GradingBSplineCurve(3)
        cpts = defLog.getControlPoints()
        cpts[0] = OCIO.GradingControlPoint(0, 0)
        cpts[1] = OCIO.GradingControlPoint(0.5, 0.5)
        cpts[2] = OCIO.GradingControlPoint(1, 1)
        assertEqualBSpline(self, rgbLog.red, defLog)
        assertEqualBSpline(self, rgbLog.green, defLog)
        assertEqualBSpline(self, rgbLog.blue, defLog)
        assertEqualBSpline(self, rgbLog.master, defLog)
        with self.assertRaises(AssertionError):
            assertEqualBSpline(self, rgbLog.master, defLin)

        rgbVideo = OCIO.GradingRGBCurve(OCIO.GRADING_LOG)
        assertEqualRGBCurve(self, rgbLog, rgbVideo)
    def test_values(self):
        """
        Test setValue() and getValue().
        """

        gct = OCIO.GradingRGBCurveTransform(OCIO.GRADING_LOG)
        gct.setValue(self.valDefaultLin)
        assertEqualRGBCurve(self, gct.getValue(), self.valDefaultLin)
    def test_contructor(self):
        """
        Test GradingRGBCurveTransform constructor without and with keywords.
        """

        gct = OCIO.GradingRGBCurveTransform()
        self.assertEqual(gct.getStyle(), OCIO.GRADING_LOG)
        assertEqualRGBCurve(self, gct.getValue(), self.valDefaultLog)
        self.assertEqual(gct.isDynamic(), False)
        self.assertEqual(gct.getBypassLinToLog(), False)
        self.assertEqual(gct.getDirection(), OCIO.TRANSFORM_DIR_FORWARD)

        gct = OCIO.GradingRGBCurveTransform(OCIO.GRADING_LIN)
        self.assertEqual(gct.getStyle(), OCIO.GRADING_LIN)
        assertEqualRGBCurve(self, gct.getValue(), self.valDefaultLin)
        self.assertEqual(gct.isDynamic(), False)
        self.assertEqual(gct.getBypassLinToLog(), False)
        self.assertEqual(gct.getDirection(), OCIO.TRANSFORM_DIR_FORWARD)

        vals = OCIO.GradingRGBCurve(OCIO.GRADING_LOG)
        vals.red = OCIO.GradingBSplineCurve(4)
        cpts = vals.red.getControlPoints()
        cpts[0] = OCIO.GradingControlPoint(0.0, 0.1)
        cpts[1] = OCIO.GradingControlPoint(0.1, 0.5)
        cpts[2] = OCIO.GradingControlPoint(0.4, 0.6)
        cpts[3] = OCIO.GradingControlPoint(0.6, 0.7)
        gct = OCIO.GradingRGBCurveTransform(style=OCIO.GRADING_VIDEO,
                                            values=vals,
                                            dynamic=True,
                                            dir=OCIO.TRANSFORM_DIR_INVERSE)
        self.assertEqual(gct.getStyle(), OCIO.GRADING_VIDEO)
        self.assertEqual(gct.isDynamic(), True)
        self.assertEqual(gct.getDirection(), OCIO.TRANSFORM_DIR_INVERSE)
        assertEqualRGBCurve(self, gct.getValue(), vals)