def GetHandles(self):
     a = self.properties
     if self.caret > 0 and self.trafos:
         # special case to deal with here: the characters that fall
         # off the end of the path are not visible. If the caret is
         # in this invisible area, display the caret after the last
         # visible character
         caret = 1
         index = min(self.caret, len(self.text), len(self.trafos)) - 1
         text = self.text[index]
         trafo = self.trafos[index]
     else:
         caret = 0
         if self.text and self.trafos:
             text = self.text[0]
             trafo = self.trafos[0]
         else:
             # XXX fix this
             self.start_point = self.paths[0].point_at(self.start_pos)
             return [handle.MakeNodeHandle(self.start_point, 1)]
     pos, up = a.font.TextCaretData(text, caret, a.font_size, a)
     pos = trafo(pos)
     up = trafo.DTransform(up)
     self.start_point = self.trafos[0].offset()
     return [
         handle.MakeCaretHandle(pos, up),
         handle.MakeNodeHandle(self.start_point, 1)
     ]
예제 #2
0
 def GetHandles(self):
     trafo = self.trafo
     start_angle = self.start_angle; end_angle = self.end_angle
     p1 = trafo(cos(self.start_angle), sin(self.start_angle))
     if start_angle == end_angle:
         return [handle.MakeNodeHandle(p1)]
     p2 = trafo(cos(self.end_angle), sin(self.end_angle))
     return [handle.MakeNodeHandle(p1), handle.MakeNodeHandle(p2)]
예제 #3
0
    def GetHandles(self):
        trafo = self.trafo
        radius1 = self.radius1
        radius2 = self.radius2
        handles = []

        if radius1 == radius2 == 0:
            for x, y, code in ((0, 0, -1), (1, 0, -2), (0, 1, -3), (1, 1, -4),
                               (0.5, 0, 1), (1.0, 0.5, 2), (0.5, 1.0,
                                                            3), (0, 0.5, 4)):
                h = handle.MakeNodeHandle(trafo(x, y))
                h.x_code = code
                handles.append(h)
        else:
            # horizontal edges
            if round(radius1, 3) >= 0.5:
                h = handle.MakeNodeHandle(trafo(0.5, 0))
                h.x_code = -5
                handles.append(h)
                h = handle.MakeNodeHandle(trafo(0.5, 1))
                h.x_code = -7
                handles.append(h)
            else:
                coords = ((radius1, 0, 5), (0.5, 0, 1), (1 - radius1, 0, 6),
                          (radius1, 1, 7), (0.5, 1, 3), (1 - radius1, 1, 8))
                for x, y, code in coords:
                    h = handle.MakeNodeHandle(trafo(x, y))
                    h.x_code = code
                    handles.append(h)

            # vertical edges
            if round(radius2, 3) >= 0.5:
                h = handle.MakeNodeHandle(trafo(0, 0.5))
                h.x_code = -9
                handles.append(h)
                h = handle.MakeNodeHandle(trafo(1, 0.5))
                h.x_code = -11
                handles.append(h)
            else:
                coords = ((0, radius2, 9), (0, 0.5, 4), (0, 1 - radius2, 10),
                          (1, radius2, 11), (1, 0.5, 2), (1, 1 - radius2, 12))
                for x, y, code in coords:
                    h = handle.MakeNodeHandle(trafo(x, y))
                    h.x_code = code
                    handles.append(h)
        #
        return handles