Create a NSImage

Hi there!
I search in the forum and didn’t find it. I’m looking for an example of code to create and draw an NSImage in the currentLayer. I want my script to draw circle around anchors I find problematic. Thanks!

I try to use annotation but you have to select the annotation tool to see the circle or arrows I created next to the faulty anchors. It’s not what I want.

When you only like to draw a circle around anchors, what do you need the image for?

This might help: Need help with Glyph API and Python - #26 by GeorgSeifert

Haaa it’s exaclty that. I don’t nee to use NSImage indeed, thanks!

Hum I’m note 100% sure I get it. Do I need to create an observer and update the NSBezeierPath while a certain condition is true? Raw code doesn’t draw anything. A portion of code maybe more clear:

	g = self.currentLayer.parent
	if g.glyphInfo.category == 'Letter':
		if g.glyphInfo.case == 1:
			for a in self.currentLayer.anchors:
				if a.name == 'top' and a.y != self.capHeight:
					rect = NSMakeRect(a.x, a.y, 20, 20)
					NSColor.colorWithRed_green_blue_alpha_(0.2, 0.8, 0.4, 1).set()
					path = NSBezierPath.bezierPathWithRect_(rect)
					path.fill()

Please read that thread carefully.