当前位置: 首页>>代码示例>>Python>>正文


Python AppKit.NSBezierPath类代码示例

本文整理汇总了Python中AppKit.NSBezierPath的典型用法代码示例。如果您正苦于以下问题:Python NSBezierPath类的具体用法?Python NSBezierPath怎么用?Python NSBezierPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NSBezierPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw

 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")
开发者ID:fontseek,项目名称:Robofont-scripts,代码行数:25,代码来源:roundingTool.py

示例2: drawPoints

    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()
开发者ID:FontBureau,项目名称:fbOpenTools,代码行数:28,代码来源:OverlayUFOs2.py

示例3: drawRect_

 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()
开发者ID:fruitsamples,项目名称:PyObjC,代码行数:8,代码来源:DotView.py

示例4: DrawTableLines

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]))))
开发者ID:schriftgestalt,项目名称:Autopsy-Plugin,代码行数:15,代码来源:AutopsyLib.py

示例5: getImage

 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
开发者ID:andyclymer,项目名称:defconAppKit,代码行数:48,代码来源:glyphCellFactory.py

示例6: drawHashMarksAndLabelsInRect_

    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()
开发者ID:typemytype,项目名称:drawbot,代码行数:60,代码来源:lineNumberRulerView.py

示例7: _ns_arc_path

 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
开发者ID:skykooler,项目名称:Lightningbeam,代码行数:7,代码来源:Canvas.py

示例8: drawWithFrame_inView_

    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)))
开发者ID:typemytype,项目名称:defconAppKit,代码行数:30,代码来源:pillListCell.py

示例9: __init__

    def __init__(self, glyphSet, path=None):
        BasePen.__init__(self, glyphSet)
        if path is None:
            from AppKit import NSBezierPath

            path = NSBezierPath.bezierPath()
        self.path = path
开发者ID:Mortimer2013,项目名称:Emoji-Tools,代码行数:7,代码来源:cocoaPen.py

示例10: roundedRectBezierPath

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
开发者ID:Artengar,项目名称:defconAppKit,代码行数:59,代码来源:roundedRectBezierPath.py

示例11: drawRect_

 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()
开发者ID:bitforks,项目名称:vanilla,代码行数:8,代码来源:testAll.py

示例12: line

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)
开发者ID:pobivan,项目名称:GlyphsSDK,代码行数:8,代码来源:drawingTools.py

示例13: __init__

 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()
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:9,代码来源:Canvas.py

示例14: addGlyph

	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)
开发者ID:bitforks,项目名称:DrawBotGlyphsPlugin,代码行数:9,代码来源:DrawBotWindow.py

示例15: drawline

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()
开发者ID:schriftgestalt,项目名称:Autopsy-Plugin,代码行数:11,代码来源:AutopsyLib.py


注:本文中的AppKit.NSBezierPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。