示例#1
0
 def insertBPoint(self,
                  index,
                  type=None,
                  anchor=None,
                  bcpIn=None,
                  bcpOut=None,
                  bPoint=None):
     """
     Insert a bPoint at index in the contour.
     """
     if bPoint is not None:
         if type is None:
             type = bPoint.type
         if anchor is None:
             anchor = bPoint.anchor
         if bcpIn is None:
             bcpIn = bPoint.bcpIn
         if bcpOut is None:
             bcpOut = bPoint.bcpOut
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._insertBPoint(index=index,
                        type=type,
                        anchor=anchor,
                        bcpIn=bcpIn,
                        bcpOut=bcpOut)
示例#2
0
 def appendBPoint(self,
                  type=None,
                  anchor=None,
                  bcpIn=None,
                  bcpOut=None,
                  bPoint=None):
     """
     Append a bPoint to the contour.
     """
     if bPoint is not None:
         if type is None:
             type = bPoint.type
         if anchor is None:
             anchor = bPoint.anchor
         if bcpIn is None:
             bcpIn = bPoint.bcpIn
         if bcpOut is None:
             bcpOut = bPoint.bcpOut
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._appendBPoint(type, anchor, bcpIn=bcpIn, bcpOut=bcpOut)
示例#3
0
 def insertBPoint(self,
                  index,
                  type,
                  anchor,
                  bcpIn=None,
                  bcpOut=None,
                  **kwargs):
     """
     Insert a bPoint at index in the contour.
     """
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._insertBPoint(index=index,
                        type=type,
                        anchor=anchor,
                        bcpIn=bcpIn,
                        bcpOut=bcpOut,
                        **kwargs)
示例#4
0
 def appendBPoint(self, type, anchor, bcpIn=None, bcpOut=None):
     """
     Append a bPoint to the contour.
     """
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._appendBPoint(type, anchor, bcpIn=bcpIn, bcpOut=bcpOut)
示例#5
0
 def insertSegment(self,
                   index,
                   type=None,
                   points=None,
                   smooth=False,
                   segment=None):
     """
     Insert a segment into the contour.
     """
     if segment is not None:
         if type is not None:
             type = segment.type
         if points is None:
             points = [(point.x, point.y) for point in segment.points]
         smooth = segment.smooth
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._insertSegment(index=index,
                         type=type,
                         points=points,
                         smooth=smooth)
示例#6
0
 def insertPoint(self, index, position=None, type="line", smooth=False, name=None, identifier=None, point=None):
     """
     Insert a point into the contour.
     """
     if point is not None:
         if position is None:
             position = point.position
         type = point.type
         smooth = point.smooth
         if name is None:
             name = point.name
         if identifier is not None:
             identifier = point.identifier
     index = normalizers.normalizeIndex(index)
     position = normalizers.normalizeCoordinateTuple(position)
     type = normalizers.normalizePointType(type)
     smooth = normalizers.normalizeBoolean(smooth)
     if name is not None:
         name = normalizers.normalizePointName(name)
     if identifier is not None:
         identifier = normalizers.normalizeIdentifier(identifier)
     self._insertPoint(
         index,
         position=position,
         type=type,
         smooth=smooth,
         name=name,
         identifier=identifier
     )
示例#7
0
 def insertPoint(self, index, position=None, type="line", smooth=False, name=None, identifier=None, point=None):
     """
     Insert a point into the contour.
     """
     if point is not None:
         if position is None:
             position = point.position
         type = point.type
         smooth = point.smooth
         if name is None:
             name = point.name
         if identifier is not None:
             identifier = point.identifier
     index = normalizers.normalizeIndex(index)
     position = normalizers.normalizeCoordinateTuple(position)
     type = normalizers.normalizePointType(type)
     smooth = normalizers.normalizeBoolean(smooth)
     if name is not None:
         name = normalizers.normalizePointName(name)
     if identifier is not None:
         identifier = normalizers.normalizeIdentifier(identifier)
     self._insertPoint(
         index,
         position=position,
         type=type,
         smooth=smooth,
         name=name,
         identifier=identifier
     )
示例#8
0
    def appendGuideline(self, position, angle, name=None, color=None):
        """
        Append a new guideline to the font.

            >>> guideline = font.appendGuideline((50, 0), 90)
            >>> guideline = font.appendGuideline((0, 540), 0, name="overshoot",
            >>> color=(0, 0, 0, 0.2))

        **position** must be a :ref:`type-coordinate`
        indicating the position of the guideline.
        **angle** indicates the :ref:`type-angle` of
        the guideline. **name** indicates the name
        for the guideline. This must be a :ref:`type-string`
        or ``None``. **color** indicates the color for
        the guideline. This must be a :ref:`type-color`
        or ``None``. This will return the newly created
        :class:`BaseGuidline` object.
        """
        position = normalizers.normalizeCoordinateTuple(position)
        angle = normalizers.normalizeGuidelineAngle(angle)
        if name is not None:
            name = normalizers.normalizeGuidelineName(name)
        if color is not None:
            color = normalizers.normalizeColor(color)
        return self._appendGuideline(position, angle, name=name, color=color)
示例#9
0
    def pointInside(self, point):
        """
        Determine if point is in the black or white of the component.

        point must be an (x, y) tuple.
        """
        point = normalizers.normalizeCoordinateTuple(point)
        return self._pointInside(point)
示例#10
0
    def pointInside(self, point):
        """
        Determine if point is in the black or white of the component.

        point must be an (x, y) tuple.
        """
        point = normalizers.normalizeCoordinateTuple(point)
        return self._pointInside(point)
示例#11
0
    def pointInside(self, point):
        """
        Determine if ``point`` is in the black or white of the contour.

            >>> contour.pointInside((40, 65))
            True

        ``point`` must be a :ref:`type-coordinate`.
        """
        point = normalizers.normalizeCoordinateTuple(point)
        return self._pointInside(point)
示例#12
0
    def pointInside(self, point):
        """
        Determine if ``point`` is in the black or white of the contour.

            >>> contour.pointInside((40, 65))
            True

        ``point`` must be a :ref:`type-coordinate`.
        """
        point = normalizers.normalizeCoordinateTuple(point)
        return self._pointInside(point)
示例#13
0
 def appendSegment(self, type, points, smooth=False):
     """
     Append a segment to the contour.
     """
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._appendSegment(type=type, points=points, smooth=smooth)
示例#14
0
 def appendBPoint(self, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None):
     """
     Append a bPoint to the contour.
     """
     if bPoint is not None:
         if type is None:
             type = bPoint.type
         if anchor is None:
             anchor = bPoint.anchor
         if bcpIn is None:
             bcpIn = bPoint.bcpIn
         if bcpOut is None:
             bcpOut = bPoint.bcpOut
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._appendBPoint(type, anchor, bcpIn=bcpIn, bcpOut=bcpOut)
示例#15
0
 def insertSegment(self, index, type, points, smooth=False):
     """
     Insert a segment into the contour.
     """
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._insertSegment(index=index, type=type,
                         points=points, smooth=smooth)
示例#16
0
 def insertBPoint(self, index, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None):
     """
     Insert a bPoint at index in the contour.
     """
     if bPoint is not None:
         if type is None:
             type = bPoint.type
         if anchor is None:
             anchor = bPoint.anchor
         if bcpIn is None:
             bcpIn = bPoint.bcpIn
         if bcpOut is None:
             bcpOut = bPoint.bcpOut
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._insertBPoint(index=index, type=type, anchor=anchor,
                        bcpIn=bcpIn, bcpOut=bcpOut)
示例#17
0
 def appendSegment(self, type=None, points=None, smooth=False, segment=None):
     """
     Append a segment to the contour.
     """
     if segment is not None:
         if type is not None:
             type = segment.type
         if points is None:
             points = [(point.x, point.y) for point in segment.points]
         smooth = segment.smooth
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._appendSegment(type=type, points=points, smooth=smooth)
示例#18
0
文件: base.py 项目: moyogo/fontparts
    def rotateBy(self, value, origin=None):
        """
        Rotate the object.

            >>> obj.transformBy(45)
            >>> obj.transformBy(45, origin=(500, 500))

        **value** must be a :ref:`type-int-float` values
        defining the angle to rotate the object by. **origin**
        defines the point at with the rotation should originate.
        It must be a :ref:`type-coordinate` or ``None``.
        The default is ``(0, 0)``.
        """
        value = normalizers.normalizeRotationAngle(value)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        self._rotateBy(value, origin=origin)
示例#19
0
    def rotateBy(self, value, origin=None):
        """
        Rotate the object.

            >>> obj.transformBy(45)
            >>> obj.transformBy(45, origin=(500, 500))

        **value** must be a :ref:`type-int-float` values
        defining the angle to rotate the object by. **origin**
        defines the point at with the rotation should originate.
        It must be a :ref:`type-coordinate` or ``None``.
        The default is ``(0, 0)``.
        """
        value = normalizers.normalizeTransformationRotationAngle(value)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        self._rotateBy(value, origin=origin)
示例#20
0
文件: base.py 项目: moyogo/fontparts
    def scaleBy(self, value, origin=None):
        """
        Scale the object.

            >>> obj.transformBy(2.0)
            >>> obj.transformBy((0.5, 2.0), origin=(500, 500))

        **value** must be an iterable containing two
        :ref:`type-int-float` values defining the x and y
        values to scale the object by. **origin** defines the
        point at with the scale should originate. It must be
        a :ref:`type-coordinate` or ``None``. The default is
        ``(0, 0)``.
        """
        value = normalizers.normalizeTransformationScale(value)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        self._scaleBy(value, origin=origin)
示例#21
0
    def scaleBy(self, value, origin=None):
        """
        Scale the object.

            >>> obj.transformBy(2.0)
            >>> obj.transformBy((0.5, 2.0), origin=(500, 500))

        **value** must be an iterable containing two
        :ref:`type-int-float` values defining the x and y
        values to scale the object by. **origin** defines the
        point at with the scale should originate. It must be
        a :ref:`type-coordinate` or ``None``. The default is
        ``(0, 0)``.
        """
        value = normalizers.normalizeTransformationScale(value)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        self._scaleBy(value, origin=origin)
示例#22
0
    def skewBy(self, value, origin=None):
        """
        Skew the object.

            >>> obj.skewBy(11)
            >>> obj.skewBy((25, 10), origin=(500, 500))

        **value** must be rone of the following:

        * single :ref:`type-int-float` indicating the
          value to skew the x direction by.
        * iterable cointaining type :ref:`type-int-float`
          defining the values to skew the x and y directions by.

        **origin** defines the point at with the skew should
        originate. It must be a :ref:`type-coordinate` or
        ``None``. The default is ``(0, 0)``.
        """
        value = normalizers.normalizeTransformationSkewAngle(value)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        self._skewBy(value, origin=origin)
示例#23
0
文件: base.py 项目: moyogo/fontparts
    def skewBy(self, value, origin=None):
        """
        Skew the object.

            >>> obj.skewBy(11)
            >>> obj.skewBy((25, 10), origin=(500, 500))

        **value** must be rone of the following:

        * single :ref:`type-int-float` indicating the
          value to skew the x direction by.
        * iterable cointaining type :ref:`type-int-float`
          defining the values to skew the x and y directions by.

        **origin** defines the point at with the skew should
        originate. It must be a :ref:`type-coordinate` or
        ``None``. The default is ``(0, 0)``.
        """
        value = normalizers.normalizeTransformationSkewAngle(value)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        self._skewBy(value, origin=origin)
示例#24
0
文件: base.py 项目: moyogo/fontparts
    def transformBy(self, matrix, origin=None):
        """
        Transform the object.

            >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0))
            >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))

        **matrix** must be a :ref:`type-transformation`.
        **origin** defines the point at with the transformation
        should originate. It must be a :ref:`type-coordinate`
        or ``None``. The default is ``(0, 0)``.
        """
        matrix = normalizers.normalizeTransformationMatrix(matrix)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        if origin is not None:
            t = transform.Transform()
            oX, oY = origin
            t = t.translate(oX, oY)
            t = t.transform(matrix)
            t = t.translate(-oX, -oY)
            matrix = tuple(t)
        self._transformBy(matrix)
示例#25
0
    def transformBy(self, matrix, origin=None):
        """
        Transform the object.

            >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0))
            >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))

        **matrix** must be a :ref:`type-transformation`.
        **origin** defines the point at with the transformation
        should originate. It must be a :ref:`type-coordinate`
        or ``None``. The default is ``(0, 0)``.
        """
        matrix = normalizers.normalizeTransformationMatrix(matrix)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        if origin is not None:
            t = transform.Transform()
            oX, oY = origin
            t = t.translate(oX, oY)
            t = t.transform(matrix)
            t = t.translate(-oX, -oY)
            matrix = tuple(t)
        self._transformBy(matrix)
示例#26
0
 def _get_base_anchor(self):
     value = self._get_anchor()
     value = normalizers.normalizeCoordinateTuple(value)
     return value
示例#27
0
 def _get_base_position(self):
     value = self._get_position()
     value = normalizers.normalizeCoordinateTuple(value)
     return value
示例#28
0
 def _set_base_position(self, value):
     value = normalizers.normalizeCoordinateTuple(value)
     self._set_position(value)
示例#29
0
文件: base.py 项目: moyogo/fontparts
 def _set_base_position(self, value):
     value = normalizers.normalizeCoordinateTuple(value)
     self._set_position(value)
示例#30
0
文件: base.py 项目: moyogo/fontparts
 def _get_base_position(self):
     value = self._get_position()
     value = normalizers.normalizeCoordinateTuple(value)
     return value
示例#31
0
 def _get_base_bcpOut(self):
     value = self._get_bcpOut()
     value = normalizers.normalizeCoordinateTuple(value)
     return value
示例#32
0
 def _set_base_bcpOut(self, value):
     value = normalizers.normalizeCoordinateTuple(value)
     self._set_bcpOut(value)
示例#33
0
 def _set_base_anchor(self, value):
     value = normalizers.normalizeCoordinateTuple(value)
     self._set_anchor(value)
示例#34
0
 def _get_base_anchor(self):
     value = self._get_anchor()
     value = normalizers.normalizeCoordinateTuple(value)
     return value
示例#35
0
 def _set_base_anchor(self, value):
     value = normalizers.normalizeCoordinateTuple(value)
     self._set_anchor(value)
示例#36
0
 def _set_base_bcpOut(self, value):
     value = normalizers.normalizeCoordinateTuple(value)
     self._set_bcpOut(value)
示例#37
0
 def _get_base_bcpOut(self):
     value = self._get_bcpOut()
     value = normalizers.normalizeCoordinateTuple(value)
     return value