mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-03 15:14:18 +00:00
Fix warnings
This commit is contained in:
@@ -27,10 +27,6 @@
|
|||||||
[node mergeProperties:self];
|
[node mergeProperties:self];
|
||||||
[node renderTo:context];
|
[node renderTo:context];
|
||||||
|
|
||||||
if ([node isKindOfClass: [RNSVGRenderable class]]) {
|
|
||||||
RNSVGRenderable *renderable = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
[template mergeProperties:self];
|
[template mergeProperties:self];
|
||||||
|
|
||||||
if ([template class] == [RNSVGSymbol class]) {
|
if ([template class] == [RNSVGSymbol class]) {
|
||||||
RNSVGSymbol *symbol = template;
|
RNSVGSymbol *symbol = (RNSVGSymbol*)template;
|
||||||
[symbol renderSymbolTo:context width:[self relativeOnWidth:self.width] height:[self relativeOnWidth:self.height]];
|
[symbol renderSymbolTo:context width:[self relativeOnWidth:self.width] height:[self relativeOnWidth:self.height]];
|
||||||
} else {
|
} else {
|
||||||
[template renderTo:context];
|
[template renderTo:context];
|
||||||
|
|||||||
+2
-2
@@ -14,7 +14,7 @@
|
|||||||
{
|
{
|
||||||
BOOL _transparent;
|
BOOL _transparent;
|
||||||
CGPathRef _cachedClipPath;
|
CGPathRef _cachedClipPath;
|
||||||
UIView *_svgView;
|
RNSVGSvgView *_svgView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
// abstract
|
// abstract
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)traverseSubviews:(BOOL (^)(RNSVGNode *node))block
|
- (void)traverseSubviews:(BOOL (^)(__kindof RNSVGNode *node))block
|
||||||
{
|
{
|
||||||
for (RNSVGNode *node in self.subviews) {
|
for (RNSVGNode *node in self.subviews) {
|
||||||
if ([node isKindOfClass:[RNSVGNode class]]) {
|
if ([node isKindOfClass:[RNSVGNode class]]) {
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
case kRNSVGTextAnchorEnd:
|
case kRNSVGTextAnchorEnd:
|
||||||
x = -width;
|
x = -width;
|
||||||
break;
|
break;
|
||||||
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CGAffineTransformMakeTranslation(x, 0);
|
return CGAffineTransformMakeTranslation(x, 0);
|
||||||
@@ -125,7 +126,7 @@
|
|||||||
//todo: throw exception here
|
//todo: throw exception here
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_textRoot = [_textRoot superview];
|
_textRoot = (RNSVGText*)[_textRoot superview];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
RNSVGPath *path = template;
|
RNSVGPath *path = (RNSVGPath *)template;
|
||||||
CGFloat startOffset = [self relativeOnWidth:self.startOffset];
|
CGFloat startOffset = [self relativeOnWidth:self.startOffset];
|
||||||
return [[RNSVGBezierTransformer alloc] initWithBezierCurvesAndStartOffset:[path getBezierCurves]
|
return [[RNSVGBezierTransformer alloc] initWithBezierCurvesAndStartOffset:[path getBezierCurves]
|
||||||
startOffset:startOffset];
|
startOffset:startOffset];
|
||||||
|
|||||||
@@ -21,14 +21,12 @@
|
|||||||
@interface RCTConvert (RNSVG)
|
@interface RCTConvert (RNSVG)
|
||||||
|
|
||||||
+ (RNSVGTextAnchor)RNSVGTextAnchor:(id)json;
|
+ (RNSVGTextAnchor)RNSVGTextAnchor:(id)json;
|
||||||
+ (RNSVGPathParser *)CGPath:(NSString *)d;
|
|
||||||
+ (CTTextAlignment)CTTextAlignment:(id)json;
|
|
||||||
+ (RNSVGCGFCRule)RNSVGCGFCRule:(id)json;
|
+ (RNSVGCGFCRule)RNSVGCGFCRule:(id)json;
|
||||||
+ (RNSVGVBMOS)RNSVGVBMOS:(id)json;
|
+ (RNSVGVBMOS)RNSVGVBMOS:(id)json;
|
||||||
+ (RNSVGCGFloatArray)RNSVGCGFloatArray:(id)json;
|
+ (RNSVGCGFloatArray)RNSVGCGFloatArray:(id)json;
|
||||||
+ (RNSVGBrush *)RNSVGBrush:(id)json;
|
+ (RNSVGBrush *)RNSVGBrush:(id)json;
|
||||||
|
|
||||||
|
+ (RNSVGPathParser *)CGPath:(NSString *)d;
|
||||||
+ (CGRect)CGRect:(id)json offset:(NSUInteger)offset;
|
+ (CGRect)CGRect:(id)json offset:(NSUInteger)offset;
|
||||||
+ (CGColorRef)CGColor:(id)json offset:(NSUInteger)offset;
|
+ (CGColorRef)CGColor:(id)json offset:(NSUInteger)offset;
|
||||||
+ (CGGradientRef)CGGradient:(id)json offset:(NSUInteger)offset;
|
+ (CGGradientRef)CGGradient:(id)json offset:(NSUInteger)offset;
|
||||||
|
|||||||
@@ -171,7 +171,8 @@ RCT_ENUM_CONVERTER(RNSVGTextAnchor, (@{
|
|||||||
RNSVGCGFloatArray colorsAndOffsets = [self RNSVGCGFloatArray:arr];
|
RNSVGCGFloatArray colorsAndOffsets = [self RNSVGCGFloatArray:arr];
|
||||||
size_t stops = colorsAndOffsets.count / 5;
|
size_t stops = colorsAndOffsets.count / 5;
|
||||||
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
|
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
|
||||||
|
|
||||||
|
|
||||||
CGGradientRef gradient = CGGradientCreateWithColorComponents(
|
CGGradientRef gradient = CGGradientCreateWithColorComponents(
|
||||||
rgb,
|
rgb,
|
||||||
colorsAndOffsets.array,
|
colorsAndOffsets.array,
|
||||||
@@ -179,7 +180,6 @@ RCT_ENUM_CONVERTER(RNSVGTextAnchor, (@{
|
|||||||
stops
|
stops
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CGColorSpaceRelease(rgb);
|
CGColorSpaceRelease(rgb);
|
||||||
free(colorsAndOffsets.array);
|
free(colorsAndOffsets.array);
|
||||||
return (CGGradientRef)CFAutorelease(gradient);
|
return (CGGradientRef)CFAutorelease(gradient);
|
||||||
|
|||||||
+20
-22
@@ -10,7 +10,7 @@
|
|||||||
#import <React/RCTLog.h>
|
#import <React/RCTLog.h>
|
||||||
#import "math.h"
|
#import "math.h"
|
||||||
|
|
||||||
@implementation RNSVGPathParser : NSObject
|
@implementation RNSVGPathParser
|
||||||
{
|
{
|
||||||
NSString* _d;
|
NSString* _d;
|
||||||
NSString* _originD;
|
NSString* _originD;
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
NSRegularExpression* decimalRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(\\.\\d+)(?=\\-?\\.)" options:0 error:nil];
|
NSRegularExpression* decimalRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(\\.\\d+)(?=\\-?\\.)" options:0 error:nil];
|
||||||
_originD = d;
|
_originD = d;
|
||||||
_d = [decimalRegularExpression stringByReplacingMatchesInString:d options:0 range:NSMakeRange(0, [d length]) withTemplate:@"$1\,"];
|
_d = [decimalRegularExpression stringByReplacingMatchesInString:d options:0 range:NSMakeRange(0, [d length]) withTemplate:@"$1,"];
|
||||||
_pathRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"[a-df-z]|[\\-+]?(?:[\\d.]e[\\-+]?|[^\\s\\-+,a-z])+" options:NSRegularExpressionCaseInsensitive error:nil];
|
_pathRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"[a-df-z]|[\\-+]?(?:[\\d.]e[\\-+]?|[^\\s\\-+,a-z])+" options:NSRegularExpressionCaseInsensitive error:nil];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@@ -148,12 +148,12 @@
|
|||||||
return ![value isEqualToString:@"0"];
|
return ![value isEqualToString:@"0"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)move:(CGPathRef)path x:(float)x y:(float)y
|
- (void)move:(CGMutablePathRef)path x:(float)x y:(float)y
|
||||||
{
|
{
|
||||||
[self moveTo:path x:x + _penX y:y + _penY];
|
[self moveTo:path x:x + _penX y:y + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveTo:(CGPathRef)path x:(float)x y:(float)y
|
- (void)moveTo:(CGMutablePathRef)path x:(float)x y:(float)y
|
||||||
{
|
{
|
||||||
_pivotX = _penX = x;
|
_pivotX = _penX = x;
|
||||||
_pivotY = _penY = y;
|
_pivotY = _penY = y;
|
||||||
@@ -163,14 +163,12 @@
|
|||||||
[_bezierCurves addObject: @[_lastStartPoint]];
|
[_bezierCurves addObject: @[_lastStartPoint]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)line:(CGPathRef)path x:(float)x y:(float)y
|
- (void)line:(CGMutablePathRef)path x:(float)x y:(float)y
|
||||||
{
|
{
|
||||||
[self lineTo:path x:x + _penX y:y + _penY];
|
[self lineTo:path x:x + _penX y:y + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)lineTo:(CGPathRef)path x:(float)x y:(float)y{
|
- (void)lineTo:(CGMutablePathRef)path x:(float)x y:(float)y{
|
||||||
NSValue * source = [NSValue valueWithCGPoint:CGPointMake(_pivotX, _pivotY)];
|
|
||||||
|
|
||||||
[self setPenDown];
|
[self setPenDown];
|
||||||
_pivotX = _penX = x;
|
_pivotX = _penX = x;
|
||||||
_pivotY = _penY = y;
|
_pivotY = _penY = y;
|
||||||
@@ -180,7 +178,7 @@
|
|||||||
[_bezierCurves addObject: @[destination, destination, destination]];
|
[_bezierCurves addObject: @[destination, destination, destination]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)curve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey
|
- (void)curve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey
|
||||||
{
|
{
|
||||||
[self curveTo:path c1x:c1x + _penX
|
[self curveTo:path c1x:c1x + _penX
|
||||||
c1y:c1y + _penY
|
c1y:c1y + _penY
|
||||||
@@ -190,14 +188,14 @@
|
|||||||
ey:ey + _penY];
|
ey:ey + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)curveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey
|
- (void)curveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey
|
||||||
{
|
{
|
||||||
_pivotX = c2x;
|
_pivotX = c2x;
|
||||||
_pivotY = c2y;
|
_pivotY = c2y;
|
||||||
[self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey];
|
[self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)curveToPoint:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey
|
- (void)curveToPoint:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey
|
||||||
{
|
{
|
||||||
[self setPenDown];
|
[self setPenDown];
|
||||||
_penX = ex;
|
_penX = ex;
|
||||||
@@ -211,12 +209,12 @@
|
|||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)smoothCurve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey
|
- (void)smoothCurve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey
|
||||||
{
|
{
|
||||||
[self smoothCurveTo:path c1x:c1x + _penX c1y:c1y + _penY ex:ex + _penX ey:ey + _penY];
|
[self smoothCurveTo:path c1x:c1x + _penX c1y:c1y + _penY ex:ex + _penX ey:ey + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)smoothCurveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey
|
- (void)smoothCurveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey
|
||||||
{
|
{
|
||||||
float c2x = c1x;
|
float c2x = c1x;
|
||||||
float c2y = c1y;
|
float c2y = c1y;
|
||||||
@@ -227,12 +225,12 @@
|
|||||||
[self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey];
|
[self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)quadraticBezierCurve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y
|
- (void)quadraticBezierCurve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y
|
||||||
{
|
{
|
||||||
[self quadraticBezierCurveTo:path c1x:(float)c1x + _penX c1y:(float)c1y + _penY c2x:(float)c2x + _penX c2y:(float)c2y + _penY];
|
[self quadraticBezierCurveTo:path c1x:(float)c1x + _penX c1y:(float)c1y + _penY c2x:(float)c2x + _penX c2y:(float)c2y + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)quadraticBezierCurveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y
|
- (void)quadraticBezierCurveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y
|
||||||
{
|
{
|
||||||
_pivotX = c1x;
|
_pivotX = c1x;
|
||||||
_pivotY = c1y;
|
_pivotY = c1y;
|
||||||
@@ -245,12 +243,12 @@
|
|||||||
[self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey];
|
[self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)smoothQuadraticBezierCurve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y
|
- (void)smoothQuadraticBezierCurve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y
|
||||||
{
|
{
|
||||||
[self smoothQuadraticBezierCurveTo:path c1x:c1x + _penX c1y:c1y + _penY];
|
[self smoothQuadraticBezierCurveTo:path c1x:c1x + _penX c1y:c1y + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)smoothQuadraticBezierCurveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y
|
- (void)smoothQuadraticBezierCurveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y
|
||||||
{
|
{
|
||||||
float c2x = c1x;
|
float c2x = c1x;
|
||||||
float c2y = c1y;
|
float c2y = c1y;
|
||||||
@@ -259,12 +257,12 @@
|
|||||||
[self quadraticBezierCurveTo:path c1x:c1x c1y:c1y c2x:c2x c2y:c2y];
|
[self quadraticBezierCurveTo:path c1x:c1x c1y:c1y c2x:c2x c2y:c2y];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)arc:(CGPathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y
|
- (void)arc:(CGMutablePathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y
|
||||||
{
|
{
|
||||||
[self arcTo:path rx:rx ry:ry rotation:rotation outer:outer clockwise:clockwise x:x + _penX y:y + _penY];
|
[self arcTo:path rx:rx ry:ry rotation:rotation outer:outer clockwise:clockwise x:x + _penX y:y + _penY];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)arcTo:(CGPathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y
|
- (void)arcTo:(CGMutablePathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y
|
||||||
{
|
{
|
||||||
float tX = _penX;
|
float tX = _penX;
|
||||||
float tY = _penY;
|
float tY = _penY;
|
||||||
@@ -332,7 +330,7 @@
|
|||||||
[self arcToBezier:path cx:cx cy:cy rx:rx ry:ry sa:sa ea:ea clockwise:clockwise rad:rad];
|
[self arcToBezier:path cx:cx cy:cy rx:rx ry:ry sa:sa ea:ea clockwise:clockwise rad:rad];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)arcToBezier:(CGPathRef)path cx:(float)cx cy:(float)cy rx:(float)rx ry:(float)ry sa:(float)sa ea:(float)ea clockwise:(BOOL)clockwise rad:(float)rad
|
- (void)arcToBezier:(CGMutablePathRef)path cx:(float)cx cy:(float)cy rx:(float)rx ry:(float)ry sa:(float)sa ea:(float)ea clockwise:(BOOL)clockwise rad:(float)rad
|
||||||
{
|
{
|
||||||
// Inverse Rotation + Scale Transform
|
// Inverse Rotation + Scale Transform
|
||||||
float cosed = cosf(rad);
|
float cosed = cosf(rad);
|
||||||
@@ -350,7 +348,7 @@
|
|||||||
arc -= M_PI * 2;
|
arc -= M_PI * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = ceilf(fabsf(arc / (M_PI / 2)));
|
int n = ceilf(fabsf(arc / ((float)M_PI / 2)));
|
||||||
|
|
||||||
float step = arc / n;
|
float step = arc / n;
|
||||||
float k = (4.0f / 3.0f) * tanf(step / 4);
|
float k = (4.0f / 3.0f) * tanf(step / 4);
|
||||||
@@ -380,7 +378,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)close:(CGPathRef)path
|
- (void)close:(CGMutablePathRef)path
|
||||||
{
|
{
|
||||||
if (_penDownSet) {
|
if (_penDownSet) {
|
||||||
_penX = _penDownX;
|
_penX = _penDownX;
|
||||||
|
|||||||
Reference in New Issue
Block a user