[ios] Implement vectorEffect nonScalingStroke / non-scaling-stroke

This commit is contained in:
Mikael Sand
2019-02-27 22:08:10 +02:00
parent ffb04c8414
commit 1b050834d5
4 changed files with 19 additions and 0 deletions
+2
View File
@@ -12,6 +12,7 @@
#import "RNSVGCGFCRule.h"
#import "RNSVGNode.h"
#import "RNSVGLength.h"
#import "RNSVGVectorEffect.h"
#import "RNSVGPercentageConverter.h"
@interface RNSVGRenderable : RNSVGNode
@@ -27,6 +28,7 @@
@property (nonatomic, assign) CGFloat strokeMiterlimit;
@property (nonatomic, strong) NSArray<RNSVGLength *> *strokeDasharray;
@property (nonatomic, assign) CGFloat strokeDashoffset;
@property (nonatomic, assign) RNSVGVectorEffect vectorEffect;
@property (nonatomic, copy) NSArray<NSString *> *propList;
- (void)setHitArea:(CGPathRef)path;
+15
View File
@@ -10,6 +10,7 @@
#import "RNSVGClipPath.h"
#import "RNSVGMask.h"
#import "RNSVGViewBox.h"
#import "RNSVGVectorEffect.h"
@implementation RNSVGRenderable
{
@@ -143,6 +144,15 @@
_strokeDashoffset = strokeDashoffset;
}
- (void)setVectorEffect:(RNSVGVectorEffect)vectorEffect
{
if (vectorEffect == _vectorEffect) {
return;
}
[self invalidate];
_vectorEffect = vectorEffect;
}
- (void)setPropList:(NSArray<NSString *> *)propList
{
if (propList == _propList) {
@@ -305,6 +315,11 @@ UInt32 saturate(CGFloat value) {
self.clientRect = clientRect;
if (_vectorEffect == kRNSVGVectorEffectNonScalingStroke) {
path = CGPathCreateCopyByTransformingPath(path, &svgToClientTransform);
CGContextConcatCTM(context, CGAffineTransformInvert(svgToClientTransform));
}
CGAffineTransform vbmatrix = self.svgView.getViewBoxTransform;
CGAffineTransform transform = CGAffineTransformConcat(self.matrix, self.transforms);
CGAffineTransform matrix = CGAffineTransformConcat(transform, vbmatrix);
@@ -31,6 +31,7 @@ RCT_EXPORT_VIEW_PROPERTY(strokeLinejoin, CGLineJoin)
RCT_EXPORT_VIEW_PROPERTY(strokeDasharray, NSArray<RNSVGLength *>)
RCT_EXPORT_VIEW_PROPERTY(strokeDashoffset, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(strokeMiterlimit, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(vectorEffect, int)
RCT_EXPORT_VIEW_PROPERTY(propList, NSArray<NSString *>)
@end
+1
View File
@@ -20,6 +20,7 @@ const vectorEffects = {
nonScalingStroke: 1,
'non-scaling-stroke': 1,
inherit: 2,
uri: 3
};
export default function extractStroke(props, styleProperties) {