Exemple #1
0
    def __init__(self, theme):
        clutter.Group.__init__(self)
        self.animate_selector = False

        selector_filename = theme.getImage("selector")
        glow_filename = theme.getImage("selector_glow")

        # Set selector base texture
        self.selector = Texture(selector_filename)
        self.selector.set_opacity(200)
        self.add(self.selector)

        # Set selector GLOW texture
        self.glow = Texture(glow_filename)
        self.glow.set_opacity(0)
        self.add(self.glow)

        # Animate selector (Glow effect with glow overlay texture)
        self.in_time = clutter.Timeline(1500)
        self.in_alpha = clutter.Alpha(self.in_time, clutter.EASE_IN_OUT_SINE)
        self.in_behaviour = clutter.BehaviourOpacity(0, 255, self.in_alpha)
        self.in_behaviour.apply(self.glow)

        self.out_time = clutter.Timeline(1500)
        self.out_alpha = clutter.Alpha(self.out_time, clutter.EASE_IN_OUT_SINE)
        self.out_behaviour = clutter.BehaviourOpacity(255, 0, self.out_alpha)
        self.out_behaviour.apply(self.glow)

        self.score = clutter.Score()
        self.score.set_loop(True)
        self.score.append(timeline=self.in_time)
        # Link the out Timeline so that there is a smooth fade out.
        self.score.append(timeline=self.out_time, parent=self.in_time)
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    rect_color = clutter.Color(255, 255, 255, 153)

    # Get the stage and set its size and color
    stage = clutter.Stage()
    stage.set_size(200, 200)
    stage.set_color(stage_color)

    # Add a rectangle to the stage
    global rect
    rect = clutter.Rectangle(rect_color)
    rect.set_size(70, 70)
    rect.set_position(50, 100)
    stage.add(rect)
    rect.show()

    # Show the stage
    stage.connect('destroy', clutter.main_quit)
    stage.show()

    # Create a score and add two timelines to it,
    # so the second timeline starts when the first one stops
    score = clutter.Score()
    score.set_loop(True)

    timeline_rotation = clutter.Timeline(5000)  # milliseconds
    timeline_rotation.connect('new-frame', on_timeline_rotation_new_frame)
    score.append(timeline=timeline_rotation)

    timeline_move = clutter.Timeline(5000)  # milliseconds
    timeline_move.connect('new-frame', on_timeline_move_new_frame)
    score.append(parent=timeline_rotation, timeline=timeline_move)

    score.start()

    # Start the main loop, so we can respond to events
    clutter.main()

    return 0
Exemple #3
0
    def _create_navigation_textures(self):
        '''Create the pause, seek-backward & seek-forward textures.'''
        self.pause_texture = Texture(
            self.theme.getImage("media-playback-pause"), 0.5, 0.5)
        self.pause_texture.set_anchor_point_from_gravity(
            clutter.GRAVITY_CENTER)
        self.pause_texture.hide()
        self.add(self.pause_texture)

        pause_in_time = clutter.Timeline(1000)
        in_alpha_pause = clutter.Alpha(pause_in_time, clutter.EASE_IN_OUT_SINE)

        self.pause_in_opacity = clutter.BehaviourOpacity(alpha=in_alpha_pause,
                                                         opacity_start=100,
                                                         opacity_end=255)
        self.pause_in_scale = clutter.BehaviourScale(1.0, 1.0, 1.4, 1.4,
                                                     in_alpha_pause)

        self.pause_in_opacity.apply(self.pause_texture)
        self.pause_in_scale.apply(self.pause_texture)

        pause_out_time = clutter.Timeline(1000)
        out_alpha_pause = clutter.Alpha(pause_out_time,
                                        clutter.EASE_IN_OUT_SINE)

        self.pause_out_opacity = clutter.BehaviourOpacity(
            alpha=out_alpha_pause, opacity_start=255, opacity_end=100)
        self.pause_out_scale = clutter.BehaviourScale(1.4, 1.4, 1.0, 1.0,
                                                      out_alpha_pause)

        self.pause_out_opacity.apply(self.pause_texture)
        self.pause_out_scale.apply(self.pause_texture)

        self.score = clutter.Score()
        self.score.set_loop(True)
        self.score.append(timeline=pause_in_time)
        self.score.append(timeline=pause_out_time, parent=pause_in_time)
        self.score.start()

        self.seekbackward_texture = Texture(
            self.theme.getImage("media-seek-backward"), 0.1, 0.5)
        self.seekbackward_texture.set_anchor_point_from_gravity(
            clutter.GRAVITY_CENTER)
        self.seekbackward_texture.set_opacity(0)
        self.add(self.seekbackward_texture)

        self.seekbackward_timeline = clutter.Timeline(1000)
        alpha_seekbackward = clutter.Alpha(self.seekbackward_timeline,
                                           clutter.EASE_IN_OUT_SINE)

        self.seekbackward_opacity = clutter.BehaviourOpacity(
            alpha=alpha_seekbackward, opacity_start=255, opacity_end=0)
        self.seekbackward_opacity.apply(self.seekbackward_texture)

        self.seekforward_texture = Texture(
            self.theme.getImage("media-seek-forward"), 0.9, 0.5)
        self.seekforward_texture.set_anchor_point_from_gravity(
            clutter.GRAVITY_CENTER)
        self.seekforward_texture.set_opacity(0)
        self.add(self.seekforward_texture)

        self.seekforward_timeline = clutter.Timeline(1000)
        alpha_seekforward = clutter.Alpha(self.seekforward_timeline,
                                          clutter.EASE_IN_OUT_SINE)

        self.seekforward_opacity = clutter.BehaviourOpacity(
            alpha=alpha_seekforward, opacity_start=255, opacity_end=0)
        self.seekforward_opacity.apply(self.seekforward_texture)
    def __init__(self, x, y, size, fg_color, bg_color, direction):
        Base.__init__(self)

        abs_size = self.get_abs_x(size)

        clutter.CairoTexture.__init__(self, abs_size, abs_size)

        context = self.cairo_create()
        context.scale(abs_size, abs_size)

        fg_cairo = self._color_to_cairo_color(fg_color)
        bg_cairo = self._color_to_cairo_color(bg_color)

        # Draw background
        context.set_line_width(0.15)
        context.set_source_rgba(bg_cairo[0], bg_cairo[1], bg_cairo[2],
                                bg_cairo[3])
        self._roundedrec(context, 0, 0, 1, 1, 0.08, 0.1)
        context.fill()

        # Draw arrow
        context.set_source_rgba(fg_cairo[0], fg_cairo[1], fg_cairo[2],
                                fg_cairo[3])
        if direction == ArrowTexture.DOWN:
            context.move_to(0.25, 0.33)
            context.line_to(0.50, 0.66)
            context.line_to(0.75, 0.33)
            context.stroke()
        elif direction == ArrowTexture.UP:
            context.move_to(0.25, 0.66)
            context.line_to(0.50, 0.33)
            context.line_to(0.75, 0.66)
            context.stroke()
        elif direction == ArrowTexture.RIGHT:
            context.move_to(0.33, 0.25)
            context.line_to(0.66, 0.50)
            context.line_to(0.33, 0.75)
            context.stroke()
        elif direction == ArrowTexture.LEFT:
            context.move_to(0.66, 0.25)
            context.line_to(0.33, 0.50)
            context.line_to(0.66, 0.75)
            context.stroke()

        del (context)  # Updates texture

        # Create bounce effect
        self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)

        in_time = clutter.Timeline(300)
        in_alpha = clutter.Alpha(in_time, clutter.EASE_OUT_SINE)
        self.in_behaviour = clutter.BehaviourScale(1.0, 1.0, 1.5, 1.5,
                                                   in_alpha)
        self.in_behaviour.apply(self)

        out_time = clutter.Timeline(300)
        out_alpha = clutter.Alpha(out_time, clutter.EASE_OUT_SINE)
        self.out_behaviour = clutter.BehaviourScale(1.5, 1.5, 1.0, 1.0,
                                                    out_alpha)
        self.out_behaviour.apply(self)

        self.score = clutter.Score()
        self.score.append(timeline=in_time)
        self.score.append(timeline=out_time, parent=in_time)

        self.set_position(self.get_abs_x(x), self.get_abs_y(y))
Exemple #5
0
    def __init__(self, fullscreen=True):
        self.fullscreen = fullscreen
        self.transition = 'FADE'

        self.stage = clutter.Stage()
        if self.fullscreen == True:
            self.stage.set_fullscreen(True)
        else:
            self.stage.set_size(1200, 800)

        size = self.stage.get_size()
        print "%r" % (size,)

        display_width = size[0]*0.7
        display_height = size[1]*0.7

        self.stage.set_color(clutter.Color(0,0,0))
        if self.fullscreen == True:
            self.stage.connect('button-press-event', lambda x,y: reactor.stop())
        self.stage.connect('destroy', lambda x: reactor.stop())
        #self.stage.connect('key-press-event', self.process_key)

        self.texture_group = clutter.Group()
        self.stage.add(self.texture_group)

        self.texture_1 = clutter.Texture()
        self.texture_1.set_opacity(0)
        self.texture_1.set_keep_aspect_ratio(True)
        self.texture_1.set_size(display_width,display_height)
        self.texture_1.haz_image = False

        self.texture_2 = clutter.Texture()
        self.texture_2.set_opacity(0)
        self.texture_2.set_keep_aspect_ratio(True)
        self.texture_2.set_size(display_width,display_height)
        self.texture_2.haz_image = False

        self.texture_1.reflection = TextureReflection(self.texture_1)
        self.texture_1.reflection.set_reflection_height(display_height/3)
        self.texture_1.reflection.set_opacity(100)

        self.texture_2.reflection = TextureReflection(self.texture_2)
        self.texture_2.reflection.set_reflection_height(display_height/3)
        self.texture_2.reflection.set_opacity(0)

        x_pos = float((self.stage.get_width() - self.texture_1.get_width()) / 2)

        self.texture_group.add(self.texture_1, self.texture_1.reflection)
        self.texture_group.add(self.texture_2, self.texture_2.reflection)
        self.texture_group.set_position(x_pos, 20.0)
        self.texture_1.reflection.set_position(0.0, (self.texture_1.get_height() + 20))
        self.texture_2.reflection.set_position(0.0, (self.texture_2.get_height() + 20))

        def timeline_out_1_comleted(x):
            self.info("timeline_out_1_comleted")

        def timeline_out_2_comleted(x):
            self.info("timeline_out_2_comleted")

        def timeline_in_1_comleted(x):
            self.info("timeline_in_1_comleted")

        def timeline_in_2_comleted(x):
            self.info("timeline_in_2_comleted")

        self.texture_1.transition_fade_out_timeline = clutter.Timeline(2000)
        self.texture_1.transition_fade_out_timeline.connect('completed',timeline_out_1_comleted)
        alpha=clutter.Alpha(self.texture_1.transition_fade_out_timeline, clutter.EASE_OUT_SINE)
        self.fade_out_texture_behaviour_1 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=255, opacity_end=0)
        self.fade_out_texture_behaviour_1.apply(self.texture_1)
        self.fade_out_reflection_behaviour_1 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=100, opacity_end=0)
        self.fade_out_reflection_behaviour_1.apply(self.texture_1.reflection)
        self.texture_1.transition_fade_out_timeline.add_marker_at_time('out_nearly_finished', 500)

        self.texture_1.transition_fade_in_timeline = clutter.Timeline(2000)
        self.texture_1.transition_fade_in_timeline.connect('completed',timeline_in_1_comleted)
        alpha=clutter.Alpha(self.texture_1.transition_fade_in_timeline, clutter.EASE_OUT_SINE)
        self.fade_in_texture_behaviour_1 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=0, opacity_end=255)
        self.fade_in_texture_behaviour_1.apply(self.texture_1)
        self.fade_in_reflection_behaviour_1 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=0, opacity_end=100)
        self.fade_in_reflection_behaviour_1.apply(self.texture_1.reflection)

        self.texture_2.transition_fade_out_timeline = clutter.Timeline(2000)
        self.texture_2.transition_fade_out_timeline.connect('completed',timeline_out_2_comleted)
        alpha=clutter.Alpha(self.texture_2.transition_fade_out_timeline, clutter.EASE_OUT_SINE)
        self.fade_out_texture_behaviour_2 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=255, opacity_end=0)
        self.fade_out_texture_behaviour_2.apply(self.texture_2)
        self.fade_out_reflection_behaviour_2 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=100, opacity_end=0)
        self.fade_out_reflection_behaviour_2.apply(self.texture_2.reflection)
        self.texture_2.transition_fade_out_timeline.add_marker_at_time('out_nearly_finished', 500)

        self.texture_2.transition_fade_in_timeline = clutter.Timeline(2000)
        self.texture_2.transition_fade_in_timeline.connect('completed',timeline_in_2_comleted)
        alpha=clutter.Alpha(self.texture_2.transition_fade_in_timeline, clutter.EASE_OUT_SINE)
        self.fade_in_texture_behaviour_2 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=0, opacity_end=255)
        self.fade_in_texture_behaviour_2.apply(self.texture_2)
        self.fade_in_reflection_behaviour_2 = clutter.BehaviourOpacity(alpha=alpha, opacity_start=0, opacity_end=100)
        self.fade_in_reflection_behaviour_2.apply(self.texture_2.reflection)

        self.texture_1.fading_score = clutter.Score()
        self.texture_1.fading_score.append(timeline=self.texture_2.transition_fade_out_timeline)
        self.texture_1.fading_score.append_at_marker(timeline=self.texture_1.transition_fade_in_timeline,parent=self.texture_2.transition_fade_out_timeline,marker_name='out_nearly_finished')
        def score_1_started(x):
            self.info("score_1_started")
        def score_1_completed(x):
            self.info("score_1_completed")
        self.texture_1.fading_score.connect('started', score_1_started)
        self.texture_1.fading_score.connect('completed', score_1_completed)

        self.texture_2.fading_score = clutter.Score()
        self.texture_2.fading_score.append(timeline=self.texture_1.transition_fade_out_timeline)
        self.texture_2.fading_score.append_at_marker(timeline=self.texture_2.transition_fade_in_timeline,parent=self.texture_1.transition_fade_out_timeline,marker_name='out_nearly_finished')
        def score_2_started(x):
            self.info("score_2_started")
        def score_2_completed(x):
            self.info("score_2_completed")
        self.texture_2.fading_score.connect('started', score_2_started)
        self.texture_2.fading_score.connect('completed', score_2_completed)

        self.in_texture = self.texture_1
        self.out_texture = self.texture_2
        self.stage.show()
Exemple #6
0
 def __init__(self, *args, **kwargs):
     self._score = clutter.Score()