Mercurial > touhou
comparison pytouhou/utils/interpolator.py @ 50:811cefefb5c8
Fix a few bugs and add support for a few instructions
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 22 Aug 2011 21:16:47 +0200 |
parents | 6ebf9539c077 |
children | ab826bc29aa2 |
comparison
equal
deleted
inserted
replaced
49:cbe1cb50f2fd | 50:811cefefb5c8 |
---|---|
3 self.values = tuple(values) | 3 self.values = tuple(values) |
4 self.start_values = tuple(values) | 4 self.start_values = tuple(values) |
5 self.end_values = tuple(values) | 5 self.end_values = tuple(values) |
6 self.start_frame = 0 | 6 self.start_frame = 0 |
7 self.end_frame = 0 | 7 self.end_frame = 0 |
8 self._frame = 0 | |
8 | 9 |
9 | 10 |
10 def set_interpolation_start(self, frame, values): | 11 def set_interpolation_start(self, frame, values): |
11 self.start_values = tuple(values) | 12 self.start_values = tuple(values) |
12 self.start_frame = frame | 13 self.start_frame = frame |
24 def set_interpolation_end_values(self, values): | 25 def set_interpolation_end_values(self, values): |
25 self.end_values = tuple(values) | 26 self.end_values = tuple(values) |
26 | 27 |
27 | 28 |
28 def update(self, frame): | 29 def update(self, frame): |
30 self._frame = frame | |
29 if frame >= self.end_frame: | 31 if frame >= self.end_frame: |
30 self.values = tuple(self.end_values) | 32 self.values = tuple(self.end_values) |
31 self.start_values = tuple(self.end_values) | 33 self.start_values = tuple(self.end_values) |
32 self.start_frame = frame | 34 self.start_frame = frame |
35 return frame == self.end_frame | |
33 else: | 36 else: |
34 truc = float(frame - self.start_frame) / float(self.end_frame - self.start_frame) | 37 truc = float(frame - self.start_frame) / float(self.end_frame - self.start_frame) |
35 self.values = tuple(start_value + truc * (end_value - start_value) | 38 self.values = tuple(start_value + truc * (end_value - start_value) |
36 for (start_value, end_value) in zip(self.start_values, self.end_values)) | 39 for (start_value, end_value) in zip(self.start_values, self.end_values)) |
40 return True | |
37 | 41 |