theLen = [NSBezierPath bezierPath];
[theLen moveToPoint:NSMakePoint(_frame.size.width/2 + base / 2 , _frame.size.height/2 - (diameter / 2))];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 - base / 2 , _frame.size.height/2 - (diameter / 2))];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 - (thickness / 2 ) , _frame.size.height/2)];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 - base / 2 , _frame.size.height/2 + (diameter / 2))];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 + base / 2 , _frame.size.height/2 + (diameter / 2))];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 + (thickness / 2 ) , _frame.size.height/2)];
[theLen closePath];
theLen.lineWidth = 2;
[theLen stroke];
[theLen fill];
Given this code, how would you simplify it? I'm trying to learn how to simplify code and all I could think off is turning that into...
float commonNSPoint[4];
commonNSPoint[0] = _frame.size.width/2 + base / 2;
commonNSPoint[1] = _frame.size.width/2 - base / 2;
commonNSPoint[2] = _frame.size.height/2 - (diameter / 2);
commonNSPoint[3] = _frame.size.height/2 + (diameter / 2);
theLen = [NSBezierPath bezierPath];
[theLen moveToPoint:NSMakePoint( commonNSPoint[0], commonNSPoint[2])];
[theLen lineToPoint:NSMakePoint(commonNSPoint[1], commonNSPoint[2])];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 - (thickness / 2 ) , _frame.size.height/2)];
[theLen lineToPoint:NSMakePoint(commonNSPoint[1], commonNSPoint[3])];
[theLen lineToPoint:NSMakePoint( commonNSPoint[0], commonNSPoint[3])];
[theLen lineToPoint:NSMakePoint(_frame.size.width/2 + (thickness / 2 ) , _frame.size.height/2)];
[theLen closePath];
[theLen closePath];
theLen.lineWidth = 2;
[theLen stroke];
[theLen fill];
Which doesn't really help me since NSBezierPath or UIBezierPath doesn't have their point location exactly the same. Also this made the code look messier.
How would you guys simplify a NSBezierPath or UIBezierPath such as this. Anything will help (since my program is base on different value of NSPoint and many NSBezierPath drawing).
Thank