mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-20 05:55:10 +00:00
native prop trans => matrix
This commit is contained in:
@@ -135,10 +135,10 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
|||||||
markUpdated();
|
markUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactProp(name = "trans")
|
@ReactProp(name = "matrix")
|
||||||
public void setTrans(@Nullable ReadableArray transformArray) {
|
public void setMatrix(@Nullable ReadableArray matrixArray) {
|
||||||
if (transformArray != null) {
|
if (matrixArray != null) {
|
||||||
int matrixSize = PropHelper.toFloatArray(transformArray, sMatrixData);
|
int matrixSize = PropHelper.toFloatArray(matrixArray, sMatrixData);
|
||||||
if (matrixSize == 6) {
|
if (matrixSize == 6) {
|
||||||
setupMatrix();
|
setupMatrix();
|
||||||
} else if (matrixSize != -1) {
|
} else if (matrixSize != -1) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Image extends Shape {
|
|||||||
let {props} = this;
|
let {props} = this;
|
||||||
return <RNSVGImage
|
return <RNSVGImage
|
||||||
ref={ele => {this.root = ele;}}
|
ref={ele => {this.root = ele;}}
|
||||||
{...this.extractProps(props, {responder: true})}
|
{...this.extractProps({...props, x: null, y: null}, {responder: true, transform: true})}
|
||||||
x={props.x.toString()}
|
x={props.x.toString()}
|
||||||
y={props.y.toString()}
|
y={props.y.toString()}
|
||||||
width={props.width.toString()}
|
width={props.width.toString()}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
{
|
{
|
||||||
CGMutablePathRef path = CGPathCreateMutable();
|
CGMutablePathRef path = CGPathCreateMutable();
|
||||||
for (RNSVGNode *node in self.subviews) {
|
for (RNSVGNode *node in self.subviews) {
|
||||||
CGAffineTransform transform = node.transform;
|
CGAffineTransform transform = node.matrix;
|
||||||
CGPathAddPath(path, &transform, [node getPath:context]);
|
CGPathAddPath(path, &transform, [node getPath:context]);
|
||||||
}
|
}
|
||||||
return (CGPathRef)CFAutorelease(path);
|
return (CGPathRef)CFAutorelease(path);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
@property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path
|
@property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path
|
||||||
@property (nonatomic, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath
|
@property (nonatomic, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath
|
||||||
@property (nonatomic, assign) BOOL responsible;
|
@property (nonatomic, assign) BOOL responsible;
|
||||||
@property (nonatomic, assign) CGAffineTransform trans;
|
@property (nonatomic, assign) CGAffineTransform matrix;
|
||||||
|
|
||||||
- (void)invalidate;
|
- (void)invalidate;
|
||||||
|
|
||||||
|
|||||||
@@ -63,21 +63,16 @@
|
|||||||
} else if (opacity > 1) {
|
} else if (opacity > 1) {
|
||||||
opacity = 1;
|
opacity = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
_transparent = opacity < 1;
|
_transparent = opacity < 1;
|
||||||
_opacity = opacity;
|
_opacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTrans:(CGAffineTransform)trans
|
- (void)setMatrix:(CGAffineTransform)matrix
|
||||||
{
|
|
||||||
self.transform = trans;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setTransform:(CGAffineTransform)transform
|
|
||||||
{
|
{
|
||||||
|
_matrix = matrix;
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
super.transform = transform;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)beginTransparencyLayer:(CGContextRef)context
|
- (void)beginTransparencyLayer:(CGContextRef)context
|
||||||
@@ -97,17 +92,17 @@
|
|||||||
- (void)renderTo:(CGContextRef)context
|
- (void)renderTo:(CGContextRef)context
|
||||||
{
|
{
|
||||||
float opacity = self.opacity;
|
float opacity = self.opacity;
|
||||||
|
|
||||||
// This needs to be painted on a layer before being composited.
|
// This needs to be painted on a layer before being composited.
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
CGContextConcatCTM(context, self.transform);
|
CGContextConcatCTM(context, self.matrix);
|
||||||
CGContextSetAlpha(context, opacity);
|
CGContextSetAlpha(context, opacity);
|
||||||
|
|
||||||
[self beginTransparencyLayer:context];
|
[self beginTransparencyLayer:context];
|
||||||
[self renderClip:context];
|
[self renderClip:context];
|
||||||
[self renderLayerTo:context];
|
[self renderLayerTo:context];
|
||||||
[self endTransparencyLayer:context];
|
[self endTransparencyLayer:context];
|
||||||
|
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +170,7 @@
|
|||||||
while (parent && [parent class] != [RNSVGSvgView class]) {
|
while (parent && [parent class] != [RNSVGSvgView class]) {
|
||||||
parent = parent.superview;
|
parent = parent.superview;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (RNSVGSvgView *)parent;
|
return (RNSVGSvgView *)parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
// 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.matrix);
|
||||||
CGContextSetAlpha(context, self.opacity);
|
CGContextSetAlpha(context, self.opacity);
|
||||||
[self renderClip:context];
|
[self renderClip:context];
|
||||||
[self renderLayerTo:context];
|
[self renderLayerTo:context];
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(name, NSString)
|
RCT_EXPORT_VIEW_PROPERTY(name, NSString)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
|
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(trans, CGAffineTransform)
|
RCT_EXPORT_VIEW_PROPERTY(matrix, CGAffineTransform)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(clipPathRef, NSString)
|
RCT_EXPORT_VIEW_PROPERTY(clipPathRef, NSString)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath)
|
RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule)
|
RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const ViewBoxAttributes = {
|
|||||||
|
|
||||||
const NodeAttributes = {
|
const NodeAttributes = {
|
||||||
name: true,
|
name: true,
|
||||||
trans: {
|
matrix: {
|
||||||
diff: arrayDiffer
|
diff: arrayDiffer
|
||||||
},
|
},
|
||||||
opacity: true,
|
opacity: true,
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ export default function(props, options = {stroke: true, transform: true, fill: t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.transform) {
|
if (options.transform) {
|
||||||
extractedProps.trans = extractTransform(props);
|
extractedProps.matrix = extractTransform(props);
|
||||||
} else if (props.transform) {
|
} else if (props.transform) {
|
||||||
extractedProps.trans = extractTransform(props.transform);
|
extractedProps.matrix = extractTransform(props.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.responder) {
|
if (options.responder) {
|
||||||
|
|||||||
Reference in New Issue
Block a user