Am I using Quartz or what ??

Discussion in 'Mac Programming' started by Bug-Creator, Aug 14, 2016.

  1. Bug-Creator, Aug 14, 2016
    Last edited: Aug 14, 2016

    Bug-Creator macrumors 6502


    May 30, 2011
    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.

    - (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];
    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....
  2. Madd the Sane macrumors 6502a

    Madd the Sane

    Nov 8, 2010
    AppKit and UIKit uses CoreGraphics internally for drawing. CoreGraphics is also called Quartz.

Share This Page