Exemple #1
0
    def apply_angle_scale_trans(self, angle, scale, trans, point=Vector(0, 0)):
        '''Update matrix transformation by adding new angle, scale and translate.

        :Parameters:
            `angle` : float
                Rotation angle to add
            `scale` : float
                Scaling value to add
            `trans` : Vector
                Vector translation to add
            `point` : Vector, default to (0, 0)
                Point to apply transformation
        '''
        old_scale = self.scale
        new_scale = old_scale * scale
        if new_scale < self.scale_min or old_scale > self.scale_max:
            scale = 1

        t = translation_matrix((trans[0]*self._do_translation_x, trans[1]*self._do_translation_y, 0))
        t = matrix_multiply(t, translation_matrix( (point[0], point[1], 0)))
        t = matrix_multiply(t, rotation_matrix(angle, (0, 0, 1)))
        t = matrix_multiply(t, scale_matrix(scale))
        t = matrix_multiply(t, translation_matrix((-point[0], -point[1], 0)))
        self.apply_transform(t)

        self.dispatch_event('on_transform', None)
Exemple #2
0
    def apply_angle_scale_trans(self, angle, scale, trans, point=Vector(0, 0)):
        '''Update matrix transformation by adding new angle, scale and translate.

        :Parameters:
            `angle` : float
                Rotation angle to add
            `scale` : float
                Scaling value to add
            `trans` : Vector
                Vector translation to add
            `point` : Vector, default to (0, 0)
                Point to apply transformation
        '''
        old_scale = self.scale
        new_scale = old_scale * scale
        if new_scale < self.scale_min or old_scale > self.scale_max:
            scale = 1

        t = translation_matrix((trans[0] * self._do_translation_x,
                                trans[1] * self._do_translation_y, 0))
        t = matrix_multiply(t, translation_matrix((point[0], point[1], 0)))
        t = matrix_multiply(t, rotation_matrix(angle, (0, 0, 1)))
        t = matrix_multiply(t, scale_matrix(scale))
        t = matrix_multiply(t, translation_matrix((-point[0], -point[1], 0)))
        self.apply_transform(t)

        self.dispatch_event('on_transform', None)
Exemple #3
0
    def apply_transform(self, trans, post_multiply=False, anchor=(0, 0)):
        '''
        Transforms scatter by trans (on top of its current transformation state)

        :Parameters:
            `trans`: transformation matrix from transformation lib.
                Transformation to be applied to the scatter widget
            `anchor`: tuple, default to (0, 0)
                The point to use as the origin of the transformation
                (uses local widget space)
            `post_multiply`: bool, default to False
                If true the transform matrix is post multiplied
                (as if applied before the current transform)
        '''
        t = translation_matrix((anchor[0], anchor[1], 0))
        t = matrix_multiply(t, trans)
        t = matrix_multiply(t, translation_matrix((-anchor[0], -anchor[1], 0)))

        if post_multiply:
            self.transform = matrix_multiply(self._transform, t)
        else:
            self.transform = matrix_multiply(t, self._transform)
Exemple #4
0
    def apply_transform(self, trans, post_multiply=False, anchor=(0, 0)):
        '''
        Transforms scatter by trans (on top of its current transformation state)

        :Parameters:
            `trans`: transformation matrix from transformation lib.
                Transformation to be applied to the scatter widget
            `anchor`: tuple, default to (0, 0)
                The point to use as the origin of the transformation
                (uses local widget space)
            `post_multiply`: bool, default to False
                If true the transform matrix is post multiplied
                (as if applied before the current transform)
        '''
        t = translation_matrix( (anchor[0], anchor[1], 0) )
        t = matrix_multiply(t, trans)
        t = matrix_multiply(t, translation_matrix( (-anchor[0], -anchor[1], 0) ))

        if post_multiply:
            self.transform = matrix_multiply(self._transform, t)
        else:
            self.transform = matrix_multiply(t, self._transform)
Exemple #5
0
 def to_local(self, x, y, **k):
     p = matrix_multiply(self._transform_inv, (x, y, 0, 1))
     return (p[0], p[1])
Exemple #6
0
 def to_parent(self, x, y, **k):
     p = matrix_multiply(self._transform, (x, y, 0, 1))
     return (p[0], p[1])
Exemple #7
0
 def to_local(self, x, y, **k):
     p = matrix_multiply(self._transform_inv, (x, y, 0, 1))
     return (p[0], p[1])
Exemple #8
0
 def to_parent(self, x, y, **k):
     p = matrix_multiply(self._transform, (x, y, 0, 1))
     return (p[0], p[1])