mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-19 13:35:11 +00:00
restore clip after clip
This commit is contained in:
@@ -36,6 +36,12 @@ class ClipPathAttr extends Component{
|
|||||||
/>
|
/>
|
||||||
</RadialGradient>
|
</RadialGradient>
|
||||||
</Defs>
|
</Defs>
|
||||||
|
<Circle
|
||||||
|
cx="50"
|
||||||
|
cy="50"
|
||||||
|
r="30"
|
||||||
|
fill="red"
|
||||||
|
/>
|
||||||
<Rect
|
<Rect
|
||||||
x="0"
|
x="0"
|
||||||
y="0"
|
y="0"
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ public class RNSVGGroupShadowNode extends RNSVGVirtualNode {
|
|||||||
if (opacity > MIN_OPACITY_FOR_DRAW) {
|
if (opacity > MIN_OPACITY_FOR_DRAW) {
|
||||||
saveAndSetupCanvas(canvas);
|
saveAndSetupCanvas(canvas);
|
||||||
|
|
||||||
if (mClipPath != null) {
|
clip(canvas, paint);
|
||||||
canvas.clipPath(mClipPath, Region.Op.REPLACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
for (int i = 0; i < getChildCount(); i++) {
|
||||||
RNSVGVirtualNode child = (RNSVGVirtualNode) getChildAt(i);
|
RNSVGVirtualNode child = (RNSVGVirtualNode) getChildAt(i);
|
||||||
|
|||||||
@@ -130,10 +130,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
|||||||
"Paths should have a valid path (d) prop");
|
"Paths should have a valid path (d) prop");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mClipPath != null) {
|
clip(canvas, paint);
|
||||||
canvas.clipPath(mClipPath, Region.Op.REPLACE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setupFillPaint(paint, opacity)) {
|
if (setupFillPaint(paint, opacity)) {
|
||||||
canvas.drawPath(mPath, paint);
|
canvas.drawPath(mPath, paint);
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public class RNSVGTextShadowNode extends RNSVGPathShadowNode {
|
|||||||
|
|
||||||
// only set up the canvas if we have something to draw
|
// only set up the canvas if we have something to draw
|
||||||
saveAndSetupCanvas(canvas);
|
saveAndSetupCanvas(canvas);
|
||||||
|
clip(canvas, paint);
|
||||||
|
|
||||||
String[] lines = new String[linesProp.size()];
|
String[] lines = new String[linesProp.size()];
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
lines[i] = linesProp.getString(i);
|
lines[i] = linesProp.getString(i);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import android.graphics.Matrix;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Region;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||||
@@ -206,4 +207,11 @@ public abstract class RNSVGVirtualNode extends ReactShadowNode {
|
|||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void clip(Canvas canvas, Paint paint) {
|
||||||
|
if (mClipPath != null) {
|
||||||
|
canvas.clipPath(mClipPath, Region.Op.REPLACE);
|
||||||
|
canvas.saveLayer(0f, 0f, 0f, 0f, paint, Canvas.CLIP_SAVE_FLAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user