~fluendo-elisa/moovida/elisa-pancake

« back to all changes in this revision

Viewing changes to elisa-plugins/elisa/plugins/poblesec/slideshow/transitions.py

  • Committer: pancake
  • Date: 2009-03-27 12:16:38 UTC
  • mfrom: (1115.2.37 elisa)
  • Revision ID: pancake@flubox-20090327121638-2da0c1a0zu3byufd
* Merge against the head

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# Elisa - Home multimedia server
 
3
# Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com).
 
4
# All rights reserved.
 
5
#
 
6
# This file is available under one of two license agreements.
 
7
#
 
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.
 
11
#
 
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.
 
16
#
 
17
# Author: Florian Boucault <florian@fluendo.com>
 
18
 
 
19
import math
 
20
from pgm.timing import implicit
 
21
 
 
22
class Transition(object):
 
23
    """
 
24
    Define a visual, animated transition between two pictures. One picture
 
25
    should disappear, one should appear.
 
26
    """
 
27
 
 
28
    @staticmethod
 
29
    def apply(start_picture, end_picture, interval):
 
30
        """
 
31
        Apply the visual transition between L{start_picture} and L{end_picture}
 
32
 
 
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
 
38
                              happen
 
39
        @type interval:       C{float}
 
40
        """
 
41
        raise NotImplementedError()
 
42
 
 
43
 
 
44
class CrossfadeTransition(Transition):
 
45
 
 
46
    @staticmethod
 
47
    def apply(start_picture, end_picture, interval):
 
48
        if end_picture != None:
 
49
            end_picture.opacity = 255
 
50
 
 
51
        if start_picture != None:
 
52
            start_picture.opacity = 0
 
53
 
 
54
 
 
55
class FlipTransition(Transition):
 
56
 
 
57
    @staticmethod
 
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]
 
62
            end_picture.ry = 0.0
 
63
            end_picture.opacity = 255
 
64
 
 
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
 
69
 
 
70
 
 
71
class FadeToRedTransition(Transition):
 
72
 
 
73
    @staticmethod
 
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
 
79
 
 
80
        if start_picture != None:
 
81
            start_picture.fg_color = (255, 0, 0, 255)
 
82
            start_picture.opacity = 0
 
83
 
 
84
 
 
85
 
 
86
class SlideTransition(Transition):
 
87
 
 
88
    @staticmethod
 
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
 
93
            end_picture.x = 0.0
 
94
            end_picture.opacity = 255
 
95
 
 
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
 
100
 
 
101
 
 
102
 
 
103
class CubeTransition(Transition):
 
104
 
 
105
    @staticmethod
 
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)
 
110
            end_picture.ry = 0.0
 
111
            end_picture.position = (0.0, 0.0, 0.0)
 
112
            end_picture.opacity = 255
 
113
 
 
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
 
118
 
 
119
 
 
120
import random
 
121
 
 
122
class PostcardTransition(Transition):
 
123
 
 
124
    @staticmethod
 
125
    def apply(start_picture, end_picture, interval):
 
126
        if end_picture != None:
 
127
#            end_picture.static_object.border_width = 2.0
 
128
#            grey = 220
 
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
 
138
 
 
139
        if start_picture != None:
 
140
            start_picture.opacity = 0