예제 #1
0
def main():
    stage = clutter.Stage()

    stage = clutter.Stage()
    stage.set_size(200, 200)
    stage.set_color(clutter.Color(0, 0, 0, 255))

    stage.connect('button-press-event', on_stage_button_press)
    stage.connect("destroy", clutter.main_quit)
    stage.show()

    clutter.main()

    return 0
예제 #2
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
예제 #3
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()
예제 #4
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)
예제 #5
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
예제 #6
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()
예제 #7
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
예제 #8
0
    def __init__(self):
        self.feed = feedparser.parse(
            'http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml')
        self.img, self.data = urllib.urlretrieve(self.feed.feed.image.href)
        self.stage = clutter.Stage()
        self.ident = clutter.texture_new_from_file(self.img)
        self.head = clutter.Text()
        self.body = clutter.Text()
        self.entry = 0
        #initialize elements of the display group
        self.head.set_position(130, 5)
        self.head.set_color(blue)
        self.body = clutter.Text()
        self.body.set_max_length(70)
        self.body.set_position(130, 22)
        self.body.set_size(250, 100)
        self.body.set_line_wrap(True)

        #get first feeed entry for text elements
        self.setfeed()
        #create group to hold elements
        self.group = clutter.Group()
        self.group.add(self.ident, self.head, self.body)
        self.group.show_all()
        #set up stage
        self.stage.set_size(400, 60)
        self.stage.set_color(white)
        self.stage.show_all()
        self.stage.add(self.group)
        self.stage.connect('key-press-event', self.parseKeyPress)
        clutter.main()
예제 #9
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
예제 #10
0
    def setUp(self):
        '''Set up the test.'''
        EntertainerTest.setUp(self)

        self.player = MediaPlayer(clutter.Stage(), 100, 100)
        self.video_item = VideoItem()
        self.video_item.filename = THIS_DIR + '/data/VideoThumbnailer/test.avi'
        self.player.set_media(self.video_item)
예제 #11
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
예제 #12
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
예제 #13
0
def main (args):
    stage = clutter.Stage(default=True)
    stage.set_color('#ccccccff')

    hands = SuperOh(8)
    stage.add(hands)
    hands.spin()

    stage.show_all()

    clutter.main()

    return 0
예제 #14
0
파일: test.py 프로젝트: fredmorcos/attic
 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()
예제 #15
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
예제 #16
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()
예제 #17
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
예제 #18
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()
예제 #19
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
예제 #20
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()
예제 #21
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
예제 #22
0
def main(args):
    stage = clutter.Stage()
    stage.set_color(clutter.Color(0, 0, 0, 255))
    stage.set_title('TextureReflection')
    stage.connect('button-press-event', clutter.main_quit)
    stage.connect('destroy', clutter.main_quit)

    group = clutter.Group()
    stage.add(group)

    try:
        tex = clutter.Texture(filename=args[0])
    except Exception:
        print "Unable to load the texture file"
        return 1

    reflect = TextureReflection(tex)
    reflect.set_opacity(100)

    x_pos = float((stage.get_width() - tex.get_width()) / 2)

    group.add(tex, reflect)
    group.set_position(x_pos, 20.0)
    reflect.set_position(0.0, (tex.get_height() + 20))

    timeline = clutter.Timeline(duration=3000)
    timeline.set_loop(True)
    alpha = clutter.Alpha(timeline, clutter.LINEAR)
    behaviour = clutter.BehaviourRotate(clutter.Y_AXIS, 0.0, 360.0, alpha,
                                        clutter.ROTATE_CW)
    behaviour.set_center(int(group.get_width() / 2), 0, 0)
    behaviour.apply(group)

    stage.show()

    timeline.start()

    clutter.main()

    return 0
예제 #23
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
예제 #24
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    label_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)

    # Connect signal handlers to handle mouse clicks on the stage
    stage.connect('button-press-event', on_stage_button_press)

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

    # Allow the actor to emit events.
    # By default only the stage does this.
    rect.set_reactive(True)

    # Connect signal handlers for events
    rect.connect('button-press-event', on_rect_button_press)
    rect.connect('button-release-event', on_rect_button_release)
    rect.connect('motion-event', on_rect_motion)
    rect.connect('enter-event', on_rect_enter)
    rect.connect('leave-event', on_rect_leave)

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

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

    return 0
예제 #25
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()

    # Instead of our custom callback,
    # we could use a standard callback. For instance, CLUTTER_ALPHA_SINE_INC.
    alpha = clutter.Alpha(timeline)
    alpha.set_func(on_alpha, None)

    behaviour = clutter.BehaviourPath(alpha, knots=((10, 10), (150, 150)))
    behaviour.apply(rect)

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

    return 0
예제 #26
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_color = clutter.Color(255, 255, 204, 255)

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

    # Add a non-editable text actor to the stage
    text = clutter.Text()

    # Setup text properties
    text.set_color(actor_color)
    text.set_text("Non-editable text: Wizard imps and sweat sock pimps,"
                  "interstellar mongrel nymphs.")
    text.set_font_name("Sans 12")
    text.set_editable(False)
    text.set_line_wrap(False)

    # Discover the preferred height and use that height
    min_height, natural_height = text.get_preferred_height(750)
    text.set_size(750, natural_height)
    text.set_position(5, 5)
    stage.add(text)
    text.show()

    # Add a multi-line editable text actor to the stage
    text = clutter.Text()

    # Setup text properties
    text.set_color(actor_color)
    text.set_text(
        "Editable text: And as I sat there brooding on the old, unknown world, I thought of "
        "Gatsby's wonder when he first picked out the green light at the end of "
        "Daisy's dock. He had come a long way to this blue lawn and his dream "
        "must have seemed so close that he could hardly fail to grasp it. He did "
        "not know that it was already behind him, somewhere back in that vast "
        "obscurity beyond the city, where the dark fields of the republic rolled "
        "on under the night.")
    text.set_font_name("Sans 12")
    text.set_editable(True)
    text.set_line_wrap(True)

    # Discover the preferred height and use that height
    min_height, natural_height = text.get_preferred_height(750)
    text.set_size(750, natural_height)

    text.set_position(5, 50)
    stage.add(text)
    text.show()

    # Set focus to handle key presses on the stage
    stage.set_key_focus(text)

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

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

    return 0
예제 #27
0
    def setUp(self):
        '''Set up the test.'''
        EntertainerTest.setUp(self)

        self.indicator = VolumeIndicator()
        clutter.Stage().add(self.indicator)
예제 #28
0
    
    # draw the hours indicator
    cr.move_to(0, 0)
    cr.line_to(math.sin(hours) * 0.2, -math.cos(hours) * 0.2)
    cr.stroke()

def tick(texture):
    cr = texture.cairo_create()
    cr.scale(300, 300)#texture.get_width(), texture.get_height())
    drawClock(cr)
    return True

if __name__ == '__main__':
    stage_color = clutter.Color(0x99, 0xcc, 0xff, 0xff)
    
    stage = clutter.Stage()
    stage.connect('button-press-event', clutter.main_quit)
    stage.connect('destroy', clutter.main_quit)
    stage.set_color(stage_color)
    
    texture = CairoTexture(300, 300)
    texture.set_position(
        (stage.get_width() - 300) / 2,
        (stage.get_height() - 300) / 2
    )
    stage.add(texture)
    texture.show()
    
    tick(texture)
    gobject.timeout_add_seconds(1, tick, texture)
    stage.show()
예제 #29
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()