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, 3, 5, 10, 15, 20, 30, 45, 60, 75,
31  90, 120, 150, 180, 240, 300, 360, 480, 600, 720,
32  900, 1200, 1500, 1800, 2400, 2700, 3600, 4800, 6000, 7200]
33 
34 ##
35 # Convert zoom factor (slider position) into scale-seconds
36 def zoomToSeconds(zoomValue):
37  if zoomValue < len(zoomSeconds):
38  return zoomSeconds[zoomValue]
39  else:
40  return zoomSeconds[-1]
41 
42 ##
43 # Convert a number of seconds to a timeline zoom factor
44 def secondsToZoom(scaleValue):
45  if scaleValue in zoomSeconds:
46  return zoomSeconds.index(scaleValue)
47  else:
48  # Find closest zoom
49  closestValue = zoomSeconds[0]
50  for zoomValue in zoomSeconds:
51  if zoomValue < scaleValue:
52  closestValue = zoomValue
53  return zoomSeconds.index(closestValue)
def secondsToZoom
Convert a number of seconds to a timeline zoom factor.
Definition: conversion.py:44
def zoomToSeconds
Convert zoom factor (slider position) into scale-seconds.
Definition: conversion.py:36