Hmm, it looks like there's something else at work here. I've tried a
threaded version and I'm still seeing the jumping; if I comment out
the thread-start it's fine. Code below; can anyone see what I'm doing
wrong here?
Thanks,
Steve
import sys, threading, gobject, clutter, cairo
from cluttercairo import CairoTexture
WIDTH = 800
HEIGHT = 800
STREAMLEN = 10 + 1
CHUNKLEN = float(WIDTH) / (STREAMLEN - 1)
SCROLLSTART=int(0)
SCROLLEND=int(-CHUNKLEN)
class StreamTexture(CairoTexture):
def __init__(self, colour):
CairoTexture.__init__(self, width=WIDTH+CHUNKLEN, height=HEIGHT)
self.colour = colour
self.hide()
def start(self):
# Define behaviour
self.timeline = clutter.Timeline(num_frames=int(CHUNKLEN), fps=60)
self.timeline.connect('started', streamstart)
self.timeline.connect('completed', streamend)
self.knots = ((SCROLLSTART, 0),
(SCROLLEND, 0 ),)
self.alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.behave = clutter.BehaviourPath(alpha=self.alpha, knots=self.knots)
self.behave.apply(self)
self.show()
self.timeline.start()
def clear(self, ctx):
ctx.set_operator (cairo.OPERATOR_CLEAR)
ctx.paint()
ctx.set_operator(cairo.OPERATOR_OVER)
def draw(self):
self.set_position(SCROLLSTART,0)
ctx = self.cairo_create()
self.clear(ctx)
ctx.set_source_rgba(*self.colour)
yoff = HEIGHT/2
xoff = 0
for section in range(STREAMLEN):
# Chunk
ex = xoff + CHUNKLEN - 4
ctx.move_to(xoff, yoff+48)
ctx.line_to(ex, yoff+48)
ctx.line_to(ex, yoff)
ctx.line_to(xoff, yoff)
ctx.close_path()
ctx.fill()
xoff += CHUNKLEN
# Simple flip-flop double-buffer
tex = {False : StreamTexture((0,1,0,1)),
True : StreamTexture((0,0,1,1))}
currtex = False
def streamend(tline):
global tex, currtex
print "Update"
tex[currtex].hide()
currtex = not currtex
tex[currtex].start()
def streamstart(tline):
global tex, currtex
print "start"
# FIXME: No locking here, but we should have plenty of time to
# draw this before it's shown
thread = threading.Thread(target=tex[not currtex].draw)
thread.run()
if __name__ == '__main__':
## Init
stage = clutter.Stage()
stage.connect('destroy', clutter.main_quit)
stage.connect('button-press-event', clutter.main_quit)
stage.connect('key-press-event', clutter.main_quit)
stage.set_size(WIDTH, HEIGHT)
stage.set_color(clutter.Color(0x0, 0x0, 0x0, 0xff))
stage.add(tex[currtex])
stage.add(tex[not currtex])
tex[currtex].draw()
tex[not currtex].draw()
# Go
stage.show()
tex[currtex].start()
clutter.main()
--
To unsubscribe send a mail to [EMAIL PROTECTED]