mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-30 05:31:01 +00:00
[ios] Implement vectorEffect nonScalingStroke / non-scaling-stroke
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,6 +20,7 @@ const vectorEffects = {
|
||||
nonScalingStroke: 1,
|
||||
'non-scaling-stroke': 1,
|
||||
inherit: 2,
|
||||
uri: 3
|
||||
};
|
||||
|
||||
export default function extractStroke(props, styleProperties) {
|
||||
|
||||
Reference in New Issue
Block a user