Authored by Justin R. Miller

adapt #231 for configurability

Merge commit 'adf08cbe' into develop
... ... @@ -84,6 +84,9 @@
/** The bounding box of the shape in the current viewport. */
@property (nonatomic, readonly) CGRect pathBoundingBox;
/** An additional pixel area around the shape that is applied to touch hit testing events. Defaults to none. */
@property (nonatomic, assign) CGFloat additionalTouchPadding;
/** @name Drawing Shapes */
/** Move the drawing pen to a projected point.
... ...
... ... @@ -435,11 +435,25 @@
{
// if shape is not filled with a color, do a simple "point on path" test
//
if (self.additionalTouchPadding)
{
CGPathRef tapTargetPath = CGPathCreateCopyByStrokingPath(shapeLayer.path, nil, fmaxf(self.additionalTouchPadding, shapeLayer.lineWidth), 0, 0, 0);
if (tapTargetPath)
{
containsPoint = [[UIBezierPath bezierPathWithCGPath:tapTargetPath] containsPoint:thePoint];
CGPathRelease(tapTargetPath);
}
}
else
{
UIGraphicsBeginImageContext(self.bounds.size);
CGContextAddPath(UIGraphicsGetCurrentContext(), shapeLayer.path);
containsPoint = CGContextPathContainsPoint(UIGraphicsGetCurrentContext(), thePoint, kCGPathStroke);
UIGraphicsEndImageContext();
}
}
else
{
// else do a "path contains point" test
... ...