{"id":286684,"date":"2017-05-22T15:10:03","date_gmt":"2017-05-22T11:10:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286684"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286684","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433 Paint \u043d\u0430 Objective-C"},"content":{"rendered":"<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0444\u043e\u0442\u043e\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0438\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u0430\u0432\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438: \u0437\u0430\u0442\u0435\u0440\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0438\u043a), \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 (\u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u0430\u0434\u0440\u0435\u0441 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0446\u0438\u0442\u0430\u0442\u0443), \u043e\u0431\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a\u0443\u044e \u043b\u0438\u0431\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u0438\u043b\u0438 \u00ab\u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u043e\u00bb. \u0421 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u0442\u0435\u043c\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u0438\u0442\u0430\u044f, \u043d\u043e \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u043f\u0440\u043e\u0449\u0435 \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u043d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/c91\/636\/d5c\/c91636d5c8e142b093b9dc6a04f879dd.jpg\"\/><\/div>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u041b\u044e\u0431\u0443\u044e \u043a\u0440\u0438\u0432\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043b\u0438\u043d\u0438\u0439. \u0422\u043e\u0433\u0434\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043a\u0440\u0438\u0432\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443:<\/p>\n<ol>\n<li>\u0420\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u043a\u0440\u0438\u0432\u0443\u044e \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432<\/li>\n<li>\u0421\u0442\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u043e \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u0430<\/li>\n<li>\u0420\u0438\u0441\u0443\u0435\u043c \u043b\u0438\u043d\u0438\u044e \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438<\/li>\n<li>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043e\u0442\u0440\u0435\u0437\u043a\u0443<\/li>\n<li>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0446\u0432\u0435\u0442, \u0442\u043e\u043b\u0449\u0438\u043d\u0443 \u043b\u0438\u043d\u0438\u0438 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/li>\n<li>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043b\u0438\u043d\u0438\u044e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d<\/li>\n<li>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u0430 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/li>\n<\/ol>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 PaintLine, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438. \u0420\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u043d\u0438\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 UIBezierPath.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c custom view. \u042d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u0430\u0441\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u043a\u0440\u0430\u0441\u043a\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043f\u0430\u043b\u044c\u0446\u0430 \u043a \u044d\u043a\u0440\u0430\u043d\u0443 \u0437\u0430\u0434\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438:<\/p>\n<pre><code class=\"objectivec\">- (void)touchesBegan:(NSSet&lt;UITouch *&gt; *)touches withEvent:(UIEvent *)event {     [super touchesBegan:touches withEvent:event];     NSSet *allTouches = [event allTouches];     if (allTouches.count != 1){         return;     }     UITouch *touch = [[allTouches allObjects] objectAtIndex:0];     pointTo = [touch locationInView:self]; }<\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u043b\u044c\u0446\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0446\u0435\u043f\u043d\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043b\u0438\u043d\u0438\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">- (void)touchesMoved:(NSSet&lt;UITouch *&gt; *)touches withEvent:(UIEvent *)event {     [super touchesMoved:touches withEvent:event];     NSSet *allTouches = [event allTouches];     if (allTouches.count != 1){         [linePaint removeAllObjects];         [self setNeedsDisplay];         return;     }     UITouch *touch = [[allTouches allObjects] objectAtIndex:0];     pointFrom = pointTo;     pointTo = [touch locationInView:self];     if (pointTo.y &lt; self.bounds.size.height && pointFrom.y &lt; self.bounds.size.height) {         [self addLineFrom:pointFrom to:pointTo];     } } <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u0430\u043b\u0435\u0446 \u043e\u0442 \u044d\u043a\u0440\u0430\u043d\u0430, \u043a\u0440\u0438\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"objectivec\">- (void)touchesEnded:(NSSet&lt;UITouch *&gt; *)touches withEvent:(UIEvent *)event {     [super touchesEnded:touches withEvent:event];     NSSet *allTouches = [event allTouches];     if (allTouches.count != 1){         [linePaint removeAllObjects];         [self setNeedsDisplay];         return;     }     UITouch *touch = [[allTouches allObjects] objectAtIndex:0];     pointFrom = pointTo;     pointTo = [touch locationInView:self];     if (pointTo.y &lt; self.bounds.size.height && pointFrom.y &lt; self.bounds.size.height) {         [self addLineFrom:pointFrom to:pointTo];     }     imgForPaint = [self getImage:imgForPaint];     dispatch_async(dispatch_get_main_queue(), ^{         if (_imageAfterEndPaint) {             _imageAfterEndPaint(imgForPaint);         }     }); } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u0438\u043d \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a. \u0415\u0441\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u0441\u0442\u0443\u044e \u043b\u0438\u043d\u0438\u044e, \u0442\u043e \u043a\u043e\u043d\u0446\u044b \u043e\u0442\u0440\u0435\u0437\u043a\u0430 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u043f\u0435\u043d\u0434\u0438\u043a\u0443\u043b\u044f\u0440\u043d\u044b \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043a\u0440\u0438\u0432\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043a\u0440\u0443\u0433\u043b\u043e\u0439 \u0444\u043e\u0440\u043c\u044b.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u0438\u043d\u0438\u0438 \u043a\u0440\u0443\u0433\u0438. \u0415\u0441\u043b\u0438 \u043f\u043b\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u0430\u043b\u044c\u0446\u0435\u043c \u043f\u043e \u044d\u043a\u0440\u0430\u043d\u0443 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u0440\u0435\u0437\u043a\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0435\u043b\u044c\u0435\u0444\u043d\u043e\u0441\u0442\u0438 \u043b\u0438\u043d\u0438\u0438 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0440\u0430\u0437\u0440\u044b\u0432\u043e\u0432.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0443\u044e \u0444\u0438\u0433\u0443\u0440\u0443, \u043a\u0430\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/a4a\/5df\/e88\/a4a5dfe8822e4a29872dab8fa3d91cd9.png\"\/><\/div>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u0430\u044f \u043a\u0440\u0438\u0432\u0430\u044f \u0441 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0446\u0430\u043c\u0438.<\/p>\n<pre><code class=\"objectivec\">- (UIBezierPath*)getBezuerPathWith:(float)zoom {     UIBezierPath *bezierPath = [[UIBezierPath alloc] init];     float width = zoom * _lineWidth \/ 2.;     for (PaintLine *line in linePaint) {         CGPoint point1 = CGPointApplyAffineTransform(line.point1, CGAffineTransformMakeScale(zoom, zoom));         CGPoint point2 = CGPointApplyAffineTransform(line.point2, CGAffineTransformMakeScale(zoom, zoom));         [bezierPath moveToPoint:point1];         float alf = atan2(point2.y - point1.y, point2.x - point1.x);         [bezierPath addArcWithCenter:point1 radius:width startAngle:alf + M_PI_2 endAngle:alf - M_PI_2 clockwise:YES];                  float alf0 = alf - M_PI_2;         CGPoint point = CGPointMake(cos(alf0) * width + point2.x, sin(alf0) * width + point2.y);         [bezierPath addLineToPoint:point];                  [bezierPath addArcWithCenter:point2 radius:width startAngle:alf - M_PI_2 endAngle:alf + M_PI_2 clockwise:YES];         alf0 = alf + M_PI_2;         point = CGPointMake(cos(alf0) * width + point1.x, sin(alf0) * width + point1.y);         [bezierPath addLineToPoint:point];     }     return bezierPath; }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0437\u0430\u043a\u0440\u0430\u0441\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041e\u043d\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\u041f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439<\/li>\n<li>\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e <\/li>\n<li>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c 32 \u0431\u0438\u0442\u0430 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ARGB<\/li>\n<li>\u0421\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/li>\n<\/ol>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0441\u0442\u0435\u043a\u0430 \u0438\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0440\u0430\u0437\u043b\u0438\u0432\u0430\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<p>  1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0446\u0432\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b<br \/>  2. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043b\u0438 \u0446\u0432\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b \u0441 \u043d\u043e\u0432\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442:<\/p>\n<p>  \u0430) \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c<br \/>   \u0431) \u041f\u0435\u0440\u0435\u043a\u0440\u0430\u0441\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 \u043d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<br \/>   \u0432) \u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c, \u043f\u043e\u043a\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435 \u043e\u043f\u0443\u0441\u0442\u0435\u0435\u0442<br \/>   \u0433) \u0412\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/p>\n<p>  3. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439<br \/>  4. \u0415\u0441\u043b\u0438 \u0446\u0432\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0447\u0430\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0440\u0430\u0432\u0435\u043d \u0446\u0432\u0435\u0442\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b:<\/p>\n<p>  \u0430) \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<br \/>   \u0431) \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/p>\n<p>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043b\u0438\u0432\u043a\u0438:<\/p>\n<p>  <b>1. \u0417\u0430\u043b\u0438\u0432\u043a\u0430 \u043f\u043e 4 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c \u0442\u043e\u0447\u043a\u0430\u043c<\/b><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/495\/4f8\/1d9\/4954f81d94d9449aa0b8b4b987bd5acd.png\"\/><\/div>\n<p>  <b>2. \u0417\u0430\u043b\u0438\u0432\u043a\u0430 \u043f\u043e 8 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c \u0442\u043e\u0447\u043a\u0430\u043c<\/b><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/af4\/c75\/d4a\/af4c75d4aa324ff39b8f0178a8e364ee.png\"\/><\/div>\n<p>  <b>3. \u0427\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u043f\u043e 4 \u0438 8 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c \u0442\u043e\u0447\u043a\u0430\u043c (2 \u2014 \u043f\u043e \u0447\u0435\u0442\u044b\u0440\u0435\u043c, 1 \u2014 \u043f\u043e \u0432\u043e\u0441\u044c\u043c\u0438)<\/b><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/d71\/1eb\/7e2\/d711eb7e22494a9686de7e8414433913.png\"\/><\/div>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u043b\u0438\u0432\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0436\u0438\u0434\u043a\u043e\u0441\u0442\u0438 \u043f\u043e \u0440\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u043f\u043e \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<p>  1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0446\u0432\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b<br \/>  2. \u0415\u0441\u043b\u0438 \u0446\u0432\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043d\u043e\u0432\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f:<\/p>\n<p>  \u0430) \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c<br \/>   \u0431) \u041f\u0435\u0440\u0435\u043a\u0440\u0430\u0441\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 \u043d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<br \/>   \u0432) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0432\u043d\u043e\u0435 1<br \/>   \u0433) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0434\u0438\u0443\u0441\u0443<br \/>   \u0434) \u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c, \u043f\u043e\u043a\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435 \u043e\u043f\u0443\u0441\u0442\u0435\u0435\u0442<br \/>   \u0435) \u0412\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<br \/>   \u0436) \u0423\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043d\u0430 1 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0434\u0438\u0443\u0441\u0443<\/p>\n<p>  3. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439<br \/>  4. \u0415\u0441\u043b\u0438 \u0446\u0432\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0447\u0430\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0440\u0430\u0432\u0435\u043d \u0446\u0432\u0435\u0442\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b:<\/p>\n<p>  \u0430) \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<br \/>   \u0431) \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/p>\n<p>  5. \u0415\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0434\u0438\u0443\u0441\u0443, \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c \u0434\u043e 0:<\/p>\n<p>  \u0430) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u043e, \u0440\u0430\u0432\u043d\u043e\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<br \/>   \u0431) \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043d\u0430 1 \u0440\u0430\u0434\u0438\u0443\u0441 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041f\u0443\u0442\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u0437\u0430\u043c\u0435\u043d\u044b \u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">[colorQueue addObject:[NSValue valueWithCGPoint:newStartPoint]];          int offset = 4*((w*round(newStartPoint.y))+round(newStartPoint.x)) + 1; memcpy(colorFroUpdate, &data[offset], 3);          float limit = 10; isCanPaint = !(abs(newColorArray[0] - data[offset]) &lt; limit && abs(newColorArray[1] - data[offset + 1]) &lt; limit && abs(newColorArray[2] - data[offset + 2]) &lt; limit);          NSInteger countPixelICurrentIterrations = 1; int iterrationIndex = 1;          while (isCanPaint && colorQueue.count &gt; 0) { \tCGPoint point = [[colorQueue objectAtIndex:0] CGPointValue]; \t[colorQueue removeObjectAtIndex:0]; \tcountPixelICurrentIterrations--; \toffset = 4*((w*round(point.y))+round(point.x)) + 1; \tmemcpy(&data[offset], newColorArray, 3); \tCGPoint newPoint; \tint x0 = point.x - 1; \tint x1 = point.x + 1; \tint y0 = point.y - 1; \tint y1 = point.y + 1; \tfor (int x = x0; x &lt;= x1; x++) { \t\tfor (int y = y0; y &lt;= y1; y++) { \t\t\tfloat s = sqrtf((x - newStartPoint.x) * (x - newStartPoint.x) + (y - newStartPoint.y) * (y - newStartPoint.y)); \t\t\tif (s &lt; iterrationIndex + 1) { \t\t\t\tnewPoint = CGPointMake(x, y); \t\t\t\tif (newPoint.x &gt;= 0 && newPoint.x &lt; w && newPoint.y &gt;= 0 && newPoint.y &lt; h) { \t\t\t\t\toffset = 4*((w*round(newPoint.y))+round(newPoint.x)) + 1; \t\t\t\t\tif (abs(colorFroUpdate[0] - data[offset]) &lt; limit && abs(colorFroUpdate[1] - data[offset + 1]) &lt; limit && abs(colorFroUpdate[2] - data[offset + 2]) &lt; limit) { \t\t\t\t\t\tmemcpy(&data[offset], newColorArray, 3); \t\t\t\t\t\t[colorQueue addObject:[NSValue valueWithCGPoint:newPoint]]; \t\t\t\t\t} \t\t\t\t} \t\t\t} \t\t} \t}              \tif (countPixelICurrentIterrations &lt;= 0 && self.updateImageOn) { \t\t\tif (iterrationIndex % 5 == 0) \t\t\t@autoreleasepool { \t\t\t\tCGImageRef cgImage = CGBitmapContextCreateImage(cgctx); \t\t\t\tUIImage *resultUIImage = [UIImage imageWithCGImage:cgImage]; \t\t\t\tself.updateImageOn(resultUIImage); \t\t\t\tCGImageRelease(cgImage); \t\t\t}                  \t\t\tcountPixelICurrentIterrations = [colorQueue count]; \t\t\titerrationIndex++; \t\t\t} \t} }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043b\u0438\u0432\u043a\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/70f\/9ba\/ead\/70f9baeada674ac0a842f2d883f6a6fe.gif\"\/><\/div>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0438 \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/329180\/\"> https:\/\/habrahabr.ru\/post\/329180\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0444\u043e\u0442\u043e\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0438\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u0430\u0432\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438: \u0437\u0430\u0442\u0435\u0440\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0438\u043a), \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 (\u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u0430\u0434\u0440\u0435\u0441 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0446\u0438\u0442\u0430\u0442\u0443), \u043e\u0431\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a\u0443\u044e \u043b\u0438\u0431\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u0438\u043b\u0438 \u00ab\u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u043e\u00bb. \u0421 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u0442\u0435\u043c\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u0438\u0442\u0430\u044f, \u043d\u043e \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u043f\u0440\u043e\u0449\u0435 \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u043d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/web\/c91\/636\/d5c\/c91636d5c8e142b093b9dc6a04f879dd.jpg\"\/><\/div>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286684","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286684"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286684\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}