mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-19 13:35:11 +00:00
change copy right and add clip for ios
This commit is contained in:
@@ -12,6 +12,7 @@ import * as Stroking from './examples/Stroking';
|
|||||||
import * as Use from './examples/Use';
|
import * as Use from './examples/Use';
|
||||||
import * as Symbol from './examples/Symbol';
|
import * as Symbol from './examples/Symbol';
|
||||||
import * as Gradients from './examples/Gradients';
|
import * as Gradients from './examples/Gradients';
|
||||||
|
import * as Clipping from './examples/Clipping';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Svg,
|
Svg,
|
||||||
@@ -27,5 +28,6 @@ export {
|
|||||||
G,
|
G,
|
||||||
Use,
|
Use,
|
||||||
Symbol,
|
Symbol,
|
||||||
Gradients
|
Gradients,
|
||||||
|
Clipping
|
||||||
};
|
};
|
||||||
|
|||||||
124
Example/examples/Clipping.js
Normal file
124
Example/examples/Clipping.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
import React, {
|
||||||
|
Component
|
||||||
|
} from 'react-native';
|
||||||
|
|
||||||
|
import Svg, {
|
||||||
|
GlipPath,
|
||||||
|
Defs,
|
||||||
|
Line,
|
||||||
|
Rect,
|
||||||
|
Text,
|
||||||
|
G
|
||||||
|
} from 'react-native-art-svg';
|
||||||
|
|
||||||
|
class ClipPathExample extends Component{
|
||||||
|
static title = 'Clip by set clip-path with a path data';
|
||||||
|
render() {
|
||||||
|
return <Svg
|
||||||
|
height="100"
|
||||||
|
width="100"
|
||||||
|
>
|
||||||
|
<Rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
width="100"
|
||||||
|
height="100"
|
||||||
|
fill="red"
|
||||||
|
clipPath="M50,5L20,99L95,39L5,39L80,99z"
|
||||||
|
/>
|
||||||
|
</Svg>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ClipRulePathExample extends Component{
|
||||||
|
static title = 'Clip by set clip-path with a path data';
|
||||||
|
render() {
|
||||||
|
return <Svg
|
||||||
|
height="100"
|
||||||
|
width="100"
|
||||||
|
>
|
||||||
|
<G
|
||||||
|
clipPath="M50,5L20,99L95,39L5,39L80,99z"
|
||||||
|
clipRule="evenodd"
|
||||||
|
>
|
||||||
|
<Rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="red"
|
||||||
|
/>
|
||||||
|
<Rect
|
||||||
|
x="50"
|
||||||
|
y="0"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="blue"
|
||||||
|
/>
|
||||||
|
<Rect
|
||||||
|
x="0"
|
||||||
|
y="50"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="yellow"
|
||||||
|
/>
|
||||||
|
<Rect
|
||||||
|
x="50"
|
||||||
|
y="50"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="green"
|
||||||
|
/>
|
||||||
|
</G>
|
||||||
|
</Svg>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const icon = <Svg
|
||||||
|
height="20"
|
||||||
|
width="20"
|
||||||
|
>
|
||||||
|
<G
|
||||||
|
clipPath="M50,5L20,99L95,39L5,39L80,99z"
|
||||||
|
clipRule="evenodd"
|
||||||
|
scale="0.2"
|
||||||
|
>
|
||||||
|
<G>
|
||||||
|
<Rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="red"
|
||||||
|
/>
|
||||||
|
<Rect
|
||||||
|
x="50"
|
||||||
|
y="0"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="blue"
|
||||||
|
/>
|
||||||
|
<Rect
|
||||||
|
x="0"
|
||||||
|
y="50"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="yellow"
|
||||||
|
/>
|
||||||
|
<Rect
|
||||||
|
x="50"
|
||||||
|
y="50"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
fill="green"
|
||||||
|
/>
|
||||||
|
</G>
|
||||||
|
</G>
|
||||||
|
</Svg>;
|
||||||
|
|
||||||
|
const samples = [ClipPathExample, ClipRulePathExample];
|
||||||
|
|
||||||
|
export {
|
||||||
|
icon,
|
||||||
|
samples
|
||||||
|
}
|
||||||
@@ -36,7 +36,9 @@
|
|||||||
/**
|
/**
|
||||||
* OPTION 2
|
* OPTION 2
|
||||||
* Load from pre-bundled file on disk. The static bundle is automatically
|
* Load from pre-bundled file on disk. The static bundle is automatically
|
||||||
* generated by "Bundle React Native code and images" build step.
|
* generated by the "Bundle React Native code and images" build step when
|
||||||
|
* running the project on an actual device or running the project on the
|
||||||
|
* simulator in the "Release" build configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
||||||
|
|||||||
@@ -24,19 +24,21 @@ import {
|
|||||||
} from 'react-native-art-svg';
|
} from 'react-native-art-svg';
|
||||||
import * as examples from './examples';
|
import * as examples from './examples';
|
||||||
import Modal from 'react-native-root-modal';
|
import Modal from 'react-native-root-modal';
|
||||||
const hairline = 1 / PixelRatio.get();
|
const hairline = StyleSheet.hairlineWidth;
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: '#F5FCFF',
|
|
||||||
paddingTop: 20,
|
paddingTop: 20,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
overflow: 'hidden'
|
overflow: 'hidden'
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
|
flex: 1,
|
||||||
|
alignSelf: 'stretch'
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
alignSelf: 'stretch',
|
alignSelf: 'stretch',
|
||||||
alignItems: 'center',
|
|
||||||
borderTopWidth: hairline,
|
borderTopWidth: hairline,
|
||||||
borderTopColor: '#ccc',
|
borderTopColor: '#ccc',
|
||||||
borderBottomWidth: hairline,
|
borderBottomWidth: hairline,
|
||||||
@@ -104,7 +106,7 @@ const styles = StyleSheet.create({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const names = ['Svg', 'Stroking', 'Path', 'Line', 'Rect', 'Polygon', 'Polyline', 'Circle', 'Ellipse', 'G', 'Text', 'Use', 'Symbol', 'Gradients'];
|
const names = ['Svg', 'Stroking', 'Path', 'Line', 'Rect', 'Polygon', 'Polyline', 'Circle', 'Ellipse', 'G', 'Text', 'Use', 'Symbol', 'Gradients', 'Clipping'];
|
||||||
|
|
||||||
class ArtSvgExample extends Component {
|
class ArtSvgExample extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -184,7 +186,9 @@ class ArtSvgExample extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <View style={styles.container}>
|
return <View
|
||||||
|
style={styles.container}
|
||||||
|
>
|
||||||
<Animated.Modal
|
<Animated.Modal
|
||||||
visible={this.state.modal}
|
visible={this.state.modal}
|
||||||
style={[styles.modal, {
|
style={[styles.modal, {
|
||||||
@@ -237,9 +241,12 @@ class ArtSvgExample extends Component {
|
|||||||
<Text style={styles.welcome}>
|
<Text style={styles.welcome}>
|
||||||
SVG by ART!
|
SVG by ART!
|
||||||
</Text>
|
</Text>
|
||||||
<View style={styles.content}>
|
<ScrollView
|
||||||
|
style={styles.content}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
{this.getExamples()}
|
{this.getExamples()}
|
||||||
</View>
|
</ScrollView>
|
||||||
</View>;
|
</View>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,6 +253,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
|||||||
stops = new float[stopsCount];
|
stops = new float[stopsCount];
|
||||||
parseGradientStops(mFillColor, stopsCount, stops, stopsColors, 7);
|
parseGradientStops(mFillColor, stopsCount, stops, stopsColors, 7);
|
||||||
|
|
||||||
|
// TODO:
|
||||||
float focusX = mFillColor[1];
|
float focusX = mFillColor[1];
|
||||||
float focusY = mFillColor[2];
|
float focusY = mFillColor[2];
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGBrush.h"
|
#import "RNSVGBrush.h"
|
||||||
@@ -15,19 +14,19 @@
|
|||||||
|
|
||||||
- (instancetype)initWithArray:(NSArray *)data
|
- (instancetype)initWithArray:(NSArray *)data
|
||||||
{
|
{
|
||||||
return [super init];
|
return [super init];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||||
|
|
||||||
- (BOOL)applyFillColor:(CGContextRef)context
|
- (BOOL)applyFillColor:(CGContextRef)context
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)paint:(CGContextRef)context
|
- (void)paint:(CGContextRef)context
|
||||||
{
|
{
|
||||||
// abstract
|
// abstract
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGBrush.h"
|
#import "RNSVGBrush.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGLinearGradient.h"
|
#import "RNSVGLinearGradient.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGBrush.h"
|
#import "RNSVGBrush.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGPattern.h"
|
#import "RNSVGPattern.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGBrush.h"
|
#import "RNSVGBrush.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGRadialGradient.h"
|
#import "RNSVGRadialGradient.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGBrush.h"
|
#import "RNSVGBrush.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGSolidColor.h"
|
#import "RNSVGSolidColor.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <QuartzCore/QuartzCore.h>
|
#import <QuartzCore/QuartzCore.h>
|
||||||
@@ -13,13 +12,13 @@
|
|||||||
#import "RNSVGCGFloatArray.h"
|
#import "RNSVGCGFloatArray.h"
|
||||||
#import "RNSVGTextFrame.h"
|
#import "RNSVGTextFrame.h"
|
||||||
#import "RCTConvert.h"
|
#import "RCTConvert.h"
|
||||||
#import "RNSVGCGFillRule.h"
|
#import "RNSVGCGFCRule.h"
|
||||||
|
|
||||||
@interface RCTConvert (RNSVG)
|
@interface RCTConvert (RNSVG)
|
||||||
|
|
||||||
+ (CGPathRef)CGPath:(id)json;
|
+ (CGPathRef)CGPath:(id)json;
|
||||||
+ (CTTextAlignment)CTTextAlignment:(id)json;
|
+ (CTTextAlignment)CTTextAlignment:(id)json;
|
||||||
+ (RNSVGCGFillRule)ARTCGFillRule:(id)json;
|
+ (RNSVGCGFCRule)RNSVGCGFCRule:(id)json;
|
||||||
+ (RNSVGTextFrame)RNSVGTextFrame:(id)json;
|
+ (RNSVGTextFrame)RNSVGTextFrame:(id)json;
|
||||||
+ (RNSVGCGFloatArray)RNSVGCGFloatArray:(id)json;
|
+ (RNSVGCGFloatArray)RNSVGCGFloatArray:(id)json;
|
||||||
+ (RNSVGBrush *)RNSVGBrush:(id)json;
|
+ (RNSVGBrush *)RNSVGBrush:(id)json;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RCTConvert+RNSVG.h"
|
#import "RCTConvert+RNSVG.h"
|
||||||
@@ -14,7 +13,7 @@
|
|||||||
#import "RNSVGRadialGradient.h"
|
#import "RNSVGRadialGradient.h"
|
||||||
#import "RNSVGSolidColor.h"
|
#import "RNSVGSolidColor.h"
|
||||||
#import "RCTLog.h"
|
#import "RCTLog.h"
|
||||||
#import "RNSVGCGFillRule.h"
|
#import "RNSVGCGFCRule.h"
|
||||||
|
|
||||||
@implementation RCTConvert (RNSVG)
|
@implementation RCTConvert (RNSVG)
|
||||||
|
|
||||||
@@ -73,10 +72,10 @@ RCT_ENUM_CONVERTER(CTTextAlignment, (@{
|
|||||||
@"justify": @(kCTTextAlignmentJustified),
|
@"justify": @(kCTTextAlignmentJustified),
|
||||||
}), kCTTextAlignmentNatural, integerValue)
|
}), kCTTextAlignmentNatural, integerValue)
|
||||||
|
|
||||||
RCT_ENUM_CONVERTER(RNSVGCGFillRule, (@{
|
RCT_ENUM_CONVERTER(RNSVGCGFCRule, (@{
|
||||||
@"evenodd": @(kARTCGFillRuleEvenodd),
|
@"evenodd": @(kRNSVGCGFCRuleEvenodd),
|
||||||
@"nonzero": @(kARTCGFillRuleNonzero),
|
@"nonzero": @(kRNSVGCGFCRuleNonzero),
|
||||||
}), kARTCGFillRuleEvenodd, intValue)
|
}), kRNSVGCGFCRuleNonzero, intValue)
|
||||||
|
|
||||||
// This takes a tuple of text lines and a font to generate a CTLine for each text line.
|
// This takes a tuple of text lines and a font to generate a CTLine for each text line.
|
||||||
// This prepares everything for rendering a frame of text in RNSVGText.
|
// This prepares everything for rendering a frame of text in RNSVGText.
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
10A063011CC7320C0000CEEF /* RNSVGPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGPath.m; sourceTree = "<group>"; };
|
10A063011CC7320C0000CEEF /* RNSVGPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGPath.m; sourceTree = "<group>"; };
|
||||||
10A063021CC7320C0000CEEF /* RNSVGSvgView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGSvgView.h; sourceTree = "<group>"; };
|
10A063021CC7320C0000CEEF /* RNSVGSvgView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGSvgView.h; sourceTree = "<group>"; };
|
||||||
10A063031CC7320C0000CEEF /* RNSVGSvgView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGSvgView.m; sourceTree = "<group>"; };
|
10A063031CC7320C0000CEEF /* RNSVGSvgView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGSvgView.m; sourceTree = "<group>"; };
|
||||||
10FEAC6A1CC7D05200F1C23C /* RNSVGCGFillRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGCGFillRule.h; sourceTree = "<group>"; };
|
10FEAC6A1CC7D05200F1C23C /* RNSVGCGFCRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGCGFCRule.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
0CF68AEA1AF0549300FF9E5C /* Brushes */,
|
0CF68AEA1AF0549300FF9E5C /* Brushes */,
|
||||||
0CF68AF81AF0549300FF9E5C /* ViewManagers */,
|
0CF68AF81AF0549300FF9E5C /* ViewManagers */,
|
||||||
0CF68ADB1AF0549300FF9E5C /* RNSVGCGFloatArray.h */,
|
0CF68ADB1AF0549300FF9E5C /* RNSVGCGFloatArray.h */,
|
||||||
10FEAC6A1CC7D05200F1C23C /* RNSVGCGFillRule.h */,
|
10FEAC6A1CC7D05200F1C23C /* RNSVGCGFCRule.h */,
|
||||||
0CF68ADC1AF0549300FF9E5C /* RNSVGContainer.h */,
|
0CF68ADC1AF0549300FF9E5C /* RNSVGContainer.h */,
|
||||||
0CF68ADD1AF0549300FF9E5C /* RNSVGGroup.h */,
|
0CF68ADD1AF0549300FF9E5C /* RNSVGGroup.h */,
|
||||||
0CF68ADE1AF0549300FF9E5C /* RNSVGGroup.m */,
|
0CF68ADE1AF0549300FF9E5C /* RNSVGGroup.m */,
|
||||||
|
|||||||
12
ios/RNSVGCGFCRule.h
Normal file
12
ios/RNSVGCGFCRule.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef CF_ENUM(int32_t, RNSVGCGFCRule) {
|
||||||
|
kRNSVGCGFCRuleEvenodd,
|
||||||
|
kRNSVGCGFCRuleNonzero
|
||||||
|
};
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef CF_ENUM(int32_t, RNSVGCGFillRule) {
|
|
||||||
kARTCGFillRuleEvenodd,
|
|
||||||
kARTCGFillRuleNonzero
|
|
||||||
};
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// A little helper to make sure we have the right memory allocation ready for use.
|
// A little helper to make sure we have the right memory allocation ready for use.
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "RNSVGContainer.h"
|
#import "RNSVGContainer.h"
|
||||||
#import "RNSVGNode.h"
|
#import "RNSVGNode.h"
|
||||||
|
#import "RNSVGCGFCRule.h"
|
||||||
|
|
||||||
@interface RNSVGGroup : RNSVGNode <RNSVGContainer>
|
@interface RNSVGGroup : RNSVGNode <RNSVGContainer>
|
||||||
|
|
||||||
|
@property (nonatomic, assign) CGPathRef clipPath;
|
||||||
|
@property (nonatomic, assign) RNSVGCGFCRule clipRule;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGGroup.h"
|
#import "RNSVGGroup.h"
|
||||||
@@ -13,10 +12,10 @@
|
|||||||
|
|
||||||
- (void)renderLayerTo:(CGContextRef)context
|
- (void)renderLayerTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
// TO-DO: Clipping rectangle
|
[self clip:context];
|
||||||
for (RNSVGNode *node in self.subviews) {
|
for (RNSVGNode *node in self.subviews) {
|
||||||
[node renderTo:context];
|
[node renderTo:context];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "RNSVGCGFCRule.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RNSVG nodes are implemented as empty UIViews but this is just an implementation detail to fit
|
* RNSVG nodes are implemented as empty UIViews but this is just an implementation detail to fit
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
@property (nonatomic, assign) CGFloat opacity;
|
@property (nonatomic, assign) CGFloat opacity;
|
||||||
|
|
||||||
|
@property (nonatomic, assign) CGPathRef clipPath;
|
||||||
|
@property (nonatomic, assign) RNSVGCGFCRule clipRule;
|
||||||
|
|
||||||
- (void)invalidate;
|
- (void)invalidate;
|
||||||
- (void)renderTo:(CGContextRef)context;
|
- (void)renderTo:(CGContextRef)context;
|
||||||
|
|
||||||
@@ -30,4 +33,6 @@
|
|||||||
*/
|
*/
|
||||||
- (void)renderLayerTo:(CGContextRef)context;
|
- (void)renderLayerTo:(CGContextRef)context;
|
||||||
|
|
||||||
|
- (void)clip:(CGContextRef)context;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGNode.h"
|
#import "RNSVGNode.h"
|
||||||
@@ -15,62 +14,94 @@
|
|||||||
|
|
||||||
- (void)insertSubview:(UIView *)subview atIndex:(NSInteger)index
|
- (void)insertSubview:(UIView *)subview atIndex:(NSInteger)index
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
[super insertSubview:subview atIndex:index];
|
[super insertSubview:subview atIndex:index];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeFromSuperview
|
- (void)removeFromSuperview
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
[super removeFromSuperview];
|
[super removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setOpacity:(CGFloat)opacity
|
- (void)setOpacity:(CGFloat)opacity
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_opacity = opacity;
|
_opacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTransform:(CGAffineTransform)transform
|
- (void)setTransform:(CGAffineTransform)transform
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
super.transform = transform;
|
super.transform = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)invalidate
|
- (void)invalidate
|
||||||
{
|
{
|
||||||
id<RNSVGContainer> container = (id<RNSVGContainer>)self.superview;
|
id<RNSVGContainer> container = (id<RNSVGContainer>)self.superview;
|
||||||
[container invalidate];
|
[container invalidate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renderTo:(CGContextRef)context
|
- (void)renderTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
if (self.opacity <= 0) {
|
float opacity = self.opacity;
|
||||||
// Nothing to paint
|
BOOL transparent = NO;
|
||||||
return;
|
if (opacity <= 0) {
|
||||||
}
|
// Nothing to paint
|
||||||
if (self.opacity >= 1) {
|
return;
|
||||||
// Just paint at full opacity
|
}
|
||||||
|
if (opacity >= 1) {
|
||||||
|
opacity = 1;
|
||||||
|
transparent = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This needs to be painted on a layer before being composited.
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
CGContextConcatCTM(context, self.transform);
|
CGContextConcatCTM(context, self.transform);
|
||||||
CGContextSetAlpha(context, 1);
|
CGContextSetAlpha(context, opacity);
|
||||||
|
if (transparent) {
|
||||||
|
CGContextBeginTransparencyLayer(context, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
[self renderLayerTo:context];
|
[self renderLayerTo:context];
|
||||||
|
if (transparent) {
|
||||||
|
CGContextEndTransparencyLayer(context);
|
||||||
|
}
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// This needs to be painted on a layer before being composited.
|
|
||||||
CGContextSaveGState(context);
|
|
||||||
CGContextConcatCTM(context, self.transform);
|
|
||||||
CGContextSetAlpha(context, self.opacity);
|
|
||||||
CGContextBeginTransparencyLayer(context, NULL);
|
|
||||||
[self renderLayerTo:context];
|
|
||||||
CGContextEndTransparencyLayer(context);
|
|
||||||
CGContextRestoreGState(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setClipPath:(CGPathRef)clipPath
|
||||||
|
{
|
||||||
|
if (clipPath == _clipPath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self invalidate];
|
||||||
|
CGPathRelease(_clipPath);
|
||||||
|
_clipPath = CGPathRetain(clipPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
CGPathRelease(_clipPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)renderLayerTo:(CGContextRef)context
|
- (void)renderLayerTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
// abstract
|
// abstract
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)clip:(CGContextRef)context
|
||||||
|
{
|
||||||
|
if (self.clipPath) {
|
||||||
|
CGContextAddPath(context, self.clipPath);
|
||||||
|
if (self.clipRule == kRNSVGCGFCRuleEvenodd) {
|
||||||
|
CGContextEOClip(context);
|
||||||
|
} else {
|
||||||
|
CGContextClip(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGPath.h"
|
#import "RNSVGPath.h"
|
||||||
@@ -13,58 +12,60 @@
|
|||||||
|
|
||||||
- (void)setD:(CGPathRef)d
|
- (void)setD:(CGPathRef)d
|
||||||
{
|
{
|
||||||
if (d == _d) {
|
if (d == _d) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
CGPathRelease(_d);
|
CGPathRelease(_d);
|
||||||
_d = CGPathRetain(d);
|
_d = CGPathRetain(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
CGPathRelease(_d);
|
CGPathRelease(_d);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renderLayerTo:(CGContextRef)context
|
- (void)renderLayerTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
if ((!self.fill && !self.stroke) || !self.d) {
|
if ((!self.fill && !self.stroke) || !self.d) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGPathDrawingMode mode = kCGPathStroke;
|
|
||||||
if (self.fill) {
|
|
||||||
if ([self.fill applyFillColor:context]) {
|
|
||||||
mode = self.fillRule == kARTCGFillRuleEvenodd ? kCGPathEOFill : kCGPathFill;
|
|
||||||
} else {
|
|
||||||
CGContextSaveGState(context);
|
|
||||||
CGContextAddPath(context, self.d);
|
|
||||||
CGContextClip(context);
|
|
||||||
[self.fill paint:context];
|
|
||||||
CGContextRestoreGState(context);
|
|
||||||
if (!self.stroke) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (self.stroke) {
|
|
||||||
CGContextSetStrokeColorWithColor(context, self.stroke);
|
|
||||||
CGContextSetLineWidth(context, self.strokeWidth);
|
|
||||||
CGContextSetLineCap(context, self.strokeLinecap);
|
|
||||||
CGContextSetLineJoin(context, self.strokeLinejoin);
|
|
||||||
RNSVGCGFloatArray dash = self.strokeDash;
|
|
||||||
if (dash.count) {
|
|
||||||
CGContextSetLineDash(context, 0, dash.array, dash.count);
|
|
||||||
}
|
|
||||||
if (mode == kCGPathFill) {
|
|
||||||
mode = kCGPathFillStroke;
|
|
||||||
} else if (mode == kCGPathEOFill) {
|
|
||||||
mode = kCGPathEOFillStroke;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CGContextAddPath(context, self.d);
|
CGPathDrawingMode mode = kCGPathStroke;
|
||||||
CGContextDrawPath(context, mode);
|
if (self.fill) {
|
||||||
|
if ([self.fill applyFillColor:context]) {
|
||||||
|
mode = self.fillRule == kRNSVGCGFCRuleEvenodd ? kCGPathEOFill : kCGPathFill;
|
||||||
|
} else {
|
||||||
|
CGContextSaveGState(context);
|
||||||
|
CGContextAddPath(context, self.d);
|
||||||
|
CGContextClip(context);
|
||||||
|
[self.fill paint:context];
|
||||||
|
CGContextRestoreGState(context);
|
||||||
|
if (!self.stroke) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (self.stroke) {
|
||||||
|
CGContextSetStrokeColorWithColor(context, self.stroke);
|
||||||
|
CGContextSetLineWidth(context, self.strokeWidth);
|
||||||
|
CGContextSetLineCap(context, self.strokeLinecap);
|
||||||
|
CGContextSetLineJoin(context, self.strokeLinejoin);
|
||||||
|
RNSVGCGFloatArray dash = self.strokeDash;
|
||||||
|
if (dash.count) {
|
||||||
|
CGContextSetLineDash(context, 0, dash.array, dash.count);
|
||||||
|
}
|
||||||
|
if (mode == kCGPathFill) {
|
||||||
|
mode = kCGPathFillStroke;
|
||||||
|
} else if (mode == kCGPathEOFill) {
|
||||||
|
mode = kCGPathEOFillStroke;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self clip:context];
|
||||||
|
|
||||||
|
CGContextAddPath(context, self.d);
|
||||||
|
CGContextDrawPath(context, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "RNSVGBrush.h"
|
#import "RNSVGBrush.h"
|
||||||
#import "RNSVGCGFloatArray.h"
|
#import "RNSVGCGFloatArray.h"
|
||||||
#import "RNSVGCGFillRule.h"
|
#import "RNSVGCGFCRule.h"
|
||||||
#import "RNSVGNode.h"
|
#import "RNSVGNode.h"
|
||||||
|
|
||||||
@interface RNSVGRenderable : RNSVGNode
|
@interface RNSVGRenderable : RNSVGNode
|
||||||
|
|
||||||
@property (nonatomic, strong) RNSVGBrush *fill;
|
@property (nonatomic, strong) RNSVGBrush *fill;
|
||||||
@property (nonatomic, assign) RNSVGCGFillRule fillRule;
|
@property (nonatomic, assign) RNSVGCGFCRule fillRule;
|
||||||
@property (nonatomic, assign) CGColorRef stroke;
|
@property (nonatomic, assign) CGColorRef stroke;
|
||||||
@property (nonatomic, assign) CGFloat strokeWidth;
|
@property (nonatomic, assign) CGFloat strokeWidth;
|
||||||
@property (nonatomic, assign) CGLineCap strokeLinecap;
|
@property (nonatomic, assign) CGLineCap strokeLinecap;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGRenderable.h"
|
#import "RNSVGRenderable.h"
|
||||||
@@ -12,84 +11,78 @@
|
|||||||
@implementation RNSVGRenderable
|
@implementation RNSVGRenderable
|
||||||
|
|
||||||
- (void)setFill:(RNSVGBrush *)fill
|
- (void)setFill:(RNSVGBrush *)fill
|
||||||
{
|
|
||||||
[self invalidate];
|
|
||||||
_fill = fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setFillRule:(RNSVGCGFillRule)fillRule
|
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_fillRule = fillRule;
|
_fill = fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStroke:(CGColorRef)stroke
|
- (void)setStroke:(CGColorRef)stroke
|
||||||
{
|
{
|
||||||
if (stroke == _stroke) {
|
if (stroke == _stroke) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
CGColorRelease(_stroke);
|
CGColorRelease(_stroke);
|
||||||
_stroke = CGColorRetain(stroke);
|
_stroke = CGColorRetain(stroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStrokeWidth:(CGFloat)strokeWidth
|
- (void)setStrokeWidth:(CGFloat)strokeWidth
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_strokeWidth = strokeWidth;
|
_strokeWidth = strokeWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStrokeLinecap:(CGLineCap)strokeLinecap
|
- (void)setStrokeLinecap:(CGLineCap)strokeLinecap
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_strokeLinecap = strokeLinecap;
|
_strokeLinecap = strokeLinecap;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStrokeJoin:(CGLineJoin)strokeLinejoin
|
- (void)setStrokeJoin:(CGLineJoin)strokeLinejoin
|
||||||
{
|
{
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_strokeLinejoin = strokeLinejoin;
|
_strokeLinejoin = strokeLinejoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStrokeDash:(RNSVGCGFloatArray)strokeDash
|
- (void)setStrokeDash:(RNSVGCGFloatArray)strokeDash
|
||||||
{
|
{
|
||||||
if (strokeDash.array == _strokeDash.array) {
|
if (strokeDash.array == _strokeDash.array) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_strokeDash.array) {
|
if (_strokeDash.array) {
|
||||||
free(_strokeDash.array);
|
free(_strokeDash.array);
|
||||||
}
|
}
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_strokeDash = strokeDash;
|
_strokeDash = strokeDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
CGColorRelease(_stroke);
|
CGColorRelease(_stroke);
|
||||||
if (_strokeDash.array) {
|
if (_strokeDash.array) {
|
||||||
free(_strokeDash.array);
|
free(_strokeDash.array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renderTo:(CGContextRef)context
|
- (void)renderTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
if (self.opacity <= 0 || self.opacity >= 1 || (self.fill && self.stroke)) {
|
if (self.opacity <= 0 || self.opacity >= 1 || (self.fill && self.stroke)) {
|
||||||
// If we have both fill and stroke, we will need to paint this using normal compositing
|
// If we have both fill and stroke, we will need to paint this using normal compositing
|
||||||
[super renderTo: context];
|
[super renderTo: context];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// This is a terminal with only one painting. Therefore we don't need to paint this
|
// This is a terminal with only one painting. Therefore we don't need to paint this
|
||||||
// off-screen. We can just composite it straight onto the buffer.
|
// off-screen. We can just composite it straight onto the buffer.
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
CGContextConcatCTM(context, self.transform);
|
CGContextConcatCTM(context, self.transform);
|
||||||
CGContextSetAlpha(context, self.opacity);
|
CGContextSetAlpha(context, self.opacity);
|
||||||
[self renderLayerTo:context];
|
[self renderLayerTo:context];
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renderLayerTo:(CGContextRef)context
|
- (void)renderLayerTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
// abstract
|
// abstract
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGSvgView.h"
|
#import "RNSVGSvgView.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGText.h"
|
#import "RNSVGText.h"
|
||||||
@@ -54,7 +53,8 @@ static void RNSVGFreeTextFrame(RNSVGTextFrame frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to-do: draw along a path
|
// to-do: draw along a path
|
||||||
|
// to-do: fill-rule
|
||||||
|
// to-do: clip
|
||||||
CGTextDrawingMode mode = kCGTextStroke;
|
CGTextDrawingMode mode = kCGTextStroke;
|
||||||
if (self.fill) {
|
if (self.fill) {
|
||||||
if ([self.fill applyFillColor:context]) {
|
if ([self.fill applyFillColor:context]) {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <CoreText/CoreText.h>
|
#import <CoreText/CoreText.h>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGNodeManager.h"
|
#import "RNSVGNodeManager.h"
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGGroupManager.h"
|
#import "RNSVGGroupManager.h"
|
||||||
|
#import "RNSVGCGFCRule.h"
|
||||||
#import "RNSVGGroup.h"
|
#import "RNSVGGroup.h"
|
||||||
|
|
||||||
@implementation RNSVGGroupManager
|
@implementation RNSVGGroupManager
|
||||||
@@ -20,4 +19,8 @@ RCT_EXPORT_MODULE()
|
|||||||
return [RNSVGGroup new];
|
return [RNSVGGroup new];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath)
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGNode.h"
|
#import "RNSVGNode.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGNodeManager.h"
|
#import "RNSVGNodeManager.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGRenderableManager.h"
|
#import "RNSVGRenderableManager.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGPathManager.h"
|
#import "RNSVGPathManager.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGNodeManager.h"
|
#import "RNSVGNodeManager.h"
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGRenderableManager.h"
|
#import "RNSVGRenderableManager.h"
|
||||||
|
|
||||||
#import "RCTConvert+RNSVG.h"
|
#import "RCTConvert+RNSVG.h"
|
||||||
#import "RNSVGCGFillRule.h"
|
#import "RNSVGCGFCRule.h"
|
||||||
|
|
||||||
@implementation RNSVGRenderableManager
|
@implementation RNSVGRenderableManager
|
||||||
|
|
||||||
@@ -18,15 +17,17 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
- (RNSVGRenderable *)node
|
- (RNSVGRenderable *)node
|
||||||
{
|
{
|
||||||
return [RNSVGRenderable new];
|
return [RNSVGRenderable new];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(strokeWidth, CGFloat)
|
RCT_EXPORT_VIEW_PROPERTY(strokeWidth, CGFloat)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(strokeLinecap, CGLineCap)
|
RCT_EXPORT_VIEW_PROPERTY(strokeLinecap, CGLineCap)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(strokeLinejoin, CGLineJoin)
|
RCT_EXPORT_VIEW_PROPERTY(strokeLinejoin, CGLineJoin)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(fill, RNSVGBrush)
|
RCT_EXPORT_VIEW_PROPERTY(fill, RNSVGBrush)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(fillRule, RNSVGCGFillRule)
|
RCT_EXPORT_VIEW_PROPERTY(fillRule, RNSVGCGFCRule)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(stroke, CGColor)
|
RCT_EXPORT_VIEW_PROPERTY(stroke, CGColor)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(strokeDash, RNSVGCGFloatArray)
|
RCT_EXPORT_VIEW_PROPERTY(strokeDash, RNSVGCGFloatArray)
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath)
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RCTViewManager.h"
|
#import "RCTViewManager.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGSvgViewManager.h"
|
#import "RNSVGSvgViewManager.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGRenderableManager.h"
|
#import "RNSVGRenderableManager.h"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
* Copyright (c) 2015-present, Horcrux.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the MIT-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RNSVGTextManager.h"
|
#import "RNSVGTextManager.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user