Ejemplo n.º 1
0
def main():
    """"""
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_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 our custom actor to the stage
    actor = Triangle(actor_color)
    actor.set_size(100, 100)
    actor.set_position(20, 20)
    stage.add(actor)
    actor.show()

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

    #actor.set_color('Red')

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

    return 0
Ejemplo n.º 2
0
    def __init__(self,
                 x,
                 y,
                 size=0.03,
                 inner_radius=0.25,
                 outter_radius=0.45,
                 thickness=0.08):
        Base.__init__(self)

        abs_size = self.get_abs_x(size)

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

        self.set_anchor_point(abs_size / 2, abs_size / 2)

        c = self._clutterColorToCairoColor(clutter.Color(255, 255, 255, 255))
        bg = self._clutterColorToCairoColor(clutter.Color(128, 128, 128, 128))

        context = self.cairo_create()
        context.scale(abs_size, abs_size)
        context.set_line_width(thickness)
        context.set_line_cap(cairo.LINE_CAP_ROUND)

        # Draw the 12 lines
        for i in range(12):
            self._draw_line(context, bg, c, outter_radius, inner_radius, i)

        del (context)  # Updates texture

        self.keep_going = False

        self.set_position(self.get_abs_x(x), self.get_abs_y(y))
Ejemplo n.º 3
0
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
    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()

    timeline = clutter.Timeline(5000)  # milliseconds
    timeline.add_marker_at_time("clutter-tutorial", 2000)  # milliseconds
    timeline.connect('new-frame', on_timeline_new_frame, rect)
    timeline.connect('marker-reached', on_timeline_marker_reached)

    timeline.set_loop(True)

    timeline.start()

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

    return 0
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_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
    rect = clutter.Rectangle(actor_color)
    rect.set_size(100, 100)
    rect.set_position(20, 20)
    stage.add(rect)
    rect.show()

    # Add a label to the stage
    label = clutter.Text("Sans 12", "Some Text", actor_color)
    label.set_size(500, 500)
    label.set_position(20, 150)
    stage.add(label)
    label.show()

    # Show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

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

    return 0
Ejemplo n.º 6
0
def on_button_press(actor, event):
    old_x, old_y = actor.get_position()
    old_width, old_height = actor.get_size()

    if not is_expanded:
        new_x = old_x - 100
        new_y = old_y - 100
        new_width = old_width + 200
        new_height = old_height + 200
        new_angle = 360
        new_color = clutter.Color(0xdd, 0x44, 0xdd, 0xff)
    else:
        new_x = old_x + 100
        new_y = old_y + 100
        new_width = old_width - 200
        new_height = old_height - 200
        new_angle = 0
        new_color = clutter.Color(0x44, 0xdd, 0x44, 0x88)

    vertex = clutter.Vertex(new_width / 2, new_height / 2, 0)
    animation = actor.animate(clutter.EASE_IN_EXPO, 2000, "x", new_x, "y",
                              new_y, "width", new_width, "height", new_height,
                              "color", new_color, "rotation-angle-z",
                              new_angle, "fixed::rotation-center-z", vertex,
                              "fixed::reactive", False)
    animation.connect('completed', on_animation_complete, actor)
Ejemplo n.º 7
0
    def __init__(self):
        champlain.Layer.__init__(self)
        # a marker can also be set in RGB with ints
        self.gray = clutter.Color(51, 51, 51)

        # RGBA
        self.white = clutter.Color(0xff, 0xff, 0xff, 0xff)
        self.black = clutter.Color(0x00, 0x00, 0x00, 0xff)

        self.hide()
Ejemplo n.º 8
0
def main():
    stage_color = clutter.Color(176, 176, 176, 255) # light gray

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

    # Create and add a label actor, hidden at first
    global label_filename
    label_filename = clutter.Text()
    label_color = clutter.Color(96, 96, 144, 255) # blueish
    label_filename.set_color(label_color)
    label_filename.set_font_name("Sans 24")
    label_filename.set_position(10, 10)
    label_filename.set_opacity(0)
    stage.add(label_filename)
    label_filename.show()

    # Add a plane under the ellipse of images
    rect_color = clutter.Color(255, 255, 255, 255) # white
    rect = clutter.Rectangle(rect_color)
    rect.set_height(ELLIPSE_HEIGHT + 20)
    rect.set_width(stage.get_width() + 100)
    # Position it so that its center is under the images
    rect.set_position(-(rect.get_width() - stage.get_width()) / 2,
                      ELLIPSE_Y + IMAGE_HEIGHT - (rect.get_height() / 2))
    # Rotate it around its center
    rect.set_rotation(clutter.X_AXIS, -90, 0, rect.get_height() / 2, 0)
    stage.add(rect)
    rect.show()

    # show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

    global timeline_rotation
    timeline_rotation = clutter.Timeline(2000) # milliseconds
    timeline_rotation.connect('completed', on_timeline_rotation_completed)

    # Add an actor for each image
    load_images("images")
    add_image_actors(stage)

    # timeline_rotation.set_loop(True)

    # Move them a bit to start with
    global list_items
    if list_items:
        rotate_all_until_item_is_at_front(list_items[0])

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

    return 0
Ejemplo n.º 9
0
def main():
    stage = clutter.Stage()
    stage.set_color(clutter.Color(red=0xff, green=0xcc, blue=0xcc, alpha=0xff))
    stage.set_size(width=400, height=300)
    stage.connect('button-press-event', on_button_press_event)
    stage.connect('destroy', clutter.main_quit)

    cairo_tex = clutter.CairoTexture(width=200, height=200)
    cairo_tex.set_position(x=(stage.get_width() - 200) / 2,
                           y=(stage.get_height() - 200) / 2)

    # we obtain a cairo context from the clutter.CairoTexture
    # and then we can use it with the cairo primitives to draw
    # on it.
    context = cairo_tex.cairo_create()

    # we scale the context to the size of the surface
    context.scale(200, 200)
    context.set_line_width(0.1)
    context.set_source_color(clutter.Color(255, 0, 0, 0x88))
    context.translate(0.5, 0.5)
    context.arc(0, 0, 0.4, 0, pi * 2)
    context.stroke()

    del (context)  # we need to destroy the context so that the
    # texture gets properly updated with the result
    # of our operations; you can either move all the
    # drawing operations into their own function and
    # let the context go out of scope or you can
    # explicitly destroy it

    # clutter.CairoTexture is a clutter.Actor, so we can
    # manipulate it as any other actor
    center_x = cairo_tex.get_width() / 2
    center_z = cairo_tex.get_height() / 2
    cairo_tex.set_rotation(clutter.Y_AXIS, 45.0, center_x, 0, center_z)
    stage.add(cairo_tex)
    cairo_tex.show()

    # clutter.CairoTexture is also a clutter.Texture, so we can save
    # memory when dealing with multiple copies by simply cloning it
    # and manipulating the clones
    clone_tex = clutter.Clone(cairo_tex)
    clone_tex.set_position((stage.get_width() - 200) / 2,
                           (stage.get_height() - 200) / 2)
    clone_tex.set_rotation(clutter.Y_AXIS, -45.0, center_x, 0, center_z)
    stage.add(clone_tex)
    clone_tex.show()

    stage.show()

    clutter.main()

    return 0
Ejemplo n.º 10
0
 def message(self, text, color=None):
     logging.info("Setting transient message to %s" % text)
     self.set_color(clutter.Color(0, 0, 0))
     self.set_opacity(250)
     self.text.set_text(text)
     if color:
         self.text.set_color(color)
     else:
         self.text.set_color(clutter.Color(230, 230, 230))
     self.animation = self.animate(clutter.EASE_IN_CUBIC,
                                   settings.TRANSIENT_MESSAGE_FADE_RATE,
                                   'opacity', 0)
Ejemplo n.º 11
0
def on_button_clicked(button):
    global already_changed, stage

    if already_changed:
        stage_color = clutter.Color(0, 0, 0, 255) # Black
        stage.set_color(stage_color)
    else:
        stage_color = clutter.Color(32, 32, 160, 255)
        stage.set_color(stage_color)

    already_changed = not already_changed

    return True # Stop further handling of this event
Ejemplo n.º 12
0
 def __init__(self):
     super(TransientMessage, self).__init__(
         clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                           clutter.BIN_ALIGNMENT_CENTER))
     self.set_size(settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT)
     self.set_color(clutter.Color(0, 0, 0, 0))
     self.text = clutter.Text(settings.TRANSIENT_MESSAGE_FONT, '')
     self.text.set_property('scale-gravity', clutter.GRAVITY_CENTER)
     self.text.set_line_alignment(ALIGN_CENTER)
     self.text.set_line_wrap(True)
     self.text.set_color(clutter.Color(230, 230, 230))
     self.add(self.text)
     self.animation = None
Ejemplo n.º 13
0
 def __init__(self):
     #create a clutter stage
     self.stage = clutter.Stage()
     #set the stage size in x,y pixels
     self.stage.set_size(500, 200)
     #define some clutter colors in rgbo (red,green,blue,opacity)
     color_black = clutter.Color(0, 0, 0, 255)
     color_green = clutter.Color(0, 255, 0, 255)
     color_blue = clutter.Color(0, 0, 255, 255)
     #set the clutter stages bg color to our black
     self.stage.set_color(color_black)
     #we will need to check on the key presses from the user
     self.stage.connect('key-press-event', self.parseKeyPress)
     #create a clutter label, is there documentation for creating a clutterlabel?
     self.label = clutter.Label()
     #set the labels font
     self.label.set_font_name('Mono 32')
     #add some text to the label
     self.label.set_text("Hello")
     #make the label green
     self.label.set_color(color_green)
     #put the label in the center of the stage
     (label_width, label_height) = self.label.get_size()
     label_x = (self.stage.get_width() / 2) - label_width / 2
     label_y = (self.stage.get_height() / 2) - label_height / 2
     self.label.set_position(label_x, label_y)
     #make a second label similar to the first label
     self.label2 = clutter.Label()
     self.label2.set_font_name('Mono 32')
     self.label2.set_text("World!")
     self.label2.set_color(color_blue)
     (label2_width, label2_height) = self.label2.get_size()
     label2_x = (self.stage.get_width() / 2) - label2_width / 2
     label2_y = (self.stage.get_height() / 2) - label2_height / 2
     self.label2.set_position(label2_x, label2_y)
     #hide the label2
     self.label2.set_opacity(0)
     #create a timeline for the animations that are going to happen
     self.timeline = clutter.Timeline(fps=20, duration=500)
     #how will the animation flow? ease in? ease out? or steady?
     #ramp_inc_func will make the animation steady
     labelalpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
     #make some opacity behaviours that we will apply to the labels
     self.hideBehaviour = clutter.BehaviourOpacity(255, 0x00, labelalpha)
     self.showBehaviour = clutter.BehaviourOpacity(0x00, 255, labelalpha)
     #add the items to the stage
     self.stage.add(self.label2)
     self.stage.add(self.label)
     #show all stage items and enter the clutter main loop
     self.stage.show_all()
     clutter.main()
Ejemplo n.º 14
0
def main(args):
    stage = clutter.Stage()
    stage.set_size(800, 600)
    stage.set_color(clutter.Color(0xcc, 0xcc, 0xcc, 0xff))
    stage.connect('key-press-event', clutter.main_quit)
    stage.connect('destroy', clutter.main_quit)

    rect = clutter.Rectangle()
    rect.set_position(0, 0)
    rect.set_size(150, 150)
    rect.set_color(clutter.Color(0x33, 0x22, 0x22, 0xff))
    rect.set_border_color(clutter.color_from_string('white'))
    rect.set_border_width(15)
    rect.show()

    knots = ( \
            (   0,   0 ),   \
            ( 300,   0 ),   \
            ( 300, 300 ),   \
            (   0, 300 ),   \
    )

    path = clutter.Path('M 0 0 L 300 0 L 300 300 L 0 300')

    timeline = clutter.Timeline(3000)
    timeline.set_loop(True)
    alpha = clutter.Alpha(timeline, clutter.EASE_OUT_SINE)

    o_behaviour = clutter.BehaviourOpacity(alpha=alpha,
                                           opacity_start=0x33,
                                           opacity_end=255)
    o_behaviour.apply(rect)

    p_behaviour = clutter.BehaviourPath(alpha, path)
    path.add_move_to(0, 0)
    p_behaviour.apply(rect)

    r_behaviour = BehaviourRotate(alpha)
    r_behaviour.apply(rect)

    stage.add(rect)
    stage.show()

    timeline.start()

    clutter.main()

    return 0
Ejemplo n.º 15
0
def main(args):
    stage = clutter.Stage()
    stage.connect('destroy', clutter.main_quit)
    stage.set_color(clutter.Color(0x66, 0x66, 0xdd, 0xff))

    rect = clutter.Rectangle(clutter.Color(0x44, 0xdd, 0x44, 0xff))
    rect.set_size(50, 50)
    rect.set_anchor_point(25, 25)
    rect.set_position(stage.get_width() / 2, stage.get_height() / 2)
    rect.set_opacity(0x88)
    rect.set_reactive(True)
    rect.connect('button-press-event', on_button_press)
    stage.add(rect)

    stage.show()
    clutter.main()
Ejemplo n.º 16
0
    def __init__(self):
        super(Footer, self).__init__(clutter.BoxLayout())

        self.set_color(clutter.Color(0, 0, 0, 0))

        layout = self.get_layout_manager()
        layout.set_vertical(True)
        layout.set_spacing(20)

        self.set_width(settings.SCREEN_WIDTH)

        self.now_playing = now_playing()

        self.now_playing_box = clutter.Box(clutter.BoxLayout())
        tmplayout = self.now_playing_box.get_layout_manager()
        tmplayout.set_vertical(False)
        tmplayout.set_spacing(20)
        self.now_playing_box.set_width(settings.SCREEN_WIDTH)
        self.next_song_box = clutter.Box(clutter.BoxLayout())
        tmplayout = self.next_song_box.get_layout_manager()
        tmplayout.set_vertical(False)
        tmplayout.set_spacing(20)
        self.next_song_box.set_width(settings.SCREEN_WIDTH)

        layout.pack(self.now_playing_box, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
        layout.pack(self.next_song_box, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
Ejemplo n.º 17
0
    def __init__(self, message):
        self.stage = clutter.Stage()
        self.stage.set_color(clutter.color_from_string('DarkSlateGrey'))
        self.stage.set_size(800, 600)
        self.stage.set_title('My First Clutter Application')
        self.stage.connect('key-press-event', clutter.main_quit)
        self.stage.connect('button-press-event', self.on_button_press_event)

        color = clutter.Color(0xff, 0xcc, 0xcc, 0xdd)

        self.label = clutter.Text()
        self.label.set_font_name('Mono 32')
        self.label.set_text(message)
        self.label.set_color(color)
        (label_width, label_height) = self.label.get_size()
        label_x = self.stage.get_width() - label_width - 50
        label_y = self.stage.get_height() - label_height
        self.label.set_position(label_x, label_y)
        self.stage.add(self.label)

        self.cursor = clutter.Rectangle()
        self.cursor.set_color(color)
        self.cursor.set_size(20, label_height)
        cursor_x = self.stage.get_width() - 50
        cursor_y = self.stage.get_height() - label_height
        self.cursor.set_position(cursor_x, cursor_y)
        self.stage.add(self.cursor)

        self.timeline = clutter.Timeline(500)
        self.timeline.set_loop(True)
        alpha = clutter.Alpha(self.timeline, clutter.LINEAR)
        self.behaviour = clutter.BehaviourOpacity(0xdd, 0, alpha)
        self.behaviour.apply(self.cursor)
Ejemplo n.º 18
0
def main(args):
    stage = clutter.Stage()
    stage.set_size(800, 600)
    stage.set_color(clutter.color_from_string('DarkSlateGray'))
    stage.connect('actor-added', on_stage_add)
    stage.connect('button-press-event', on_button_press_event)

    print "stage color: %s" % (stage.get_color())

    color = clutter.Color(0x35, 0x99, 0x2a, 0x66)
    border_color = color.lighten()
    rect = None
    for i in range(1, 10):
        rect = clutter.Rectangle()
        rect.set_position((800 - (80 * i)) / 2, (600 - (60 * i)) / 2)
        rect.set_size(80 * i, 60 * i)

        # colors are either clutter.Color or 4-tuples
        if i % 2 == 0:
            rect.set_color(color)
        else:
            rect.set_color((0x35, 0x99, 0x2a, 0x33))

        rect.set_border_width(10)
        rect.set_border_color(border_color)

        stage.add(rect)
        rect.show()

    stage.show()
    clutter.main()

    return 0
Ejemplo n.º 19
0
 def on_press(self, actor, event):
     """
     """
     if event.keyval == clutter.keysyms.Left:
         self.get_parent().remove_screen(self)
     elif event.keyval == clutter.keysyms.Return:
         if can_buy_song():
             logging.info('User bought song %s.' % self.song)
             queue_song(self.song)
             credits_decrement()
             transient_message.message('Bought song %s' % self.song,
                                       color=clutter.Color(40, 250, 40))
             self.header.update()
         else:
             transient_message.message('Insert Quarter!',
                                       color=clutter.Color(250, 40, 40))
Ejemplo n.º 20
0
    def __init__(self, song):
        super(SongDetailScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(settings.SONG_ARTIST_FONT,
                            "by %s" % self.song.artist.name)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() - (self.left_arrow.get_width() +
                                               self.play.get_width()))

        layout.add(
            self.box,
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER,
        )

        layout.add(self.left_arrow, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)
Ejemplo n.º 21
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_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
    rect = clutter.Rectangle(actor_color)
    rect.set_size(100, 100)
    rect.set_position(20, 20)
    stage.add(rect)
    rect.show()

    # Rotate it 20 degrees away from us around the x axis
    # (around its top edge)
    rect.set_rotation(clutter.X_AXIS, -20, 0, 0, 0)

    # Add a label to the stage
    label = clutter.Text("Sans 12", "Some Text", actor_color)
    label.set_size(500, 500)
    label.set_position(20, 150)
    stage.add(label)
    label.show()

    # Scale it 300% along the x axis
    label.set_scale(3., 1.)

    # Move it up and to the right
    label.move_by(10, -10)

    # Move it along the z axis, further from the viewer
    label.set_depth(-20)

    # Show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

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

    return 0
Ejemplo n.º 22
0
    def __init__(self, width=DEFAULT_SYMBOL_SIZE):
        super(PlaySymbol, self).__init__(width=width, color='blue')

        self.box = clutter.Box(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        self.play = clutter.Text('Router Ultra Bold 25', 'PLAY')
        self.play.set_color(clutter.Color(255, 255, 255, 102))
        self.box.add(self.play)
        self.add(self.box)
Ejemplo n.º 23
0
    def __init__(self, font, text):
        """
        """
        super(Text, self).__init__(clutter.FixedLayout())

        self.text = clutter.Text(font, text)
        self.text.set_line_alignment(ALIGN_CENTER)
        self.text.set_line_wrap(True)
        self.text.set_color(clutter.Color(255, 255, 255))

        self.shadow = clutter.Text(font, text)
        self.shadow.set_line_alignment(ALIGN_CENTER)
        self.shadow.set_line_wrap(True)
        self.shadow.set_color(clutter.Color(0, 0, 0))
        offset = int(self.font_size() / 24) + 2
        self.shadow.set_position(offset, offset)

        self.add(self.shadow)
        self.add(self.text)
Ejemplo n.º 24
0
    def __init__(self):
        self.current_mode = 0
        self.stage = clutter.Stage()
        self.stage.set_color(clutter.Color(0x88, 0x88, 0xdd, 0xff))

        self.rect = clutter.Rectangle()
        self.rect.set_color(clutter.Color(0xee, 0x33, 0, 0xff))
        self.rect.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self.rect.set_size(50, 50)
        self.rect.set_position(self.stage.get_width() / 2,
                               self.stage.get_height() / 2)
        self.stage.add(self.rect)

        self.easing_mode_label = clutter.Text()
        self.stage.add(self.easing_mode_label)

        self.stage.connect('destroy', clutter.main_quit)
        self.stage.connect('button-press-event', self.on_button_press)
        self.stage.show()
        self.update_label()
Ejemplo n.º 25
0
 def HTMLColorToRGB(self, colorstring):
     """ convert #RRGGBB to a clutter color var """
     colorstring = colorstring.strip()
     if colorstring[0] == '#':
         colorstring = colorstring[1:]
     if len(colorstring) != 6:
         raise ValueError("input #%s is not in #RRGGBB format" %
                          colorstring)
     r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
     r, g, b = [int(n, 16) for n in (r, g, b)]
     return clutter.Color(r, g, b)
Ejemplo n.º 26
0
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
    rect = clutter.Rectangle(rect_color)
    rect.set_size(40, 40)
    rect.set_position(10, 10)
    stage.add(rect)
    rect.show()

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

    timeline = clutter.Timeline(5000)  # milliseconds
    timeline.set_loop(True)
    timeline.start()

    # Create a clutter alpha for the animation
    alpha = clutter.Alpha(timeline)
    alpha.set_func(on_alpha, None)

    # Create an animation to change the properties
    # XXX: There is a bug in pygobject that will refuse to convert between
    # ints and chars. This should be fixed when clutter 1.2 is out and
    # pyclutter targets it. The result is that the opacity won't be animated
    # the bug report is https://bugzilla.gnome.org/show_bug.cgi?id=591800
    # and shall be fixed in the next release, so perhaps by the time you read
    # this is already fixed.
    rect.animate_with_alpha(alpha, 'x', 150.0, 'y', 150.0, 'opacity', 0.0)

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

    return 0
Ejemplo n.º 27
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_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 group to the stage
    group = clutter.Group()
    group.set_position(40, 40)
    stage.add(group)
    group.show()

    # Add a rectangle to the group
    rect = clutter.Rectangle(actor_color)
    rect.set_size(50, 50)
    rect.set_position(0, 0)
    group.add(rect)
    rect.show()

    # Add a label to the group
    label = clutter.Text("Sans 9", "Some Text", actor_color)
    label.set_position(0, 60)
    group.add(label)
    label.show()

    # Scale the group 120% along the x axis
    group.set_scale(3.0, 1.0)

    # Rotate it around the z axis
    group.set_rotation(clutter.Z_AXIS, 10, 0, 0, 0)

    # Show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

    # Start the main loop, so we can respond to events
    clutter.main()
Ejemplo n.º 28
0
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
Ejemplo n.º 29
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_color = clutter.Color(255, 255, 255, 153)
    actor_color2 = clutter.Color(16, 64, 144, 255)

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

    # Add our custom container to the stage
    box = ExampleBox()

    # Set the size to the preferred size of the container
    box.set_size(-1, -1)
    box.set_position(20, 20)
    stage.add(box)
    box.show()

    # Add some actors to our container
    actor = clutter.Rectangle(color=actor_color)
    actor.set_size(75, 75)
    box.add(actor)
    actor.show()

    actor2 = clutter.Rectangle(color=actor_color2)
    actor2.set_size(75, 75)
    box.add(actor2)
    actor2.show()

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

    box.do_remove_all()

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

    return 0
Ejemplo n.º 30
0
def on_timeline_new_frame(timeline, frame_num, rect):
    global rotation_angle
    rotation_angle += 1
    if rotation_angle >= 360:
        rotation_angle = 0

    # Rotate the rectangle clockwise around the z axis, around it's
    # top-left corner
    rect.set_rotation(clutter.X_AXIS, rotation_angle, 0, 0, 0)

    # Change the color
    # (This is a silly example, making the rectangle flash)
    global color_change_count
    color_change_count += 1
    if color_change_count > 100:
        color_change_count = 0
    if color_change_count == 0:
        rect_color = clutter.Color(255, 255, 255, 153)
        rect.set_color(rect_color)
    elif color_change_count == 50:
        rect_color = clutter.Color(16, 64, 144, 255)
        rect.set_color(rect_color)