Skip to content

Commit

Permalink
Fix 'distance' symbol duplication with MobileVLCKit (tools.c.o).
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyapavkin committed Feb 14, 2020
1 parent b2f2d15 commit da74ea1
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions ios/Utils/RNSVGPathMeasure.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@
*/
static CGFloat idealFlatness = (CGFloat).01;

/**
* returns the distance between two points
*/
CGFloat distance(CGPoint p1, CGPoint p2)
{
CGFloat dx = p2.x - p1.x;
CGFloat dy = p2.y - p1.y;
return hypot(dx, dy);
}

// Subdivide a Bézier (specific division)
/*
* (c) 2004 Alastair J. Houghton
Expand Down Expand Up @@ -85,10 +75,18 @@ void subdivideBezierAtT(const CGPoint bez[4], CGPoint bez1[4], CGPoint bez2[4],
}

@implementation RNSVGPathMeasure
/**
* returns the distance between two points
*/
+(CGFloat) distanceFrom:(CGPoint) p1 to:(CGPoint) p2 {
CGFloat dx = p2.x - p1.x;
CGFloat dy = p2.y - p1.y;
return hypot(dx, dy);
}

- (void)addLine:(CGPoint *)last next:(const CGPoint *)next {
NSArray *line = @[[NSValue valueWithCGPoint:*last], [NSValue valueWithCGPoint:*next]];
_pathLength += distance(*last, *next);
_pathLength += [RNSVGPathMeasure distanceFrom:*last to:*next];
[_lengths addObject:[NSNumber numberWithDouble:_pathLength]];
[_lines addObject:line];
*last = *next;
Expand Down Expand Up @@ -153,10 +151,10 @@ - (void)extractPathData:(CGPathRef)path {
CGPoint ctrl2 = bez[2];
CGPoint next = bez[3];
CGFloat polyLen =
distance(last, ctrl1) +
distance(ctrl1, ctrl2) +
distance(ctrl2, next);
CGFloat chordLen = distance(last, next);
[RNSVGPathMeasure distanceFrom:last to:ctrl1] +
[RNSVGPathMeasure distanceFrom:ctrl1 to:ctrl2] +
[RNSVGPathMeasure distanceFrom:ctrl2 to:next];
CGFloat chordLen = [RNSVGPathMeasure distanceFrom:last to:next];
CGFloat error = polyLen - chordLen;

// if the error is less than our accepted level of error
Expand Down

0 comments on commit da74ea1

Please sign in to comment.