Category Archives: Uncategorized

midlife crises

I generally have tried to have a midlife crisis every couple of years, in the hopes that it would extend my life  by four…  I’m about due.

It’s been a while since I seriously reevaluated my lifestyle and work. but now is the time.  I’m going to lock my self in the shop (metaphorically) friday after work and come out sunday night.  hopefully I’ll have been able to spend enough contiguous time in the studio to get my head wrapped around all the projects I either have going on or want to get started…

we shall see…

CGContextAddArcToPoint()

void CGContextAddArcToPoint (
   CGContextRef c,
   CGFloat x1,
   CGFloat y1,
   CGFloat x2,
   CGFloat y2,
   CGFloat radius
);

Seems simple enough. the thing to remember is that the first point is the corner you would have been going to go to if you were doing a hard corner, and the second point is the point where you’re intending to go next.

so, if you were to draw an angle, you might do the following.

CGContextMoveToPoint(ctx, 10.0, 60.0);    CGContextAddLineToPoint(ctx, 60.0, 60.0);
CGContextAddLineToPoint(ctx, 60.0, 10.0);

to get:
Screen Shot 2013-12-20 at 12.43.49 PM

if you want to make the corner rounded, you would replace the middle point with an addArcToPoint like:

CGContextMoveToPoint(ctx, 10.0, 60.0);
CGContextAddArcToPoint(ctx, 60, 60, 60, 10, 20);
CGContextAddLineToPoint(ctx, 60, 10);

to get:
Screen Shot 2013-12-20 at 12.44.07 PM

note that despite telling the arc where you want to end up, you still have to draw the line to get there. otherwise you get the rounded corner and nothing else.  from this you can establish that addArcToPoint is basically drawing two straight lines that meet where your corner would have been, and then tries to wedge a circle of the requested radius into that corner. the arc that results from tangent to tangent, as well as the line from the previous point is what is actually drawn.  it does not, however, draw the line from the end of the arc to the next point. you have to do that yourself.  it’s important to note that if you want the line leaving the arc to be tangent to that arc, it should probably actually be a line to the second point that you defined in the addArcToPoint function.

one caveat to this is that if the starting point (the one in the moveTo…  line) and the first point in the addArcToPoint are the same, there will be no arc.

so if you want to make a circle you might do the following

CGContextMoveToPoint(ctx, 20, 20);
CGContextAddArcToPoint(ctx, 20, 10, 10, 10, 10);
CGContextAddArcToPoint(ctx, 0, 10, 0, 20, 10);
CGContextAddArcToPoint(ctx, 0, 30, 10, 30, 10);
CGContextAddArcToPoint(ctx, 20, 30, 20, 20, 10);

and you get:
Screen Shot 2013-12-20 at 12.44.49 PM

one last thing. it is up to you to make sure that the arc radius is small enough to fit into the corner that would have been drawn. otherwise it will draw the complete arc angle that you request, but it probably won’t be where you want it to be.  for example, this code:

CGContextMoveToPoint(ctx, 20.0, 50.0);
CGContextAddArcToPoint(ctx, 50, 50, 20, 20, 25);
CGContextAddLineToPoint(ctx, 20, 20);

gives you:
Screen Shot 2013-12-20 at 12.47.42 PM

where an arc radius of 5 would have given you:

Screen Shot 2013-12-20 at 12.52.08 PM

which is probably what you wanted… right?

movie review

well, comment…

I highly recommend Thor: the Dark World. I will never hear “ta-da!” the same ever again.  Very funny, contrasting the very dramatic. I haven’t laughed that hard at the right parts of a movie in so long…  Marvel has definitely held on to their high level of attention to detail and should be rewarded for that.

go see!