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()
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()
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)
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)
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()