Re: Drawing on Clutter Contents



Hi,

Cairo uses floating point values from 0.0 to 1.0 for colors, but apart
from that your code should work with Clutter 1.16. For earlier versions
you have to put the canvas into an extra actor instead of the stage.

So long

:wq buz

On Thu, Oct 03, 2013 at 10:34:03PM +0200, Alessandro Re wrote:
Hello,
I was trying to draw with Cairo on a Content, but nothing shows up. I saw
some examples (included the one in the reference), but I can not see (what
I think are) notable differences.

Here's my code, can you please tell me what I am missing?

Thanks!

#!/usr/bin/env python3

import sys
from gi.repository import Clutter as clu
import cairo

def quit(*args):
    clu.main_quit()

def draw_something(canvas, ctx, w, h):
    ctx.set_source_rgb(0xff, 0x00, 0xff)
    ctx.set_line_width(3)
    ctx.move_to(0, 0)
    ctx.line_to(w, h)
    ctx.stroke()
    return True

#def invalidate(canvas):
#    canvas.invalidate()
#    return True

if __name__ == '__main__':
    clu.init(sys.argv)

    black = clu.Color.new(0x00, 0x00, 0x00, 0xff)

    stage = clu.Stage()
    stage.set_color(black)
    stage.set_size(200, 200)
    stage.connect('destroy', quit)
    stage.show()

    canvas = clu.Canvas()
    canvas.set_size(200, 200)
    canvas.connect('draw', draw_something)

    stage.set_content(canvas)

#    clu.threads_add_timeout(0, 1000, invalidate, canvas)

    canvas.invalidate()
    clu.main()


~Alessandro

_______________________________________________
clutter-list mailing list
clutter-list gnome org
https://mail.gnome.org/mailman/listinfo/clutter-list


-- 
GnuPG Fingerprint: 2FFF FC48 C7DF 1EA0 00A0  FD53 8C35 FD2E 6908 7B82

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]