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 _set_pos(self, pos):
     _pos = self.bbox[0]
     if pos == _pos:
         return
     t = Vector(*pos) - _pos
     trans = translation_matrix((t.x, t.y, 0))
     self.apply_transform(trans)
Exemple #4
0
 def _set_pos(self, pos):
     _pos = self.bbox[0]
     if pos == _pos:
         return
     t = Vector(*pos) - _pos
     trans = translation_matrix( (t.x, t.y, 0) )
     self.apply_transform(trans)
Exemple #5
0
 def _apply_drag(self, touch):
     #_last_touch_pos has last pos in correct parent space, just liek incoming touch
     dx = (touch.x -
           self._last_touch_pos[touch][0]) * self._do_translation_x
     dy = (touch.y -
           self._last_touch_pos[touch][1]) * self._do_translation_y
     self.apply_transform(translation_matrix((dx, dy, 0)))
     self.dispatch_event('on_transform', touch)
Exemple #6
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 #7
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 #8
0
 def _set_center(self, center):
     if center == self.center:
         return False
     t = Vector(*center) - self.center
     trans = translation_matrix((t.x, t.y, 0))
     self.apply_transform(trans)
Exemple #9
0
 def _apply_drag(self, touch):
     #_last_touch_pos has last pos in correct parent space, just liek incoming touch
     dx = (touch.x - self._last_touch_pos[touch][0]) * self._do_translation_x
     dy = (touch.y - self._last_touch_pos[touch][1]) * self._do_translation_y
     self.apply_transform(translation_matrix((dx, dy, 0)))
     self.dispatch_event('on_transform', touch)
Exemple #10
0
 def _set_center(self, center):
     if center == self.center:
         return False
     t = Vector(*center) - self.center
     trans = translation_matrix( (t.x, t.y, 0) )
     self.apply_transform(trans)