OpenShot Video Editor  2.0.0
conversion.py
Go to the documentation of this file.
1 ##
2 #
3 # @file
4 # @brief This file deals with value conversions
5 # @author Jonathan Thomas <jonathan@openshot.org>
6 # @author Frank Dana <ferdnyc AT gmail com>
7 #
8 # @section LICENSE
9 #
10 # Copyright (c) 2008-2018 OpenShot Studios, LLC
11 # (http://www.openshotstudios.com). This file is part of
12 # OpenShot Video Editor (http://www.openshot.org), an open-source project
13 # dedicated to delivering high quality video editing and animation solutions
14 # to the world.
15 #
16 # OpenShot Video Editor is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 3 of the License, or
19 # (at your option) any later version.
20 #
21 # OpenShot Video Editor is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
28 #
29 
30 zoomSeconds = [1,
31  7,
32  14,
33  24,
34  54,
35  94,
36  118,
37  174,
38  205,
39  276,
40  356,
41  445,
42  542,
43  648,
44  761,
45  881,
46  1075,
47  1212,
48  1428,
49  1578,
50  1813,
51  2141,
52  2396,
53  2745,
54  3192,
55  3645,
56  4187,
57  4890,
58  5988,
59  7200
60  ]
61 
62 ##
63 # Convert zoom factor (slider position) into scale-seconds
64 def zoomToSeconds(zoomValue):
65  return zoomSeconds[zoomValue] or 1
66 
67 
68 ##
69 # Convert a number of seconds to a timeline zoom factor
70 def secondsToZoom(scaleValue):
71  if scaleValue in zoomSeconds:
72  return zoomSeconds[scaleValue]
73  else:
74  # Find closest zoom
75  closestValue = zoomSeconds[0]
76  for zoomValue in zoomSeconds:
77  if zoomValue < scaleValue:
78  closestValue = zoomValue
79  return zoomSeconds.index(closestValue)
80 
def secondsToZoom
Convert a number of seconds to a timeline zoom factor.
Definition: conversion.py:70
def zoomToSeconds
Convert zoom factor (slider position) into scale-seconds.
Definition: conversion.py:64