hi,

this happens because you're changing the alpha value of your _color
instance on every redraw. This should give you the expected behaviour:

paint_color = self._color.copy()


So long

:wq buz

On Thu, Feb 12, 2009 at 05:08:56PM -0300, Eduardo Matus wrote:
> hello, I'm testing a custom actor made with cogl, I apply the scale and
> opacity behaviour, but with the opacity behaviour does not work (nothing is
> showed), but instead of use a custom texture I use a clutter.Rectangle and
> it works... so maybe is a bug or I'm doing something wrog.. anyone can test
> it?
> 
> thks!
> 
> 
> import gobject
> import clutter
> from clutter import cogl
> 
> class roundRec(clutter.Rectangle):
> 
> 
>     __gtype_name__ = 'roundRec'
>     __gproperties__ = {'color':(str, 'color', 'Color', None,
> gobject.PARAM_READWRITE),}
> 
> 
>     def __init__(self):
>         clutter.Rectangle.__init__(self)
>         self._color = clutter.color_parse("red")
> 
>     def set_color(self, color):
>         self._color = clutter.color_parse(color)
> 
>     def do_set_property(self, pspec, value):
>         if pspec.name == 'color':
>             self._color = clutter.color_parse(value)
>         else:
>             raise TypeError('Unknown property '+pspec.name)
> 
>     def do_get_property(self, pspec):
>         if pspec.name == 'color':
>             return self._color
>         else:
>             raise TypeError('Unknown property '+pspec.name)
> 
>     def do_paint(self):
>         (x1, y1, x2, y2) = self.get_allocation_box()
>         paint_color = self._color
>         real_alpha = self.get_paint_opacity() * paint_color.alpha/255
>         paint_color.alpha = real_alpha
> 
>         w = int(x2-x1)
>         h = int(y2-y1)
>         cogl.color(paint_color)
>         clutter.cogl.path_round_rectangle(0, 0, w, h, 30, 15)
>         clutter.cogl.path_fill()
> 
> 
> def startEffect(stage, event, timeline, actor):
>     actor.set_opacity(0)
>     actor.show()
>     timeline.start()
> 
> if __name__ == '__main__':
>     s = clutter.Stage()
>     s.set_size(800, 600)
> 
> 
>     t = roundRec()
>     t.set_size(400,200)
>     s.add(t)
>     t.set_position(15,15)
>     t.hide()
> 
> 
>     timeline = clutter.Timeline(fps=25, duration=1000)
>     alpha = clutter.Alpha(timeline, clutter.sine_inc_func)
>     bh = clutter.BehaviourScale(0, 0, 1.0, 1.0, alpha)
>     bho = clutter.BehaviourOpacity(0, 255, alpha)
> 
>     bh.apply(t) #scale
>     bho.apply(t) #opacity
> 
>     s.connect('destroy', clutter.main_quit)
>     s.connect('button-press-event', startEffect, timeline, t)
>     s.show()
>     clutter.main()

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

Attachment: signature.asc
Description: Digital signature

Reply via email to