Last active
November 10, 2021 17:21
-
-
Save theoknock/a378183f53ffbd50e4f63c36c0a6f4fa to your computer and use it in GitHub Desktop.
Matching arc, ellipses or circular path to a touch location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { | |
^ (UITouch * touch) { | |
CGPoint center = CGPointMake(CGRectGetMaxX(rect), CGRectGetMaxY(rect)); | |
CGPoint tp = [touch preciseLocationInView:touch.view]; | |
CGFloat radius = sqrt(pow(tp.x - center.x, 2.0) + pow(tp.y - center.y, 2.0)); | |
UIBezierPath * bezier_quad_curve = [UIBezierPath bezierPathWithArcCenter:center | |
radius:radius | |
startAngle:degreesToRadians(270.0) | |
endAngle:degreesToRadians(180.0) | |
clockwise:FALSE]; | |
}([touches.anyObject]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code resizes an arc as a finger is dragged across the screen, its edge matching the touch location precisely.