Drawing layer in viewPort coords


I may be missing something rather obvious here, but is there are relatively straightforward way to draw a glyph Layer in the top left corner of the viewPort, like one can draw text/other bezier paths just using viewPort.origin.x/.y?

At the moment my early tests seem to draw it in with coordinated relative to the glyph origin, not the viewport. I know there’s likely a workaround using maths and the methods that are accessible via currentTab, but just in case I’m making it harder than it needs to be…


The selectedLayerOrigin attribute of the current tab may help you in that case:

Are you making a Reporter plugin? Then there are the drawBackgroundWithOptions_() and drawForegroundWithOptions_() callbacks.

This is from the FramesPerSecond plugin. It is written in ObjectiveC, but you will get the point.

- (void)drawForegroundWithOptions:(NSDictionary *)options {
	if (fpsMilisec + 1.0 < [NSDate timeIntervalSinceReferenceDate]) {
		fpsFramesPerSecond = fpsCounter / ([NSDate timeIntervalSinceReferenceDate] - fpsMilisec);
		fpsMilisec = [NSDate timeIntervalSinceReferenceDate];
		fpsCounter = 0;
	NSRect VisibleRect = [editViewController.graphicView visibleRect];
	VisibleRect = NSInsetRect(VisibleRect, 2, 2);
	NSColor* color;
	if (fpsFramesPerSecond > 22) {
		color = [NSColor greenColor];
	else if (fpsFramesPerSecond > 14) {
		color = [NSColor greenColor];
	else {
		color = [NSColor redColor];
	[[NSString stringWithFormat:@"fps: %.1f", fpsFramesPerSecond] drawAtPoint:VisibleRect.origin color:color alignment:GSBottomLeft];