Drawing inside an NSImage?
Drawing inside an NSImage?
- Subject: Drawing inside an NSImage?
- From: "Patrick J. Collins" <email@hidden>
- Date: Sun, 08 Mar 2015 16:12:26 -0700 (PDT)
I have an NSView which has in its "drawRect:" method:
NSColor *backgroundColor = [NSColor colorWithPatternImage:self.image];
[backgroundColor setFill];
...
the image method does:
-(NSImage *)image {
if (!_image) {
_image = [[NSImage alloc] initWithSize:self.bounds.size];
[_image lockFocus];
[[NSColor blueColor] set];
NSBezierPath *line = [NSBezierPath bezierPath];
NSPoint pointA = NSMakePoint(0, 0);
NSPoint pointB = NSMakePoint(self.bounds.size.width, 0);
[line moveToPoint:pointA];
[line lineToPoint:pointB];
[line stroke];
}
return _image;
}
The resulting line is drawn off center (somewhere around -10px) from the middle
of the NSView... I would like to have my 0,0 origin be the bottom left corner
of the NSView as I would get if I were to put this line directly in the
drawRect (not using an NSImage): method..
What am I doing wrong here?
Patrick J. Collins
http://collinatorstudios.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden