Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Rickard Lindberg, Roger Lindberg 2 # 3 # This file is part of Timeline. 4 # 5 # Timeline is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # Timeline is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with Timeline. If not, see <http://www.gnu.org/licenses/>. 17 18 19 import wx 20 2123 """ 24 Convert between pixel coordinates and time coordinates. 25 """ 2672 7328 self.width, self.height = size 29 self.half_width = self.width / 2 30 self.half_height = self.height / 2 31 self.half_height = int(round(divider_line_slider * self.height)) 32 self.time_type = time_type 33 self.time_period = time_period3436 """Return the x position in pixels as a float for the given time.""" 37 return self.width * ( 38 (time - self.time_period.start_time) / self.time_period.delta() 39 )4042 """Return the x position in pixels as an integer for the given time.""" 43 try: 44 return int(round(self.calc_exact_x(time))) 45 except OverflowError: 46 if time < self.time_period.start_time: 47 return -1 48 if time > self.time_period.end_time: 49 return self.width + 15052 """Return the with in pixels as a float for the given time_period.""" 53 return (self.calc_exact_x(time_period.end_time) - 54 self.calc_exact_x(time_period.start_time))5557 """Return the with in pixels as an integer for the given time_period.""" 58 return (self.calc_x(time_period.end_time) - 59 self.calc_x(time_period.start_time)) + 16062 """Return the time at pixel `x`.""" 63 if self.width == 0: 64 x_percent_of_width = 0 65 else: 66 x_percent_of_width = float(x) / self.width 67 return self.time_period.get_time_at_percent(x_percent_of_width)6875 if (factor < 0.0 or factor > 1.0): 76 return color 77 return tuple([int(x * factor) for x in color])78 79 86 87 90
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jan 25 02:55:27 2019 | http://epydoc.sourceforge.net |