示例#1
0
 def drawWithFrame_inView_(self, frame, view):
     if hasattr(self, '_path'):
         if not hasattr(self, '_image'):
             self._image = self._callbackTarget.imageForPath_(self._path)
             self.setTitle_(self._callbackTarget.titleForPath_(self._path))
         self._checkCell.setIntValue_(self._callbackTarget.stateForPath_(self._path))
         x = frame.origin.x
         y = frame.origin.y + 1
         height = frame.size.height - 1
         if self.state() or self.isHighlighted():
             highlight_rect = NSMakeRect(x, y, frame.size.width, height)
             if view.needsToDrawRect_(highlight_rect):
                 self.highlightColorInView_(view).set()
                 NSBezierPath.bezierPathWithRect_(highlight_rect).fill()
         x += CHECK_CELL_LEFT_PADDING
         checkCellSize = self._checkCell.cellSize()
         check_cell_rect = NSMakeRect(x, y, checkCellSize.width, height)
         if view.needsToDrawRect_(check_cell_rect):
             self._checkCell.drawWithFrame_inView_(check_cell_rect, view)
         x += checkCellSize.width - 1
         imageSize = self._image.size()
         image_rect = NSMakeRect(x, y, imageSize.width, imageSize.height)
         if view.needsToDrawRect_(image_rect):
             self._image.drawInRect_fromRect_operation_fraction_(image_rect, NSZeroRect, NSCompositeSourceOver, 1.0)
         x += imageSize.width + 4
         rest_of_cell_rect = NSMakeRect(x, y, frame.size.width - x, height)
         if view.needsToDrawRect_(rest_of_cell_rect):
             super(SelectiveSyncBrowserCell, self).drawWithFrame_inView_(rest_of_cell_rect, view)
     else:
         super(SelectiveSyncBrowserCell, self).drawWithFrame_inView_(frame, view)
示例#2
0
 def draw(self, scale):
     controlSoftColor = self.controlSoftColor
     controlStrongColor = self.controlStrongColor
     if self._roundedGlyph is not None:
         self._roundedGlyph.drawPreview(scale,
                                        styleFill=False,
                                        showNodes=False,
                                        strokeWidth=2,
                                        strokeColor=controlStrongColor)
     for point in self.roundablePoints:
         x, y = point.x, point.y
         (cx, cy), r = self.getControlPoint(point)
         controlSoftColor.set()
         controlStrongColor.setStroke()
         radiusCircle = NSBezierPath.bezierPathWithOvalInRect_(
             ((x - r, y - r), (r * 2, r * 2)))
         radiusCircle.fill()
         radiusCircle.setLineWidth_(scale)
         radiusCircle.stroke()
         controlStrongColor.set()
         cor = 12 * scale
         controlDot = NSBezierPath.bezierPathWithOvalInRect_(
             ((cx - cor, cy - cor), (cor * 2, cor * 2)))
         controlDot.fill()
         if point.labels['cornerRadius']:
             fill(1)
             fontSize(9 * scale)
             _r = str(r)
             textBox(_r, (cx - cor, cy - (cor * 1.5), cor * 2, cor * 2),
                     align='center')
示例#3
0
 def draw(self, scale):
     controlSoftColor = self.controlSoftColor
     controlStrongColor = self.controlStrongColor
     if self._roundedGlyph is not None:
         self._roundedGlyph.drawPreview(
             scale, styleFill=False, showNodes=False, strokeWidth=2, strokeColor=controlStrongColor
         )
     for point in self.roundablePoints:
         x, y = point.x, point.y
         (cx, cy), r = self.getControlPoint(point)
         controlSoftColor.set()
         controlStrongColor.setStroke()
         radiusCircle = NSBezierPath.bezierPathWithOvalInRect_(((x - r, y - r), (r * 2, r * 2)))
         radiusCircle.fill()
         radiusCircle.setLineWidth_(scale)
         radiusCircle.stroke()
         controlStrongColor.set()
         cor = 12 * scale
         controlDot = NSBezierPath.bezierPathWithOvalInRect_(((cx - cor, cy - cor), (cor * 2, cor * 2)))
         controlDot.fill()
         if point.labels["cornerRadius"]:
             fill(1)
             fontSize(9 * scale)
             _r = str(r)
             textBox(_r, (cx - cor, cy - (cor * 1.5), cor * 2, cor * 2), align="center")
示例#4
0
    def drawPoints(self, glyph, scale):
        save()
        _onCurveSize = self._onCurvePointsSize * scale
        _offCurveSize = self._offCurvePointsSize * scale
        _strokeWidth = self._strokeWidth * scale
        
        self._pointsColor.set()
        
        path = NSBezierPath.bezierPath()
        offCurveHandlesPath = NSBezierPath.bezierPath()
        pointsData = glyph.getRepresentation("doodle.OutlineInformation")
        
        for point1, point2 in pointsData["bezierHandles"]:
            offCurveHandlesPath.moveToPoint_(point1)
            offCurveHandlesPath.lineToPoint_(point2)

        for point in pointsData.get("offCurvePoints"):
            (x, y) = point["point"]
            path.appendBezierPathWithOvalInRect_(NSMakeRect(x - _offCurveSize, y - _offCurveSize, _offCurveSize * 2, _offCurveSize * 2))
            
        for point in pointsData.get("onCurvePoints"):
            (x, y) = point["point"]
            path.appendBezierPathWithRect_(NSMakeRect(x - _onCurveSize, y - _onCurveSize, _onCurveSize * 2, _onCurveSize * 2))
            
        path.fill()
        offCurveHandlesPath.setLineWidth_(_strokeWidth)
        strokePixelPath(offCurveHandlesPath)
        restore()
示例#5
0
    def setPixel(self, event, dragging=False):
        if self.data is None:
            return False
        try:
            editView = self.editViewController().graphicView()
        except:
            return False

        layer = editView.activeLayer()
        try:
            master = layer.parent.parent.masters[layer.layerId]
        except KeyError:
            return False
        if master is None:
            return False

        # Get location of click in font coordinates
        Loc = editView.getActiveLocation_(event)
        loc_pixel = ((Loc.x - self.rect.origin.x) / self.pixel_size,
                     (Loc.y - self.rect.origin.y) / self.pixel_size /
                     self.pixel_ratio)
        if self.prev_location != loc_pixel:
            x, y = loc_pixel
            current = NSGraphicsContext.currentContext()
            context = NSGraphicsContext.graphicsContextWithBitmapImageRep_(
                self.data)
            if context is None:
                self.prev_location = loc_pixel
                print("Could not get context in setPixel")
                return False
            NSGraphicsContext.saveGraphicsState()
            NSGraphicsContext.setCurrentContext_(context)
            if self.erase:
                NSColor.whiteColor().set()
            else:
                NSColor.blackColor().set()
            effective_size = self.pen_size / self.pixel_size
            if dragging and self.prev_location is not None:
                px, py = self.prev_location
                path = NSBezierPath.alloc().init()
                path.setLineCapStyle_(NSRoundLineCapStyle)
                path.setLineWidth_(effective_size)
                # path.strokeLineFromPoint_toPoint_(x, y, x + self.pen_size, y + self.pen_size)
                path.moveToPoint_((px, py))
                path.lineToPoint_((x, y))
                path.stroke()
                self.needs_save = True
            else:
                half = effective_size / 2
                rect = NSMakeRect(x - half, y - half, effective_size,
                                  effective_size)
                path = NSBezierPath.bezierPathWithOvalInRect_(rect)
                path.fill()
                self.needs_save = True
            # For rectangular pens:
            # NSBezierPath.fillRect_(rect)
            NSGraphicsContext.setCurrentContext_(current)
            NSGraphicsContext.restoreGraphicsState()
            self.prev_location = loc_pixel
        return True
示例#6
0
 def drawRect_(self, rect):
     NSColor.whiteColor().set()
     NSRectFill(self.bounds())
     origin = (self.center[0] - self.radius, self.center[1] - self.radius)
     size = (2 * self.radius, 2 * self.radius)
     dotRect = (origin, size)
     self.color.set()
     NSBezierPath.bezierPathWithOvalInRect_(dotRect).fill()
示例#7
0
 def drawRect_(self, rect):
     NSColor.whiteColor().set()
     NSRectFill(self.bounds())
     origin = (self.center[0]-self.radius, self.center[1]-self.radius)
     size = (2 * self.radius, 2 * self.radius)
     dotRect = (origin, size)
     self.color.set()
     NSBezierPath.bezierPathWithOvalInRect_(dotRect).fill()
示例#8
0
    def drawRect_(self, rect):

        NSColor.whiteColor().set()
        NSBezierPath.fillRect_(rect)

        if Glyphs.font is None:
            return

        if not Glyphs.font.selectedLayers:
            return

        glyphToRotate = None
        try:
            glyphToRotate = Glyphs.font.selectedLayers[0]
        except:
            print(traceback.format_exc())

        if glyphToRotate is None:
            return

        try:
            previewPath = glyphToRotate.completeBezierPath

            rotationFactor = self.wrapper._rotationFactor
            Width = NSWidth(self.frame())
            Height = NSHeight(self.frame())

            scaleFactor = 0.666666 / (glyphToRotate.parent.parent.upm /
                                      min(Width, Height))

            ## scaling and zeroing the glyph
            #------------------------
            transform = NSAffineTransform.transform()
            transform.scaleBy_(scaleFactor)
            bounds = glyphToRotate.bounds
            transform.translateXBy_yBy_(-NSMidX(bounds), -NSMidY(bounds))
            previewPath.transformUsingAffineTransform_(transform)

            ## rotation
            #------------------------
            transform = NSAffineTransform.transform()
            transform.rotateByDegrees_(rotationFactor)
            previewPath.transformUsingAffineTransform_(transform)

            ## positioning to the middle of the viewport
            #------------------------
            transform = NSAffineTransform.transform()
            transform.translateXBy_yBy_(Width / 2, Height / 2 - 8)
            previewPath.transformUsingAffineTransform_(transform)

            ## fill path
            #------------------------
            NSColor.blackColor().set()
            previewPath.fill()

        except:
            print(traceback.format_exc())
示例#9
0
 def drawRect_(self, rect):
     if not self.border:
         return super(ThumbnailBoxView, self).drawRect_(rect)
     with save_graphics_state():
         self._shadow.set()
         NSColor.whiteColor().set()
         NSBezierPath.bezierPathWithRect_(NSInsetRect(rect, self.BORDER_INSET, self.BORDER_INSET)).fill()
     size = self.image().size()
     self.image().drawInRect_fromRect_operation_fraction_(NSInsetRect(rect, self.IMAGE_INSET, self.IMAGE_INSET), NSMakeRect(*rect_to_centered_square(size.width, size.height)), NSCompositeSourceOver, 1.0)
 def drawCoveringBadge(self, x, y, width, height, radius):
     try:
         myPath = NSBezierPath.alloc().init()
         NSColor.colorWithCalibratedRed_green_blue_alpha_(*COLOR).set()
         myRect = NSRect((x, y), (width, height))
         thisPath = NSBezierPath.bezierPathWithRoundedRect_cornerRadius_(
             myRect, radius)
         myPath.appendBezierPath_(thisPath)
         myPath.fill()
     except:
         print traceback.format_exc()
示例#11
0
 def getImage(self):
     image = NSImage.alloc().initWithSize_((self.width, self.height))
     image.setFlipped_(True)
     image.lockFocus()
     context = NSGraphicsContext.currentContext()
     bodyRect = ((0, 0), (self.width, self.height - self.headerHeight))
     headerRect = ((0, -self.height + self.headerHeight),
                   (self.width, self.headerHeight))
     # draw a background color
     cellBackgroundColor.set()
     NSRectFill(((0, 0), (self.width, self.height)))
     # background
     context.saveGraphicsState()
     bodyTransform = NSAffineTransform.transform()
     bodyTransform.translateXBy_yBy_(0, self.height - self.headerHeight)
     bodyTransform.scaleXBy_yBy_(1.0, -1.0)
     bodyTransform.concat()
     self.drawCellBackground(bodyRect)
     context.restoreGraphicsState()
     # glyph
     if self.shouldDrawMetrics:
         self.drawCellHorizontalMetrics(bodyRect)
         self.drawCellVerticalMetrics(bodyRect)
     context.saveGraphicsState()
     NSBezierPath.clipRect_(
         ((0, 0), (self.width, self.height - self.headerHeight)))
     glyphTransform = NSAffineTransform.transform()
     glyphTransform.translateXBy_yBy_(self.xOffset, self.yOffset)
     glyphTransform.scaleBy_(self.scale)
     glyphTransform.concat()
     self.drawCellGlyph()
     context.restoreGraphicsState()
     # foreground
     context.saveGraphicsState()
     bodyTransform.concat()
     self.drawCellForeground(bodyRect)
     context.restoreGraphicsState()
     # header
     if self.shouldDrawHeader:
         context.saveGraphicsState()
         headerTransform = NSAffineTransform.transform()
         headerTransform.translateXBy_yBy_(0, self.headerHeight)
         headerTransform.scaleXBy_yBy_(1.0, -1.0)
         headerTransform.concat()
         self.drawCellHeaderBackground(headerRect)
         self.drawCellHeaderText(headerRect)
         context.restoreGraphicsState()
     # done
     image.unlockFocus()
     return image
示例#12
0
def DrawTableLines(list, colour, thickness):
	
	global myDialog
	for i, point in enumerate(list):

		try:
			drawline(list[i][1]*mm, list[i][2]*mm, list[i+1][1]*mm, list[i+1][2]*mm, colour, thickness, None)
		except:
			pass

		NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(colour[0], colour[1], colour[2], colour[3], 1).set()
		Rect = NSMakeRect(point[1]*mm-(thickness), point[2]*mm-(thickness), thickness*2, thickness*2)
		NSBezierPath.bezierPathWithOvalInRect_(Rect).fill()
		if Glyphs.boolDefaults["com_yanone_Autopsy_drawpointsvalues"]:
			DrawText(pdffont['Regular'], pointsvaluefontsize, glyphcolour, point[1]*mm + (thickness/6+1)*mm, point[2]*mm - (thickness/6+2.5)*mm, str(int(round(point[0]))))
示例#13
0
 def getImage(self):
     image = NSImage.alloc().initWithSize_((self.width, self.height))
     image.setFlipped_(True)
     image.lockFocus()
     context = NSGraphicsContext.currentContext()
     bodyRect = ((0, 0), (self.width, self.height - self.headerHeight))
     headerRect = ((0, -self.height + self.headerHeight), (self.width, self.headerHeight))
     # draw a background color
     cellBackgroundColor.set()
     NSRectFill(((0, 0), (self.width, self.height)))
     # background
     context.saveGraphicsState()
     bodyTransform = NSAffineTransform.transform()
     bodyTransform.translateXBy_yBy_(0, self.height - self.headerHeight)
     bodyTransform.scaleXBy_yBy_(1.0, -1.0)
     bodyTransform.concat()
     self.drawCellBackground(bodyRect)
     context.restoreGraphicsState()
     # glyph
     if self.shouldDrawMetrics:
         self.drawCellHorizontalMetrics(bodyRect)
         self.drawCellVerticalMetrics(bodyRect)
     context.saveGraphicsState()
     NSBezierPath.clipRect_(((0, 0), (self.width, self.height - self.headerHeight)))
     glyphTransform = NSAffineTransform.transform()
     glyphTransform.translateXBy_yBy_(self.xOffset, self.yOffset)
     glyphTransform.scaleBy_(self.scale)
     glyphTransform.concat()
     self.drawCellGlyph()
     context.restoreGraphicsState()
     # foreground
     context.saveGraphicsState()
     bodyTransform.concat()
     self.drawCellForeground(bodyRect)
     context.restoreGraphicsState()
     # header
     if self.shouldDrawHeader:
         context.saveGraphicsState()
         headerTransform = NSAffineTransform.transform()
         headerTransform.translateXBy_yBy_(0, self.headerHeight)
         headerTransform.scaleXBy_yBy_(1.0, -1.0)
         headerTransform.concat()
         self.drawCellHeaderBackground(headerRect)
         self.drawCellHeaderText(headerRect)
         context.restoreGraphicsState()
     # done
     image.unlockFocus()
     return image
示例#14
0
    def drawWithFrame_inView_(self, frame, view):
        row = view.selectedRow()
        columnCount = len(view.tableColumns())
        frames = [view.frameOfCellAtColumn_row_(i, row) for i in xrange(columnCount)]
        selected = frame in frames

        (x, y), (w, h) = frame
        y += 1
        h -= 2

        if selected:
            pillTextAttributes[NSForegroundColorAttributeName] = self._color
            foregroundColor = NSColor.whiteColor()
        else:
            pillTextAttributes[NSForegroundColorAttributeName] = NSColor.whiteColor()
            foregroundColor = self._color

        text = self.title()
        text = NSAttributedString.alloc().initWithString_attributes_(text, pillTextAttributes)
        textRect = text.boundingRectWithSize_options_((w, h), 0)
        (textX, textY), (textW, textH) = textRect

        foregroundColor.set()
        path = NSBezierPath.bezierPath()
        radius = h / 2.0
        path.appendBezierPathWithOvalInRect_(((x, y), (h, h)))
        path.appendBezierPathWithOvalInRect_(((x + textW - 1, y), (h, h)))
        path.appendBezierPathWithRect_(((x + radius, y), (textW - 1, h)))
        path.fill()
        text.drawInRect_(((x + radius, y), (textW, textH)))
示例#15
0
文件: Canvas.py 项目: tomihasa/pygui
 def _ns_arc_path(self, c, r, sa, ea):
     ns_path = NSBezierPath.bezierPath()
     ns_path.setLineWidth_(self._pensize)
     ns_path.\
         appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_(
             c, r, sa, ea)
     return ns_path
示例#16
0
    def _drawUnspecified(self, position, kind, size, vector=(-1, 1)):
        if vector is None:
            vector = (-1, 1)
        angle = atan2(vector[1], vector[0])
        circle_size = size * 1.3
        x, y = position
        NSColor.colorWithCalibratedRed_green_blue_alpha_(0.9, 0.1, 0.0,
                                                         0.85).set()

        t = NSAffineTransform.transform()
        t.translateXBy_yBy_(x, y)
        t.rotateByRadians_(angle)

        myPath = NSBezierPath.alloc().init()
        myPath.setLineWidth_(0)
        myPath.appendBezierPathWithOvalInRect_(
            NSMakeRect(x - 0.5 * circle_size, y - 0.5 * circle_size,
                       circle_size, circle_size))
        myPath.stroke()
        if self.show_labels or distance_between_points(self.mouse_position,
                                                       position) < size:
            self._drawTextLabel(
                transform=t,
                text=kind,
                size=size,
                angle=angle,
            )
示例#17
0
	def drawingCalculation(self, curvePoints, interpolFactor):

		color = self.w.colorFill.get()

		if len(curvePoints) != 0:
			path = NSBezierPath.bezierPath()
			
			path.setLineWidth_(int(self.w.strokeThickness.get()) / self.scale)
			
			for idx, pts in enumerate(curvePoints):
				
				if idx == 0:
					path.moveToPoint_((pts[0],pts[1]))
				else:
					path.lineToPoint_((pts[0],pts[1]))
					color.set()
					path.stroke()

			processedPoints = []
			interpolatedPoints = []
			for i, pts in enumerate(curvePoints):
				try:
					pt1 = (pts[0], pts[1])
					pt2 = (curvePoints[i+1][0], curvePoints[i+1][1])
					processedPoints.append(pt1)
					processedPoints.append(pt2)
					
					interpolatedPt = self.interpolatePoint(pt1, pt2, interpolFactor)
					interpolatedPoints.append(interpolatedPt)
					
				except IndexError:
					pass
			
			return interpolatedPoints
		return None
示例#18
0
 def _ns_arc_path(self, c, r, sa, ea):
     ns_path = NSBezierPath.bezierPath()
     ns_path.setLineWidth_(self._pensize)
     ns_path.\
         appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_(
             c, r, sa, ea)
     return ns_path
示例#19
0
    def drawHashMarksAndLabelsInRect_(self, rect):
        bounds = self.bounds()
        view = self.clientView()

        rulerBackgroundColor = self.rulerBackgroundColor()
        if rulerBackgroundColor is not None:
            rulerBackgroundColor.set()
            NSRectFill(bounds)

        if not isinstance(view, NSTextView):
            return

        layoutManager = view.layoutManager()
        container = view.textContainer()
        text = view.string()
        nullRange = NSMakeRange(NSNotFound, 0)
        yinset = view.textContainerInset().height
        visibleRect = self.scrollView().contentView().bounds()
        textAttributes = self.textAttributes()

        lines = self.lineIndices()

        glyphRange = layoutManager.glyphRangeForBoundingRect_inTextContainer_(visibleRect, container)
        _range = layoutManager.characterRangeForGlyphRange_actualGlyphRange_(glyphRange, None)[0]
        _range.length += 1

        count = len(lines)
        index = 0

        lineNumber = self.lineNumberForCharacterIndex_inText_(_range.location, text)

        for line in range(lineNumber, count):
            index = lines[line]
            if NSLocationInRange(index, _range):
                rects, rectCount = layoutManager.rectArrayForCharacterRange_withinSelectedCharacterRange_inTextContainer_rectCount_(
                    NSMakeRange(index, 0),
                    nullRange,
                    container,
                    None
                )
                if rectCount > 0:
                    ypos = yinset + NSMinY(rects[0]) - NSMinY(visibleRect)
                    labelText = NSString.stringWithString_("%s" % (line + 1))
                    stringSize = labelText.sizeWithAttributes_(textAttributes)

                    x = NSWidth(bounds) - stringSize.width - self.RULER_MARGIN
                    y = ypos + (NSHeight(rects[0]) - stringSize.height) / 2.0
                    w = NSWidth(bounds) - self.RULER_MARGIN * 2.0
                    h = NSHeight(rects[0])

                    labelText.drawInRect_withAttributes_(NSMakeRect(x, y, w, h), textAttributes)

            if index > NSMaxRange(_range):
                break

        path = NSBezierPath.bezierPath()
        path.moveToPoint_((bounds.origin.x + bounds.size.width, bounds.origin.y))
        path.lineToPoint_((bounds.origin.x + bounds.size.width, bounds.origin.y + bounds.size.height))
        NSColor.grayColor().set()
        path.stroke()
示例#20
0
def drawIcon(foregroundColor, backgroundColor):
    image = NSImage.alloc().initWithSize_((120, 11))
    image.lockFocus()
    foregroundColor.set()
    path = NSBezierPath.bezierPath()
    path.setLineWidth_(1.0)
    # left
    path.moveToPoint_((0, 5.5))
    path.lineToPoint_((15, 5.5))
    path.moveToPoint_((4, 8.5))
    path.lineToPoint_((0, 5.5))
    path.lineToPoint_((4, 2.5))
    # right
    path.moveToPoint_((120, 5.5))
    path.lineToPoint_((105, 5.5))
    path.moveToPoint_((114, 8.5))
    path.lineToPoint_((120, 5.5))
    path.lineToPoint_((114, 2.5))
    # center
    path.moveToPoint_((50, 5.5))
    path.lineToPoint_((70, 5.5))
    path.moveToPoint_((54, 8.5))
    path.lineToPoint_((50, 5.5))
    path.lineToPoint_((54, 2.5))
    path.moveToPoint_((66, 8.5))
    path.lineToPoint_((70, 5.5))
    path.lineToPoint_((66, 2.5))
    path.stroke()
    image.unlockFocus()
    return image
示例#21
0
    def __init__(self, glyphSet, path=None):
        BasePen.__init__(self, glyphSet)
        if path is None:
            from AppKit import NSBezierPath

            path = NSBezierPath.bezierPath()
        self.path = path
示例#22
0
    def background(self, layer):
        try:
            NSColor.colorWithDeviceRed_green_blue_alpha_(0.2, 0.2, 0.2,
                                                         0.5).set()
            for a in layer.anchors:
                if a not in layer.selection:
                    continue
                for (l2,
                     otherAnchor) in self.matchingGlyphsAndAnchorsForAnchor(
                         layer, a):
                    if l2.parent.name in self.skipMark:
                        continue
                    anchorAnchorPos = NSPoint(
                        a.position.x - otherAnchor.position.x,
                        a.position.y - otherAnchor.position.y,
                    )
                    bez = NSBezierPath.bezierPath()
                    bez.appendBezierPath_(l2.bezierPath)

                    t = NSAffineTransform.transform()
                    t.translateXBy_yBy_(anchorAnchorPos.x, anchorAnchorPos.y)
                    bez.transformUsingAffineTransform_(t)
                    bez.fill()

        except:
            print("Oops!", sys.exc_info()[0], "occured.")
            traceback.print_exc(file=sys.stdout)
示例#23
0
    def drawWithFrame_inView_(self, frame, view):
        row = view.selectedRow()
        columnCount = len(view.tableColumns())
        frames = [
            view.frameOfCellAtColumn_row_(i, row) for i in range(columnCount)
        ]
        selected = frame in frames

        (x, y), (w, h) = frame
        y += 1
        h -= 2

        if selected:
            pillTextAttributes[NSForegroundColorAttributeName] = self._color
            foregroundColor = NSColor.whiteColor()
        else:
            pillTextAttributes[
                NSForegroundColorAttributeName] = NSColor.whiteColor()
            foregroundColor = self._color

        text = self.title()
        text = NSAttributedString.alloc().initWithString_attributes_(
            text, pillTextAttributes)
        textRect = text.boundingRectWithSize_options_((w, h), 0)
        (textX, textY), (textW, textH) = textRect

        foregroundColor.set()
        path = NSBezierPath.bezierPath()
        radius = h / 2.0
        path.appendBezierPathWithOvalInRect_(((x, y), (h, h)))
        path.appendBezierPathWithOvalInRect_(((x + textW - 1, y), (h, h)))
        path.appendBezierPathWithRect_(((x + radius, y), (textW - 1, h)))
        path.fill()
        text.drawInRect_(((x + radius, y), (textW, textH)))
def roundedRectBezierPath(rect, radius,
        roundUpperLeft=True, roundUpperRight=True, roundLowerLeft=True, roundLowerRight=True,
        closeTop=True, closeBottom=True, closeLeft=True, closeRight=True):

    (rectLeft, rectBottom), (rectWidth, rectHeight) = rect
    rectTop = rectBottom + rectHeight
    rectRight = rectLeft + rectWidth

    path = NSBezierPath.bezierPath()

    if roundUpperLeft:
        path.moveToPoint_((rectLeft, rectHeight-radius))
        path.appendBezierPathWithArcFromPoint_toPoint_radius_((rectLeft, rectTop), (rectLeft+radius, rectTop), radius)
    else:
        path.moveToPoint_((rectLeft, rectTop))

    if roundUpperRight:
        if closeTop:
            path.lineToPoint_((rectRight-radius, rectTop))
        else:
            path.moveToPoint_((rectRight-radius, rectTop))
        path.appendBezierPathWithArcFromPoint_toPoint_radius_((rectRight, rectTop), (rectRight, rectTop-radius), radius)
    else:
        if closeTop:
            path.lineToPoint_((rectRight, rectTop))
        else:
            path.moveToPoint_((rectRight, rectTop))

    if roundLowerRight:
        if closeRight:
            path.lineToPoint_((rectRight, rectBottom+radius))
        else:
            path.moveToPoint_((rectRight, rectBottom+radius))
        path.appendBezierPathWithArcFromPoint_toPoint_radius_((rectRight, rectBottom), (rectRight-radius, rectBottom), radius)
    else:
        if closeRight:
            path.lineToPoint_((rectRight, rectBottom))
        else:
            path.moveToPoint_((rectRight, rectBottom))

    if roundLowerLeft:
        if closeBottom:
            path.lineToPoint_((rectLeft+radius, rectBottom))
        else:
            path.moveToPoint_((rectLeft+radius, rectBottom))
        path.appendBezierPathWithArcFromPoint_toPoint_radius_((rectLeft, rectBottom), (rectLeft, rectBottom+radius), radius)
    else:
        if closeBottom:
            path.lineToPoint_((rectLeft, rectBottom))
        else:
            path.moveToPoint_((rectLeft, rectBottom))

    if closeLeft:
        if roundUpperLeft:
            path.lineToPoint_((rectLeft, rectHeight-radius))
        else:
            path.lineToPoint_((rectLeft, rectTop))

    return path
示例#25
0
def drawGlyph(pen, glyph):
    save()
    stroke(None)
    fill(0)
    pen.path = NSBezierPath.bezierPath()
    glyph.draw(pen)
    drawPath(pen.path)
    restore()
示例#26
0
 def drawRect_(self, rect):
     from AppKit import NSRectFill, NSBezierPath, NSColor
     self.color.set()
     NSRectFill(self.bounds())
     NSColor.blackColor().set()
     p = NSBezierPath.bezierPathWithRect_(self.bounds())
     p.setLineWidth_(10)
     p.stroke()
示例#27
0
 def drawRect_(self, rect):
     super(PictureView, self).drawRect_(rect)
     pos = self.dropboxViewFinalPosition.origin
     size = self.dropboxViewFinalPosition.size
     a = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(NSRect((pos[0] - 3, pos[1] - 3), (size[0] + 6, size[1] + 6)), 5.0, 5.0)
     a.setLineWidth_(2)
     NSColor.whiteColor().set()
     a.fill()
示例#28
0
 def drawRect_(self, rect):
     from AppKit import NSRectFill, NSBezierPath, NSColor
     self.color.set()
     NSRectFill(self.bounds())
     NSColor.blackColor().set()
     p = NSBezierPath.bezierPathWithRect_(self.bounds())
     p.setLineWidth_(10)
     p.stroke()
示例#29
0
def line(x1, y1, x2=None, y2=None):
	# draws a line
	if x2 is None and y2 is None and isinstance(x1, tuple) and isinstance(y1, tuple):
		(x1, y1), (x2, y2) = x1, y1
	p = NSBezierPath.bezierPath()
	p.moveToPoint_(NSMakePoint(x1, y1))
	p.lineToPoint_(NSMakePoint(x2, y2))
	drawPath(p)
示例#30
0
 def draw(self, rect):
     #NSColor.redColor().set()
     yellowColor.set()
     for n in range(50):
         rgba(random(), random(), random())
         rect = NSMakeRect(n * 400 + M, n * 400 + M, M, M)
         path = NSBezierPath.bezierPathWithRect_(rect)
         path.fill()
示例#31
0
 def __init__(self):
     self._ns_path = NSBezierPath.bezierPath()
     self._ns_path.setWindingRule_(NSEvenOddWindingRule)
     self._stack = []
     ctx = NSGraphicsContext.currentContext()
     ctx.setCompositingOperation_(NSCompositeSourceOver)
     GCanvas.__init__(self)
     self._printing = not ctx.isDrawingToScreen()
     self.initgraphics()
示例#32
0
def line(x1, y1, x2=None, y2=None):
    # draws a line
    if x2 is None and y2 is None and isinstance(x1, tuple) and isinstance(
            y1, tuple):
        (x1, y1), (x2, y2) = x1, y1
    p = NSBezierPath.bezierPath()
    p.moveToPoint_(NSMakePoint(x1, y1))
    p.lineToPoint_(NSMakePoint(x2, y2))
    drawPath(p)
	def addGlyph(self, glyph):
		BezierPath = glyph._layer.bezierPath()
		if BezierPath != None:
			BezierPath = BezierPath.copy()
		else:
			BezierPath = NSBezierPath.bezierPath()
		for currComponent in glyph._layer.components:
			BezierPath.appendBezierPath_(currComponent.bezierPath())
		self.getNSBezierPath().appendBezierPath_(BezierPath)
	def addGlyph(self, glyph):
		BezierPath = glyph._layer.bezierPath()
		if BezierPath != None:
			BezierPath = BezierPath.copy()
		else:
			BezierPath = NSBezierPath.bezierPath()
		for currComponent in glyph._layer.components:
			BezierPath.appendBezierPath_(currComponent.bezierPath())
		self.getNSBezierPath().appendBezierPath_(BezierPath)
示例#35
0
文件: Canvas.py 项目: tomihasa/pygui
 def __init__(self):
     self._ns_path = NSBezierPath.bezierPath()
     self._ns_path.setWindingRule_(NSEvenOddWindingRule)
     self._stack = []
     ctx = NSGraphicsContext.currentContext()
     ctx.setCompositingOperation_(NSCompositeSourceOver)
     GCanvas.__init__(self)
     self._printing = not ctx.isDrawingToScreen()
     self.initgraphics()
示例#36
0
def drawOutline(pen, glyph, color, s):
    save()
    strokeWidth(1 / s)
    stroke(*color)
    fill(None)
    pen.path = NSBezierPath.bezierPath()
    glyph.draw(pen)
    drawPath(pen.path)
    restore()
示例#37
0
def DrawGlyph(f, glyph, PSCommands, xoffset, yoffset, ratio, fillcolour,
              strokecolour, strokewidth, dashed):
    if not PSCommands:
        layer = glyph.layers[0]
        p = layer.drawBezierPath
        transform = NSAffineTransform.new()
        transform.translateXBy_yBy_(xoffset * mm, yoffset * mm)
        transform.scaleBy_(ratio)
        p.transformUsingAffineTransform_(transform)
    else:
        p = NSBezierPath.bezierPath()

        for command in PSCommands:

            if command[0] == 'moveTo':
                try:
                    p.close()
                except:
                    pass

                x = xoffset * mm + command[1][0] * ratio
                y = yoffset * mm + command[1][1] * ratio
                p.moveToPoint_((x, y))
                #print "('moveTo', (%s, %s))," % (command[1][0], command[1][1])

            if command[0] == 'lineTo':
                x = xoffset * mm + command[1][0] * ratio
                y = yoffset * mm + command[1][1] * ratio
                p.lineToPoint_((x, y))
                #print "('lineTo', (%s, %s))," % (command[1][0], command[1][1])

            if command[0] == 'curveTo':

                points = []

                for point in command[1:]:
                    points.append((xoffset * mm + point[0] * ratio,
                                   yoffset * mm + point[1] * ratio))

                p.curveToPoint_controlPoint1_controlPoint2_(
                    points[0], points[1], points[2])
        p.closePath()

    if fillcolour:
        NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(
            fillcolour[0], fillcolour[1], fillcolour[2], fillcolour[3],
            1).set()
        p.fill()
    if strokecolour:
        NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(
            strokecolour[0], strokecolour[1], strokecolour[2], strokecolour[3],
            1).set()
        if dashed:
            p.setLineDash_count_phase_(dashed, 2, 0.0)
        p.setLineWidth_(strokewidth)
        p.stroke()
 def draw(self, scale):
     if self.isDragging() and self.pStart and self.pEnd:
         r = self.getMarqueRect()
         if r:
             color = getDefaultColor('glyphViewSelectionMarqueColor')
             color.set()
             path = NSBezierPath.bezierPathWithRect_(r)
             path.fill()
         return
     self.drawSelection(scale)
示例#39
0
 def draw(self, scale):
     if self.isDragging() and self.pStart and self.pEnd:
         r = self.getMarqueRect()
         if r:
             color = getDefaultColor('glyphViewSelectionMarqueColor')
             color.set()
             path = NSBezierPath.bezierPathWithRect_(r)
             path.fill()
         return
     self.drawSelection(scale)
示例#40
0
    def drawRect_(self, rect):
        try:
            NSColor.whiteColor().set()
            NSRectFill(self.bounds())
            NSColor.blackColor().setFill()
            NSColor.blueColor().setStroke()
            p = NSBezierPath.bezierPath()
            xcursor = 0
            string = self.string
            master = self.master
            for s in range(0, len(string)):
                thisPath = NSBezierPath.bezierPath()
                gsglyph = master.font.glyphs[string[s]]
                layer = gsglyph.layers[master.id]
                thisPath.appendBezierPath_(layer.completeBezierPath)
                # print("X cursor was",xcursor)
                xcursor = xcursor - layer.bounds.origin.x
                # print("Moving backwards", layer.bounds.origin.x)
                t = NSAffineTransform.transform()
                t.translateXBy_yBy_(xcursor, -master.descender)
                thisPath.transformUsingAffineTransform_(t)
                # print("Drawing at",xcursor)
                # print(thisPath)
                xcursor = xcursor + layer.bounds.origin.x
                xcursor = xcursor + layer.bounds.size.width
                # print("Adding width", layer.bounds.size.width)
                if s < len(string) - 1:
                    xcursor = xcursor + self.distances[(string[s],
                                                        string[s + 1])]
                p.appendBezierPath_(thisPath)

            t = NSAffineTransform.transform()
            if xcursor > 0:
                vscale = self.bounds().size.height / (master.ascender -
                                                      master.descender)
                hscale = self.bounds().size.width / xcursor
                t.scaleBy_(min(hscale, vscale))
                p.transformUsingAffineTransform_(t)
            p.fill()
        except:
            print("Oops!", sys.exc_info()[0], "occured.")
            traceback.print_exc(file=sys.stdout)
    def drawWithFrame_inView_(self, frame, view):
        frame.origin.x -= 1
        frame.size.width += 2
        frame.origin.y -= 2
        frame.size.height += 2
        textFrame = NSInsetRect(frame, 2, 2)

        text = self.objectValue()
        color = getColorDefault("PyDEBackgroundColor", fallbackBackgroundColor)
        color.set()
        NSBezierPath.bezierPathWithRect_(frame).fill()

        if self.isHighlighted():
            frame.origin.y += 1
            frame.size.height -= 1
            color = getColorDefault("PyDEHightLightColor", fallbackHightLightColor)
            color.set()
            NSBezierPath.bezierPathWithRect_(frame).fill()

        text.drawInRect_(textFrame)
示例#42
0
	def drawLine(self, x1, y1, x2, y2, strokeWidth=1):
		try:
			myPath = NSBezierPath.bezierPath()
			myPath.moveToPoint_( (x1, y1) )
			myPath.lineToPoint_( (x2, y2) )
			myPath.setLineWidth_( strokeWidth/self.getScale() )
			selectionColor = 0, 0, 0.5, 0.2
			NSColor.colorWithCalibratedRed_green_blue_alpha_( *selectionColor ).set()
			myPath.stroke()
		except:
			print(traceback.format_exc())
示例#43
0
def drawline(x1, y1, x2, y2, colour, strokewidth, dashed):

	NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(colour[0], colour[1], colour[2], colour[3], 1).set()
	Path = NSBezierPath.bezierPath()
	Path.moveToPoint_((x1, y1))
	Path.lineToPoint_((x2, y2))
	Path.setLineWidth_(strokewidth)
	
	if dashed:
		Path.setLineDash_count_phase_(dashed, 2, 0.0)
	Path.stroke()
示例#44
0
def drawrect(x1, y1, x2, y2, fillcolour, strokecolour, strokewidth, dashed, rounded):
	Rect = NSMakeRect(x1, y1, x2 - x1, y2 - y1)
	Path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(Rect, rounded, rounded)
	if fillcolour:
		NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(fillcolour[0], fillcolour[1], fillcolour[2], fillcolour[3], 1).set()
		Path.fill()
	if strokecolour:
		Path.setLineWidth_(strokewidth)
		if dashed:
			Path.setLineDash_count_phase_(dashed, 2, 0.0)
		NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(strokecolour[0], strokecolour[1], strokecolour[2], strokecolour[3], 1).set()
		Path.stroke()
示例#45
0
 def draw_bbox(x1, y1, x2, y2, x3, y3, x4, y4, outline=False):
     path = NSBezierPath.bezierPath()
     path.moveToPoint_((x1, y1))
     path.lineToPoint_((x2, y2))
     path.lineToPoint_((x3, y3))
     path.lineToPoint_((x4, y4))
     path.lineToPoint_((x1, y1))
     if not outline:
         path.fill()
     else:
         path.setLineWidth_(30)
         path.stroke()
def drawGlyph(glyph):
	BezierPath = glyph._layer.bezierPath()
	if BezierPath != None:
		BezierPath = BezierPath.copy()
	else:
		BezierPath = NSBezierPath.bezierPath()
	OpenBezierPath = glyph._layer.openBezierPath()
	if OpenBezierPath:
		BezierPath.appendBezierPath_(OpenBezierPath)
	for currComponent in glyph._layer.components:
		BezierPath.appendBezierPath_(currComponent.bezierPath())
	_drawBotDrawingTool.drawPath(BezierPath)
示例#47
0
def drawline(x1, y1, x2, y2, colour, strokewidth, dashed):

    NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(
        colour[0], colour[1], colour[2], colour[3], 1).set()
    Path = NSBezierPath.bezierPath()
    Path.moveToPoint_((x1, y1))
    Path.lineToPoint_((x2, y2))
    Path.setLineWidth_(strokewidth)

    if dashed:
        Path.setLineDash_count_phase_(dashed, 2, 0.0)
    Path.stroke()
def drawGlyph(glyph):
	BezierPath = glyph._layer.bezierPath
	if BezierPath != None:
		BezierPath = BezierPath.copy()
	else:
		BezierPath = NSBezierPath.bezierPath()
	OpenBezierPath = glyph._layer.openBezierPath
	if OpenBezierPath:
		BezierPath.appendBezierPath_(OpenBezierPath)
	for currComponent in glyph._layer.components:
		BezierPath.appendBezierPath_(currComponent.bezierPath)
	_drawBotDrawingTool.drawPath(BezierPath)
示例#49
0
 def extensionIconPlaceholder(self):
     width = 200
     height = 200
     image = NSImage.alloc().initWithSize_((width, height))
     image.lockFocus()
     path = NSBezierPath.bezierPathWithOvalInRect_(
         ((0, 0), (width, height)))
     color1 = NSColor.disabledControlTextColor()
     color1.set()
     path.fill()
     image.unlockFocus()
     return image
示例#50
0
 def drawCellHorizontalMetrics(self, rect):
     (xMin, yMin), (width, height) = rect
     font = self.font
     scale = self.scale
     yOffset = self.yOffset
     path = NSBezierPath.bezierPath()
     lines = set((0, font.info.descender, font.info.xHeight, font.info.capHeight, font.info.ascender))
     for y in lines:
         y = round((y * scale) + yMin + yOffset) - .5
         path.moveToPoint_((xMin, y))
         path.lineToPoint_((xMin + width, y))
     cellMetricsLineColor.set()
     path.setLineWidth_(1.0)
     path.stroke()
示例#51
0
def DrawGlyph(f, glyph, PSCommands, xoffset, yoffset, ratio, fillcolour, strokecolour, strokewidth, dashed):
	if not PSCommands:
		layer = glyph.layers[0]
		p = layer.drawBezierPath
		transform = NSAffineTransform.new()
		transform.translateXBy_yBy_(xoffset*mm, yoffset*mm)
		transform.scaleBy_(ratio)
		p.transformUsingAffineTransform_(transform)
	else:
		p = NSBezierPath.bezierPath()
		
		for command in PSCommands:
		
			if command[0] == 'moveTo':
				try:
					p.close()
				except:
					pass
	
				x = xoffset*mm + command[1][0] * ratio
				y = yoffset*mm + command[1][1] * ratio
				p.moveToPoint_((x, y))
				#print "('moveTo', (%s, %s))," % (command[1][0], command[1][1])
	
			if command[0] == 'lineTo':
				x = xoffset*mm + command[1][0] * ratio
				y = yoffset*mm + command[1][1] * ratio
				p.lineToPoint_((x, y))
				#print "('lineTo', (%s, %s))," % (command[1][0], command[1][1])
	
			if command[0] == 'curveTo':
	
				points = []
				
				for point in command[1:]:
					points.append( (xoffset*mm + point[0] * ratio, yoffset*mm + point[1] * ratio) )
				
				p.curveToPoint_controlPoint1_controlPoint2_(points[0], points[1], points[2])
		p.closePath()
	
	if fillcolour:
		NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(fillcolour[0], fillcolour[1], fillcolour[2], fillcolour[3], 1).set()
		p.fill()
	if strokecolour:
		NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(strokecolour[0], strokecolour[1], strokecolour[2], strokecolour[3], 1).set()
		if dashed:
			p.setLineDash_count_phase_(dashed, 2, 0.0)
		p.setLineWidth_(strokewidth)
		p.stroke()
示例#52
0
文件: SillyBalls.py 项目: aosm/pyobjc
    def animateOneFrame(self):
        # choose a random point.
        (x, y), (fw, fh) = self.frame()
        x, y = randrange(0.0, fw), randrange(0.0, fw)
        ballSize = randrange(10.0, 90.0)

        path = NSBezierPath.bezierPathWithOvalInRect_(((x, y), (ballSize, ballSize)))

        # make a random color.
        randomColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(random(), random(), random(), random())

        # set it.
        randomColor.set()

        # draw a new ball.
        path.fill()
    def __init__(self, dimensions):
        super(DashedRectangle, self).__init__(dimensions, scale="none")

        box_width = self.getPosSize()[2]
        box_height = self.getPosSize()[3]

        line_image = NSImage.alloc().initWithSize_((box_width, box_height))
        line_image.lockFocus()
        path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(NSMakeRect(.5, .5, box_width - 1, box_height - 1), 5, 5)
        path.setLineWidth_(1.0)
        path.setLineDash_count_phase_((5, 5), 2, 0)
        NSColor.colorWithCalibratedWhite_alpha_(0, 0.1).set()
        path.stroke()
        line_image.unlockFocus()

        self.setImage(imageObject=line_image)
示例#54
0
    def getGraph(self):
        path = NSBezierPath.bezierPath()

        maxMag = 0
        mag = self.fieldValue(0)

        maxMag = max(maxMag, mag)
        path.moveToPoint_(polarToRect((mag, 0)))
        for deg in range(1, 359, 1):
            r = (deg/180.0)*pi
            mag = self.fieldValue(r)
            maxMag = max(maxMag, mag)
            path.lineToPoint_(polarToRect((mag, r)))
        path.closePath()

        return path, maxMag;
示例#55
0
 def drawCellHeaderBackground(self, rect):
     (xMin, yMin), (width, height) = rect
     # background
     try:
         gradient = NSGradient.alloc().initWithColors_([cellHeaderHighlightColor, cellHeaderBaseColor])
         gradient.drawInRect_angle_(rect, 90)
     except NameError:
         cellHeaderBaseColor.set()
         NSRectFill(rect)
     # bottom line
     cellHeaderLineColor.set()
     bottomPath = NSBezierPath.bezierPath()
     bottomPath.moveToPoint_((xMin, yMin + height - .5))
     bottomPath.lineToPoint_((xMin + width, yMin + height - .5))
     bottomPath.setLineWidth_(1.0)
     bottomPath.stroke()
示例#56
0
def drawLine(xy1, xy2, lineWidth=1.0):
    x1, y1 = xy1
    x2, y2 = xy2
    turnOffAntiAliasing = False
    if x1 == x2 or y1 == y2:
        turnOffAntiAliasing = True
    if turnOffAntiAliasing:
        context = NSGraphicsContext.currentContext()
        context.setShouldAntialias_(False)
    path = NSBezierPath.bezierPath()
    path.moveToPoint_((x1, y1))
    path.lineToPoint_((x2, y2))
    if turnOffAntiAliasing and lineWidth == 1.0:
        lineWidth = 0.001
    path.setLineWidth_(lineWidth)
    path.stroke()
    if turnOffAntiAliasing:
        context.setShouldAntialias_(True)
示例#57
0
	def _drawTextLabel(self, transform, text, size, vector):
		if vector is None:
			vector = (-1, 1)
		angle = atan2(vector[0], -vector[1])
		text_size = 0.5 * size
		
		#para_style = NSMutableParagraphStyle.alloc().init()
		#para_style.setAlignment_(NSCenterTextAlignment)

		attrs = {
			NSFontAttributeName:            NSFont.systemFontOfSize_(text_size),
			NSForegroundColorAttributeName: NSColor.colorWithCalibratedRed_green_blue_alpha_( 0.4, 0.4, 0.6, 0.7 ),
			#NSParagraphStyleAttributeName:  para_style,
		}
		myString = NSString.string().stringByAppendingString_(text)
		bbox = myString.sizeWithAttributes_(attrs)
		bw = bbox.width
		bh = bbox.height

		text_pt = NSPoint()
		text_pt.y = 0

		if -0.5 * pi < angle <= 0.5 * pi:
			text_pt.x = -1.3 * size - bw / 2 * cos(angle) - bh / 2 * sin(angle)
		else:
			text_pt.x = -1.3 * size + bw / 2 * cos(angle) + bh / 2 * sin(angle)
		
		text_pt = transform.transformPoint_(text_pt)
		
		rr = NSRect(
			origin = (text_pt.x - bw / 2, text_pt.y - bh / 2),
			size = (bw, bh)
		)
		
		if DEBUG:
			NSColor.colorWithCalibratedRed_green_blue_alpha_( 0, 0, 0, 0.15 ).set()
			myRect = NSBezierPath.bezierPathWithRect_(rr)
			myRect.setLineWidth_(0.05 * size)
			myRect.stroke()
		
		myString.drawInRect_withAttributes_(
			rr,
			attrs
		)