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)
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)
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)
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)
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)
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 )
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 )
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
def _get_base_anchor(self): value = self._get_anchor() value = normalizers.normalizeCoordinateTuple(value) return value
def _get_base_position(self): value = self._get_position() value = normalizers.normalizeCoordinateTuple(value) return value
def _set_base_position(self, value): value = normalizers.normalizeCoordinateTuple(value) self._set_position(value)
def _set_base_position(self, value): value = normalizers.normalizeCoordinateTuple(value) self._set_position(value)
def _get_base_position(self): value = self._get_position() value = normalizers.normalizeCoordinateTuple(value) return value
def _get_base_bcpOut(self): value = self._get_bcpOut() value = normalizers.normalizeCoordinateTuple(value) return value
def _set_base_bcpOut(self, value): value = normalizers.normalizeCoordinateTuple(value) self._set_bcpOut(value)
def _set_base_anchor(self, value): value = normalizers.normalizeCoordinateTuple(value) self._set_anchor(value)
def _get_base_anchor(self): value = self._get_anchor() value = normalizers.normalizeCoordinateTuple(value) return value
def _set_base_anchor(self, value): value = normalizers.normalizeCoordinateTuple(value) self._set_anchor(value)
def _set_base_bcpOut(self, value): value = normalizers.normalizeCoordinateTuple(value) self._set_bcpOut(value)
def _get_base_bcpOut(self): value = self._get_bcpOut() value = normalizers.normalizeCoordinateTuple(value) return value