@@ -272,6 +272,10 @@ public final class AvatarEditOverlayNode: ASDisplayNode {
272272 }
273273}
274274
275+ private func generateAvatarBubblePath( ) -> CGPath {
276+ return try ! convertSvgPath ( " M60,30.274903 C60,46.843446 46.568544,60.274904 30,60.274904 C13.431458,60.274904 0,46.843446 0,30.274903 C0,23.634797 2.158635,17.499547 5.810547,12.529785 L6.036133,12.226074 C6.921364,10.896042 7.367402,8.104698 5.548828,5.316895 C3.606939,2.340088 1.186019,0.979668 2.399414,0.470215 C3.148032,0.156204 7.572027,0.000065 10.764648,1.790527 C12.148517,2.56662 13.2296,3.342422 14.09224,4.039734 C14.42622,4.309704 14.892063,4.349773 15.265962,4.138523 C19.618079,1.679604 24.644722,0.274902 30,0.274902 C46.568544,0.274902 60,13.70636 60,30.274903 Z " )
277+ }
278+
275279public final class AvatarNode : ASDisplayNode {
276280 public static func avatarBubbleMask( size: CGSize ) -> UIImage ! {
277281 return generateImage ( size, rotatedContext: { size, context in
@@ -282,19 +286,20 @@ public final class AvatarNode: ASDisplayNode {
282286 } )
283287 }
284288
289+ public static let avatarBubblePath : CGPath = generateAvatarBubblePath ( )
290+
285291 public static func addAvatarBubblePath( context: CGContext , rect: CGRect ) {
286- if let path = try ? convertSvgPath ( " M60,30.274903 C60,46.843446 46.568544,60.274904 30,60.274904 C13.431458,60.274904 0,46.843446 0,30.274903 C0,23.634797 2.158635,17.499547 5.810547,12.529785 L6.036133,12.226074 C6.921364,10.896042 7.367402,8.104698 5.548828,5.316895 C3.606939,2.340088 1.186019,0.979668 2.399414,0.470215 C3.148032,0.156204 7.572027,0.000065 10.764648,1.790527 C12.148517,2.56662 13.2296,3.342422 14.09224,4.039734 C14.42622,4.309704 14.892063,4.349773 15.265962,4.138523 C19.618079,1.679604 24.644722,0.274902 30,0.274902 C46.568544,0.274902 60,13.70636 60,30.274903 Z " ) {
287- let sx = rect. width / 60.0
288- let sy = rect. height / 60.0
289- var transform = CGAffineTransform (
290- a: sx, b: 0.0 ,
291- c: 0.0 , d: - sy,
292- tx: rect. minX,
293- ty: rect. minY + rect. height
294- )
295- let transformedPath = path. copy ( using: & transform) !
296- context. addPath ( transformedPath)
297- }
292+ let path = AvatarNode . avatarBubblePath
293+ let sx = rect. width / 60.0
294+ let sy = rect. height / 60.274904
295+ var transform = CGAffineTransform (
296+ a: sx, b: 0.0 ,
297+ c: 0.0 , d: - sy,
298+ tx: rect. minX,
299+ ty: rect. minY + rect. height
300+ )
301+ let transformedPath = path. copy ( using: & transform) !
302+ context. addPath ( transformedPath)
298303 }
299304
300305 public static let gradientColors : [ [ UIColor ] ] = [
0 commit comments