Exemplo n.º 1
0
 def _draw(self, info):
     currentTool = getActiveEventTool()
     view = currentTool.getNSView()
     if self.drawAtPoint:
         view._drawTextAtPoint("%i %i" %(self.x, self.y), textAttributes, self.drawAtPoint, yOffset=fontSize)
     else:
         print 'mouse is up'
Exemplo n.º 2
0
    def _drawBackground(self, infoDict):
        assert self.elementShape in SHAPE_OPTIONS

        glyph = infoDict['glyph']
        currentTool = getActiveEventTool()
        view = currentTool.getNSView()
        textAttributes = {
            NSFontAttributeName: NSFont.systemFontOfSize_(bodySizeCaption),
            NSForegroundColorAttributeName: NSColor.blackColor()
        }

        # load data if point is selected
        if PLUGIN_KEY in glyph.lib:
            for eachContour in glyph:
                for eachPt in eachContour.points:
                    if eachPt.selected is True and eachPt.type != 'offCurve' and eachPt.naked(
                    ).uniqueID in glyph.lib[PLUGIN_KEY]:
                        self.loadDataFromLib(glyph, eachPt.naked().uniqueID)

        # draw interpolateValued ovals
        if self.preview is True and PLUGIN_KEY in glyph.lib:
            self._drawElements(glyph, SUB_COLOR, 4, 'canvas')

        # draw master ovals
        if self.preview is True and PLUGIN_KEY in glyph.lib:
            for eachContour in glyph:
                for eachSegment in eachContour:
                    ID = eachSegment.onCurve.naked().uniqueID
                    if ID in glyph.lib[PLUGIN_KEY]:
                        elementDict = glyph.lib[PLUGIN_KEY][ID]
                        save()
                        fill(*MASTER_COLOR)
                        translate(eachSegment.onCurve.x, eachSegment.onCurve.y)
                        rotate(elementDict['angle'])

                        if self.elementShape == 'Oval':
                            oval(-elementDict['width'] / 2.,
                                 -elementDict['height'] / 2.,
                                 elementDict['width'], elementDict['height'])
                        else:
                            rect(-elementDict['width'] / 2.,
                                 -elementDict['height'] / 2.,
                                 elementDict['width'], elementDict['height'])
                        restore()

        # draw values
        if self.drawValues is True and PLUGIN_KEY in glyph.lib:
            for eachContour in glyph:
                for eachSegment in eachContour:
                    ID = eachSegment.onCurve.naked().uniqueID
                    if ID in glyph.lib[PLUGIN_KEY]:
                        nibData = glyph.lib[PLUGIN_KEY][ID]
                        values = '%s: %s\n%s: %s\n%s: %s' % (
                            'width', nibData['width'], 'height',
                            nibData['height'], 'angle', nibData['angle'])
                        view._drawTextAtPoint(
                            values,
                            textAttributes,
                            (eachSegment.onCurve.x, eachSegment.onCurve.y),
                            yOffset=2.8 * bodySizeCaption)
Exemplo n.º 3
0
 def _draw(self, info):
     currentTool = getActiveEventTool()
     view = currentTool.getNSView()
     if self.drawAtPoint:
         view._drawTextAtPoint("%i %i" %(self.x, self.y), textAttributes, self.drawAtPoint, yOffset=0, backgroundColor=bgColor, drawBackground=True, roundBackground=True)