コード例 #1
0
 def test_set_tween(self):
     tween = Tween(3)
     tween.wait(6)
     tween.set(2.5, 8)
     self.assertEqual(len(tween), 14)
     self.assertEqual(tween.get(0), 3)
     self.assertEqual(tween[5], 3)
     self.assertEqual(tween[6], 2.5)
     self.assertEqual(tween.get(13), 2.5)
     expected = [3, 3, 3, 3, 3, 3, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5]
     for i, v in enumerate(tween):
         self.assertEqual(v, expected[i])
     self.assertEqual(i, 13)
コード例 #2
0
 def test_wait_tween(self):
     tween = Tween(5)
     tween.wait(10)
     self.assertEqual(len(tween), 10)
     self.assertEqual(tween.get(0), 5)
     self.assertEqual(tween.get(9), 5)
     self.assertEqual(tween[0], 5)
     self.assertEqual(tween[9], 5)
コード例 #3
0
from generativepy.tween import Tween

# Create a tween
tween = Tween(3.0).wait(4).to(13.0, 5).wait(2).set(7.0, 4)

# You can use len() to fund the length of the tween in frames
print('Length = ', len(tween))

# You can access the vale#ue for a particular frame using indexing []
# or the get() function.
print('tween[7] = ', tween[5])
print('tween[8] = ', tween.get(7))

# The tween can be accessed as a sequence. Here we use a list
# comprehension to convert the values to strings that print the
# entire sequence
strings = [str(x) for x in tween]
print(', '.join(strings))