Re: pyclutter anyone?

2010-02-09 Thread Aahz
In article ,
donn   wrote:
>
>No one uses pyClutter?

Never heard of it before.

>I have some code, it does not work, but maybe this will start to help 
>solve the problem:

You need to provide some more detail than "does not work".  Perhaps this
will help:

http://www.catb.org/~esr/faqs/smart-questions.html
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

import antigravity
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyclutter anyone?

2010-02-05 Thread donn

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("#FF90"))
rect2.set_color(clutter.color_from_string("#00FF0090"))
rect3.set_color(clutter.color_from_string("#FF90"))

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
--
http://mail.python.org/mailman/listinfo/python-list


pyclutter anyone?

2010-02-05 Thread donn
Hi, this is a little bit of a cross-post. I posted to the clutter list, 
but there's little activity there.


I am trying to make sense of pyClutter 1.0. Could anyone point me to an
example (or post one) that shows clipping from a path applied to child
objects?

For example: A star shape that contains a bunch of moving rectangles
which will travel/size/rotate with the star, but are clipped to the
shape of the star.

I suspect this will involve a custom clutter.Group class of some kind,
with cogl paths and an on_paint() method, but I can find no headway on
the web so far.

Hope someone can help!
\d

--
Fonty Python and Things! -- http://otherwise.relics.co.za/wiki/Software

--
http://mail.python.org/mailman/listinfo/python-list