Beispiel #1
0
    def __init__ (self, nhands=6):
        clutter.Group.__init__(self)

        self.n_hands = nhands
        self.timeline = clutter.Timeline(5000)

        self.timeline.set_loop(True)
        self.timeline.connect('new-frame', self.on_new_frame)

        def sine_wave (alpha):
            return math.sin(alpha.get_timeline().get_progress() * math.pi)

        self.alpha = clutter.Alpha(self.timeline)
        self.alpha.set_func(sine_wave)

        self.scalers = []
        self.scalers.append(clutter.BehaviourScale(0.5, 0.5, 1.0, 1.0, self.alpha))
        self.scalers.append(clutter.BehaviourScale(1.0, 1.0, 0.5, 0.5, self.alpha))

        self.stage = clutter.Stage(default=True)
        self.stage.set_size(1024, 768)
        self.stage.connect('button-press-event', self.on_button_press)
        self.stage.connect('key-press-event', self.on_key_press)

        self.create_hands()
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        self._stage = clutter.Stage()
        self._stage.set_color(clutter.Color(0, 0, 0, 255))
        self._stage.set_size(300, 300)
        self._stage.connect('key-press-event', clutter.main_quit)

        rect = clutter.Rectangle()
        rect.set_color(clutter.Color(255, 255, 255, 0x99))
        rect.set_size(100, 100)
        rect.set_position(100, 100)
        self._stage.add(rect)

        rect = clutter.Rectangle()
        rect.set_color(clutter.Color(255, 255, 255, 255))
        rect.move_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        rect.set_size(100, 100)
        rect.set_position(100, 100)
        self._stage.add(rect)
        self._gravity = clutter.GRAVITY_NORTH_WEST
        self._rect = rect

        self._timeline = clutter.Timeline(duration=500)
        self._timeline.set_loop(True)
        self._timeline.connect('completed', self.on_timeline_completed, self)

        alpha = clutter.Alpha(self._timeline, clutter.LINEAR)

        self._behave = clutter.BehaviourScale(0.0, 0.0, 1.0, 1.0, alpha=alpha)
        self._behave.apply(rect)

        self._stage.show_all()
Beispiel #3
0
    def forward_effect(self, from_screen, to_screen):
        """
        Fade+zoom out all components from the "from_screen" and fade+zoom in
        all components of the "to_screen".
        @param from_screen: Screen object (Currently displayed screen)
        @param to_screen: Screen object (Screen displayed after transition)
        """
        # Initialize to_screen for animation
        to_screen.set_opacity(0)
        to_screen.show()

        # Fade out current screen
        if from_screen is not None:
            fade_out = clutter.Timeline(22, 85)
            alpha_out = clutter.Alpha(fade_out, clutter.smoothstep_inc_func)
            self.out_fade = clutter.BehaviourOpacity(255, 0, alpha_out)
            self.out_fade.apply(from_screen)
            #from_screen.set_anchor_point_from_gravity(
            #                                       clutter.GRAVITY_CENTER)
            self.out_zoom = clutter.BehaviourScale(1.0, 1.0, 1.2, 1.2,
                                                    alpha_out)
            #from_screen.set_anchor_point(0,0)
            self.out_zoom.apply(from_screen)

        # Fade in timeline
        fade_in = clutter.Timeline(22, 85)
        alpha_in = clutter.Alpha(fade_in, clutter.smoothstep_inc_func)
        self.in_behaviour = clutter.BehaviourOpacity(0, 255, alpha_in)
        self.in_behaviour.apply(to_screen)
        #to_screen.set_anchor_point_from_gravity(
        #                                           clutter.GRAVITY_CENTER)
        self.in_zoom = clutter.BehaviourScale(0.8, 0.8, 1.0, 1.0, alpha_in)
        #to_screen.set_anchor_point(0,0)
        self.in_zoom.apply(to_screen)

        # Start transition animation
        if from_screen is not None:
            fade_out.start()
        fade_in.start()
Beispiel #4
0
    def backward_effect(self, from_screen, to_screen):
        """ 
        Do the same as forward_effect, but zoom backwards. This gives an
        illusion of going back.
        @param from_screen: Screen object (Currently displayed screen)
        @param to_screen: Screen object (Screen displayed after transition)
        """
        # Initialize to_screen for animation
        to_screen.set_opacity(0x00)
        to_screen.show()

        # Fade out current screen
        fade_out = clutter.Timeline(22, 85)
        alpha_out = clutter.Alpha(fade_out, clutter.smoothstep_inc_func)
        self.out_fade = clutter.BehaviourOpacity(255, 0, alpha_out)
        self.out_fade.apply(from_screen)
        #from_screen.set_anchor_point_from_gravity(
        #                                           clutter.GRAVITY_CENTER)
        self.out_zoom = clutter.BehaviourScale(1.0, 1.0, 0.8, 0.8, alpha_out)
        self.out_zoom.apply(from_screen)
        fade_out.connect('completed', self._remove_from_stage_callback,
                                                    from_screen)

        # Fade in timeline
        fade_in = clutter.Timeline(22, 85)
        alpha_in = clutter.Alpha(fade_in, clutter.smoothstep_inc_func)
        self.in_behaviour = clutter.BehaviourOpacity(0, 255, alpha_in)
        self.in_behaviour.apply(to_screen)
        #to_screen.set_anchor_point_from_gravity(
        #                                           clutter.GRAVITY_CENTER)
        self.in_zoom = clutter.BehaviourScale(1.2, 1.2, 1.0, 1.0, alpha_in)
        self.in_zoom.apply(to_screen)

        # Start transition animation
        if from_screen is not None:
            fade_out.start()
        fade_in.start()
Beispiel #5
0
def on_timeline_rotation_completed(timeline):
    # All the items have now been rotated so that the clicked item is at the
    # front.  Now we transform just this one item gradually some more, and
    # show the filename.

    # Transform the image
    global timeline_moveup
    actor = item_at_front.actor
    timeline_moveup = clutter.Timeline(1000) # milliseconds
    alpha = clutter.Alpha(timeline_moveup, clutter.EASE_OUT_SINE)

    # Scale the item from its normal scale to approximately twice the normal scale
    scale_start = actor.get_scale()[0]
    scale_end = scale_start * 1.8

    global behaviour_scale
    behaviour_scale = clutter.BehaviourScale(scale_start, scale_start,
                                             scale_end, scale_end,
                                             alpha=alpha)
    behaviour_scale.apply(actor)

    # Move the item up the y axis
    knots = (
        (int(actor.get_x()), int(actor.get_y())),
        (int(actor.get_x()), int(actor.get_y() - 250)),
    )
    global behaviour_path
    behaviour_path = clutter.BehaviourPath(alpha, knots=knots)
    behaviour_path.apply(actor)

    # Show the filename gradually
    global label_filename
    label_filename.set_text(item_at_front.filepath)
    global behaviour_opacity
    behaviour_opacity = clutter.BehaviourOpacity(0, 255, alpha=alpha)
    behaviour_opacity.apply(label_filename)

    # Start the timeline and handle its "completed" signal so we can unref it
    timeline_moveup.connect('completed', on_timeline_moveup_completed)
    timeline_moveup.start()
Beispiel #6
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)
Beispiel #7
0
    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))