def mouseDragged(self, mousePoint, delta): if self.snatchedPoint is not None: snatchedPoint = self.snatchedPoint cut = False self._roundedGlyph = IntelGlyph(self._sourceGlyph) i1, i2 = self.getRoundedPointIndices(snatchedPoint) dx = snatchedPoint[0]-mousePoint[0] dy = snatchedPoint[1]-mousePoint[1] d = hypot(dx, dy) if self.shiftDown: d = round(d/5)*5 d = int(d) limit = self.getLimit(snatchedPoint) if d > limit: d = limit if self.shiftDown and self.commandDown: d = 0 if self.optionDown: cut = True self._roundedGlyph[i1][i2].labels['cornerRadius'] = d self._roundedGlyph[i1][i2].labels['cut'] = cut self._roundedGlyph.drawCornersByLabels() snatchedPoint.labels['cornerRadius'] = d snatchedPoint.labels['cut'] = cut self.snatchedPoint = snatchedPoint
def getSelection(self, notification=None): glyph = CurrentGlyph() if len(glyph.selection) == 0: return [] elif len(glyph.selection) > 0: iG = IntelGlyph(glyph) if self.currentMode == 'Build': selection = iG.getSelection(True) elif self.currentMode in ['Break', 'Pit']: selection = [point for point in iG.getSelection() if (point.segmentType is not None) and (abs(point.turn()) > pi/18)] return selection
def breakCorners(self): g = CurrentGlyph() iG = IntelGlyph(g) radius = self.parameters['radius'].get() roundness = self.parameters['roundness'].get() for contour in iG: selection = contour.getSelection() for point in selection: contour.breakCorner(point, radius, velocity=roundness) contour.correctSmoothness() return iG
def pitCorners(self): g = CurrentGlyph() iG = IntelGlyph(g) depth = self.parameters['depth'].get() breadth = self.parameters['breadth'].get() bottom = self.parameters['bottom'].get() for contour in iG: selection = contour.getSelection() for point in selection: contour.pitCorner(point, depth, breadth, bottom) contour.removeOverlappingPoints() contour.correctSmoothness() return iG
def updateRoundablePoints(self): glyph = self._sourceGlyph = self.getGlyph() if glyph is not None: workingGlyph = IntelGlyph(glyph) self._roundedGlyph = IntelGlyph(glyph) self._roundedGlyph.drawCornersByLabels() roundablePoints = [] for contour in workingGlyph: closed = contour.isClosed for point in contour: nextPoint = point.next() previousPoint = point.previous() turnLimit = abs(point.turn()) < (10/180)*pi if (point.segmentType is not None) and \ (self.getLimit(point) > 0) and \ (closed or (not closed and (not point.isFirst()) and (not point.isLast()))) and \ (((previousPoint.segmentType is not None) and (nextPoint.segmentType is not None)) or \ ((previousPoint.segmentType is None) and (nextPoint.segmentType is not None) and not turnLimit and not point.smooth) or \ ((previousPoint.segmentType is not None) and (nextPoint.segmentType is None) and not turnLimit and not point.smooth)): roundablePoints.append(point) self.roundablePoints = roundablePoints self._workingGlyph = workingGlyph
def buildCorners(self): g = CurrentGlyph() iG = IntelGlyph(g) for contour in iG: segments = contour.collectSegments()['selection'] l = len(segments) lines, curves = self.checkComposition(segments) if l > 1 and lines and curves: segments = [segment for segment in segments if len(segment) == 4] elif l > 1 and lines and not curves: segments = segments[:1] + segments[-1:] for segment in reversed(segments): contour.buildCorner(segment) return iG