コード例 #1
0
 def drawGlyphBackground(self, glyph, rect, alternate=False):
     if self.needsToDrawRectInGlyphSpace_scale_(rect):
         if glyph.name == ".notdef":
             self._notdefBackgroundColor.set()
             NSRectFillUsingOperation(rect, NSCompositeSourceOver)
         if alternate:
             self._alternateHighlightColor.set()
             NSRectFillUsingOperation(rect, NSCompositeSourceOver)
コード例 #2
0
    def __init__(self, dimensions, alpha=1):
        super(Background, self).__init__(dimensions, scale="fit")

        colorTile = NSImage.alloc().initWithSize_((10, 10))
        colorTile.lockFocus()
        color = NSColor.colorWithCalibratedWhite_alpha_(0, alpha)
        color.set()
        NSRectFillUsingOperation(((0, 0), (10, 10)), NSCompositeSourceOver)
        colorTile.unlockFocus()

        self.setImage(imageObject=colorTile)
コード例 #3
0
def drawImage(paths, foregroundColor, backgroundColor):
    image = NSImage.alloc().initWithSize_((19, 19))
    image.lockFocus()
    backgroundColor.set()
    NSRectFillUsingOperation(((0, 0), (19, 19)), NSCompositeSourceOver)
    foregroundColor.set()
    path = NSBezierPath.bezierPathWithRect_(((0.5, 0.5), (18, 18)))
    for (mT, lT) in paths:
        path.moveToPoint_(mT)
        path.lineToPoint_(lT)
    path.setLineWidth_(1.0)
    path.stroke()
    image.unlockFocus()
    return image
コード例 #4
0
 def drawSegment_inFrame_withView_(self, segment, frame, view):
     (x, y), (w, h) = frame
     # draw highlight
     if self.isSelectedForSegment_(segment):
         NSColor.colorWithCalibratedWhite_alpha_(0, .2).set()
         NSRectFillUsingOperation(frame, NSCompositeSourceOver)
     # draw border
     if segment != 0:
         path = NSBezierPath.bezierPath()
         path.moveToPoint_((x + .5, y + h))
         path.lineToPoint_((x + .5, y))
         path.setLineWidth_(1.0)
         placardBorderColor.set()
         path.stroke()
         x += 1
     # draw image
     image = self.imageForSegment_(segment)
     if image is not None:
         image.drawAtPoint_fromRect_operation_fraction_((x, y), ((0, 0), image.size()), NSCompositeSourceOver, 1.0)
コード例 #5
0
ファイル: drawing.py プロジェクト: RafalBuchner/defconAppKit
def drawFilledRect(rect):
    context = NSGraphicsContext.currentContext()
    context.setShouldAntialias_(False)
    NSRectFillUsingOperation(rect, NSCompositeSourceOver)
    context.setShouldAntialias_(True)