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 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 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 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(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 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]))))
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 DrawText(font, fontsize, fontcolour, x, y, text): attributes = { NSFontAttributeName: NSFont.fontWithName_size_(font, fontsize), NSForegroundColorAttributeName: NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_( fontcolour[0], fontcolour[1], fontcolour[2], fontcolour[3], 1) } String = NSAttributedString.alloc().initWithString_attributes_( text, attributes) String.drawAtPoint_((x, y))
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]))))
def DrawText(font, fontsize, fontcolour, x, y, text): attributes = {NSFontAttributeName : NSFont.fontWithName_size_(font, fontsize), NSForegroundColorAttributeName: NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(fontcolour[0], fontcolour[1], fontcolour[2], fontcolour[3], 1)} String = NSAttributedString.alloc().initWithString_attributes_(text, attributes) String.drawAtPoint_((x, y))