def test_Operators(self): # generate some unique values r1 = Gf.ColorRamp(Gf.RGB(1, 2, 3)) r2 = Gf.ColorRamp(Gf.RGB(1, 2, 4)) r3 = Gf.ColorRamp(Gf.RGB(3, 2, 1)) results = [r1, r2, r3] # test operators for i in range(len(results)): # Test repr self.assertTrue(eval(repr(results[i])) == results[i]) # Test equality for j in range(len(results)): if i == j: self.assertTrue(results[i] == results[j]) else: self.assertTrue(results[i] != results[j])
def test_Constructors(self): results = [] results.append(Gf.ColorRamp()) results.append(Gf.ColorRamp(Gf.RGB())) results.append(Gf.ColorRamp(Gf.RGB(), Gf.RGB())) results.append(Gf.ColorRamp(Gf.RGB(), Gf.RGB(), Gf.RGB())) results.append(Gf.ColorRamp(Gf.RGB(), Gf.RGB(), Gf.RGB(), 1)) results.append(Gf.ColorRamp(Gf.RGB(), Gf.RGB(), Gf.RGB(), 1, 2)) results.append(Gf.ColorRamp(Gf.RGB(), Gf.RGB(), Gf.RGB(), 1, 2, 3)) results.append(Gf.ColorRamp(Gf.RGB(), Gf.RGB(), Gf.RGB(), 1, 2, 3, 4)) results.append( Gf.ColorRamp(Gf.RGB(), Gf.RGB(), Gf.RGB(), 1, 2, 3, 4, 5)) for r in results: self.assertIsInstance(r, Gf.ColorRamp)
def test_Properties(self): r = Gf.ColorRamp() testVal = 0.314159 for propName in 'midPos widthMin widthMax widthMidIn widthMidOut'.split( ): self.assertNotEqual(getattr(r, propName), testVal) setattr(r, propName, testVal) self.assertEqual(getattr(r, propName), testVal)
def test_Eval(self): '''Eval -- make sure ends and middle are exact, make sure betweens are between them.''' r = Gf.ColorRamp() self.assertTrue( r.Eval(0) == Gf.RGB(0, 0, 1) and r.Eval(0.5) == Gf.RGB(0, 1, 0) and r.Eval(1) == Gf.RGB(1, 0, 0)) self.assertFalse(r.Eval(0.25).r != 0 or \ r.Eval(0.75).b != 0 or \ r.Eval(0.25).g <= 0 or \ r.Eval(0.25).g >= 1 or \ r.Eval(0.25).b <= 0 or \ r.Eval(0.25).b >= 1 or \ r.Eval(0.75).r <= 0 or \ r.Eval(0.75).r >= 1 or \ r.Eval(0.75).g <= 0 or \ r.Eval(0.75).g >= 1)