Re: pyclutter anyone?

Discussion in 'Python' started by donn, Feb 5, 2010.

  1. donn

    donn Guest

    No one uses pyClutter?
    I have some code, it does not work, but maybe this will start to help
    solve the problem:

    import clutter
    from clutter import cogl

    x,y=0,0

    def boo(tl,frame,obj):#,evt):
    global x,y
    obj.set_position(x, y)

    def xy(obj,evt):
    global x,y
    x,y = evt.x,evt.y

    class G(clutter.Group):
    """
    Attempt to make a Group that can clip its children to a path.
    """
    def __init__(self,*args):
    clutter.Group.__init__(self,*args)
    #self.set_clip(0,0,10,10)
    self.connect("paint",self.do_paint)
    self._color = clutter.Color(255,200,100)
    def do_paint(self, args):
    width,height=200,200
    cogl.path_move_to(width / 2, 0)
    cogl.path_line_to(width, height)
    cogl.path_line_to(0, height)
    cogl.path_line_to(width / 2, 0)
    cogl.path_close()
    #cogl.set_source_color(self._color)
    #cogl.path_fill()

    ## Colour me lost from here...
    cogl.clip_push_from_path()
    clutter.Group.do_paint(self)
    cogl.clip_pop()

    def main():
    global group1
    stage = clutter.Stage()
    stage.set_size(500, 500)
    stage.set_color(clutter.color_from_string("#FFF"))

    rect1, rect2, rect3 = clutter.Rectangle(), clutter.Rectangle(),
    clutter.Rectangle()
    group1, group2, group3 = G(), clutter.Group(), clutter.Group()

    group1.add(rect1, group2)
    group2.add(rect2, group3)
    group3.add(rect3)

    group1.set_position(100, 100)
    group2.set_position(100, 100)
    group3.set_position(100, 100)

    rect1.set_position(0, 0)
    rect2.set_position(0, 0)
    rect3.set_position(0, 0)

    rect1.set_size(150, 150)
    rect2.set_size(150, 150)
    rect3.set_size(150, 150)

    rect1.set_color(clutter.color_from_string("#FF000090"))
    rect2.set_color(clutter.color_from_string("#00FF0090"))
    rect3.set_color(clutter.color_from_string("#0000FF90"))

    stage.add(group1)

    stage.show_all()
    group1.show_all()
    group2.show_all()
    group3.show_all()

    stage.connect("key-press-event", clutter.main_quit)
    stage.connect('destroy', clutter.main_quit)
    stage.connect('motion-event', xy)

    path = clutter.Path('M 0 0 L 300 0 L 300 300 L 0 300z')
    timeline = clutter.Timeline(4000)
    timeline.set_loop(True)
    alpha = clutter.Alpha(timeline,clutter.EASE_OUT_SINE)
    p_behaviour = clutter.BehaviourPath(alpha, path)
    path.add_move_to(0, 0)
    p_behaviour.apply(group3)

    timeline.add_marker_at_time("foo",2000)

    timeline.start()

    t=clutter.Timeline(1000)
    t.set_loop(True)
    t.connect('new-frame', boo, group1)
    t.start()

    clutter.main()

    if __name__ == '__main__':
    main()

    \d

    --
    Fonty Python and Things! -- http://otherwise.relics.co.za/wiki/Software
     
    donn, Feb 5, 2010
    #1
    1. Advertising

  2. donn

    Aahz Guest

    Aahz, Feb 9, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JDS

    Anyone?? Anyone at all??

    JDS, Sep 26, 2005, in forum: HTML
    Replies:
    2
    Views:
    395
    Montgomery BOO...URNS
    Sep 29, 2005
  2. Steve Williams

    Anyone? Anyone?

    Steve Williams, Sep 16, 2003, in forum: Python
    Replies:
    0
    Views:
    394
    Steve Williams
    Sep 16, 2003
  3. donn

    pyclutter anyone?

    donn, Feb 5, 2010, in forum: Python
    Replies:
    0
    Views:
    223
  4. craf

    About list Pyclutter

    craf, Apr 2, 2011, in forum: Python
    Replies:
    0
    Views:
    185
  5. craf

    about Pyclutter

    craf, Apr 2, 2011, in forum: Python
    Replies:
    0
    Views:
    183
Loading...

Share This Page