1
# -*- coding: utf-8 -*-
2
# Elisa - Home multimedia server
3
# Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com).
6
# This file is available under one of two license agreements.
8
# This file is licensed under the GPL version 3.
9
# See "LICENSE.GPL" in the root of this distribution including a special
10
# exception to use Elisa with Fluendo's plugins.
12
# The GPL part of Elisa is also available under a commercial licensing
13
# agreement from Fluendo.
14
# See "LICENSE.Elisa" in the root directory of this distribution package
15
# for details on that license.
17
# Author: Florian Boucault <florian@fluendo.com>
20
from pgm.timing import implicit
22
class Transition(object):
24
Define a visual, animated transition between two pictures. One picture
25
should disappear, one should appear.
29
def apply(start_picture, end_picture, interval):
31
Apply the visual transition between L{start_picture} and L{end_picture}
33
@param start_picture: picture that should disappear
34
@type start_picture: L{pgm.timing.implicit.AnimatedObject}
35
@param end_picture: picture that should appear
36
@type end_picture: L{pgm.timing.implicit.AnimatedObject}
37
@param interval: time in seconds during which the transition should
39
@type interval: C{float}
41
raise NotImplementedError()
44
class CrossfadeTransition(Transition):
47
def apply(start_picture, end_picture, interval):
48
if end_picture != None:
49
end_picture.opacity = 255
51
if start_picture != None:
52
start_picture.opacity = 0
55
class FlipTransition(Transition):
58
def apply(start_picture, end_picture, interval):
59
if end_picture != None:
60
end_picture.static_object.ry = math.pi
61
end_picture.z = [-end_picture.absolute_width, 0.0]
63
end_picture.opacity = 255
65
if start_picture != None:
66
start_picture.z = [-start_picture.absolute_width, 0.0]
67
start_picture.ry = -math.pi
68
start_picture.opacity = 0
71
class FadeToRedTransition(Transition):
74
def apply(start_picture, end_picture, interval):
75
if end_picture != None:
76
end_picture.static_object.fg_color = (255, 0, 0, 255)
77
end_picture.fg_color = (255, 255, 255, 255)
78
end_picture.opacity = 255
80
if start_picture != None:
81
start_picture.fg_color = (255, 0, 0, 255)
82
start_picture.opacity = 0
86
class SlideTransition(Transition):
89
def apply(start_picture, end_picture, interval):
90
if end_picture != None:
91
end_picture.update_animation_settings(transformation=implicit.DECELERATE)
92
end_picture.static_object.x = 1.0
94
end_picture.opacity = 255
96
if start_picture != None:
97
start_picture.update_animation_settings(transformation=implicit.DECELERATE)
98
start_picture.x = -1.2
99
start_picture.opacity = 0
103
class CubeTransition(Transition):
106
def apply(start_picture, end_picture, interval):
107
if end_picture != None:
108
end_picture.static_object.ry = math.pi/2.0
109
end_picture.static_object.position = (0.5, 0.0, 0.0)
111
end_picture.position = (0.0, 0.0, 0.0)
112
end_picture.opacity = 255
114
if start_picture != None:
115
start_picture.ry = -math.pi/2.0
116
start_picture.position = (-0.5, 0.0, 0.0)
117
start_picture.opacity = 0
122
class PostcardTransition(Transition):
125
def apply(start_picture, end_picture, interval):
126
if end_picture != None:
127
# end_picture.static_object.border_width = 2.0
129
# end_picture.static_object.border_outer_color = (grey, grey, grey, 255)
130
end_picture.static_object.size = (0.8, 0.8)
131
end_picture.static_object.position = (0.1, 0.1, 0.0)
132
end_picture.static_object.ry = 0.01
133
end_picture.opacity = 255
134
end_picture.setup_next_animations('ry', duration=2.0*interval*1000)
135
end_picture.ry = random.randrange(30, 51)/200.0
136
end_picture.setup_next_animations('rx', duration=2.0*interval*1000)
137
end_picture.rx = random.randrange(30, 51)/200.0
139
if start_picture != None:
140
start_picture.opacity = 0