Hey Martin!

I'm forwarding this message to the clutter-mailinglist, as it seems you
have missed to reply back to the list (reply-all).

-------- Original-Message --------
Subject: Re: [clutter] zoom effect

> My guess for the "curve effect" would be that scaling is applied from
> (0, 0), i.e. from top-left of the actor (or here: stage). While moving
> to the position, the position moves away from you via scaling. I could
> be wrong though, as I've not seen the effect myself :) .
>
> I would suggest that you use set_depth for zooming. Set the depth of
> your group large enough so that you have a nice overview of the slides
> and in your do_alpha_notify function set it back to zero (assuming that
> one slide fills the stage at a depth of zero).
>
> Hope that helps :)
> - Sven

Sven, thanks for your tips. I was under the impression that the depth
of the actors is only used for the stacking order. I did some
experiments with set_depth and set_depthu and the appearance (size) of
the actor that does not change regardless of the size I use.

I found a solution that results in the correct effect. It works by
simultaneously shifting the actor and changing the perspective of the
stage. However, the field of view angle of the stage has to be changed
in a nonlinear way, otherwise the zoom effect appears nonlinear like
when changing the scale of the stage.

For anyone interested the code for this is:

class ZoomRect(clutter.Behaviour):
    __gtype_name__ = 'BehaviourZoomRect'
    def __init__(self, alpha, actor, stage):
        clutter.Behaviour.__init__(self)
        self.set_alpha(alpha)
        self.actor = actor
        self.stage = stage
    def set_shift_range(self, start_x, start_y, end_x, end_y):
        self.start_x = start_x
        self.start_y = start_y
        self.end_x = end_x
        self.end_y = end_y
        self.dx = (1.0*(self.end_x - self.start_x))/clutter.MAX_ALPHA
        self.dy = (1.0*(self.end_y - self.start_y))/clutter.MAX_ALPHA
    def set_fovy_range(self, fovy_start, fovy_end):
        self.tan_start = math.tan((math.pi * fovy_start)/180.0)
        self.tan_end   = math.tan((math.pi * fovy_end)/180.0)
        self.d_tan     = (1.0*(self.tan_end -
self.tan_start))/clutter.MAX_ALPHA
    def do_alpha_notify (self, alpha_value):
        pos_x = self.start_x + alpha_value*self.dx
        pos_y = self.start_y + alpha_value*self.dy
        self.actor.set_position(pos_x, pos_y)
        fovy, aspect, z_near, z_far = self.stage.get_perspective()
        fovy = (180/math.pi)*math.atan(self.tan_start +
alpha_value*self.d_tan)
        self.stage.set_perspective(fovy, aspect, z_near, z_far)

best,

Martin


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to