Finally decided to go into OS X coding and struggling both with Objective-C (more an C++ guy) and the various APIs.
What I'm trying to achieve is drawing simple vector based GFX with the possibility to edit objects.
Found various names like Quartz, Core Graphics, Core Image ....
Examples I found use UIView, but are for iOS. Example for OS X has NSView and function names are slightly different.
Is what I gobbled together and it does seem to work, but I'm not sure wether I'm on the road to HW accelerated GFX or just entering a dead end....
What I'm trying to achieve is drawing simple vector based GFX with the possibility to edit objects.
Found various names like Quartz, Core Graphics, Core Image ....
Examples I found use UIView, but are for iOS. Example for OS X has NSView and function names are slightly different.
Code:
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
NSRect bound = [self bounds];
[[NSColor greenColor] set];
[NSBezierPath fillRect:bound];
NSBezierPath *aPath = [NSBezierPath bezierPath];
[[NSColor blueColor] set];
// Set the starting point of the shape.
[aPath moveToPoint:CGPointMake(100.0, 0.0)];
// Draw the lines.
[aPath lineToPoint:CGPointMake(200.0, 40.0)];
[aPath lineToPoint:CGPointMake(160, 140)];
[aPath lineToPoint:CGPointMake(40.0, 140)];
[aPath lineToPoint:CGPointMake(0.0, 40.0)];
[aPath closePath];
[aPath stroke];
}
Last edited: