[cairo] Drawing a transparent rectangle on an Image

Mr SZ sk8in_zombi at yahoo.com.au
Tue Jul 15 07:37:40 PDT 2008


Hi,

I am drawing a semi transparent dotted rectangle on an image .What I want to do is to change the border ticks to alternate so they appear as if the ticks are moving around the rectangle.Here is the code that I wrote to draw the rectangle as such with hard coded co-ord for now :

def expose_event(widget, event, surface):

    ctx = widget.window.cairo_create()
    ctx.set_source_surface(surface, 0,0)
    ctx.paint()
    ctx.set_source_rgba(1, 1, 1,0.5)
    
    ctx.save()
    
    ctx.new_path()
    ctx.translate(3*20, 0)
    square(ctx)
    ctx.fill()

    ctx.restore()

    
    ctx.set_line_width(20 / 16)
    ctx.set_tolerance(0.1)
    ctx.set_line_join(cairo.LINE_JOIN_MITER)
    ctx.set_dash([20/2.0, 20/2.0], 8)

    ctx.save()

    ctx.new_path()
    ctx.set_source_rgba(0,0 ,0 ,0.5)
    ctx.translate(3*20, 0)
    square(ctx)
    ctx.stroke_preserve()

    ctx.restore()

Now I can change the ticks by changing the set_dash args but I don't want to put it in an infinite while loop.Also,I don't want it to be CPU intensive.


" life isn't heavy enough,it flies away and floats far above action"


      Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20080715/67d843d5/attachment.html 


More information about the cairo mailing list