diff --git a/TestsExample/src/Test2170.tsx b/TestsExample/src/Test2170.tsx
new file mode 100644
index 00000000..aaf1a1d5
--- /dev/null
+++ b/TestsExample/src/Test2170.tsx
@@ -0,0 +1,65 @@
+import * as React from 'react';
+import {View} from 'react-native';
+import {
+ Circle,
+ RadialGradient,
+ Rect,
+ Stop,
+ Svg,
+ SvgXml,
+} from 'react-native-svg';
+
+// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/r#example
+const svgXml = `
+
+`;
+
+export default function App() {
+ return (
+
+
+
+
+ );
+}
diff --git a/android/src/main/java/com/horcrux/svg/Brush.java b/android/src/main/java/com/horcrux/svg/Brush.java
index 0492cda3..dc3dc04e 100644
--- a/android/src/main/java/com/horcrux/svg/Brush.java
+++ b/android/src/main/java/com/horcrux/svg/Brush.java
@@ -204,6 +204,14 @@ class Brush {
double rx = getVal(mPoints[2], width, scale, textSize);
double ry = getVal(mPoints[3], height, scale, textSize);
+ if (rx <= 0 || ry <= 0) {
+ // Gradient with radius = 0 should be rendered as solid color of the last stop
+ rx = width;
+ ry = height;
+ stops = new float[] {stops[0], stops[stops.length - 1]};
+ stopsColors =
+ new int[] {stopsColors[stopsColors.length - 1], stopsColors[stopsColors.length - 1]};
+ }
double ratio = ry / rx;
double cx = getVal(mPoints[4], width, scale, textSize) + offsetX;
diff --git a/apple/Brushes/RNSVGPainter.mm b/apple/Brushes/RNSVGPainter.mm
index 276fa6e3..6a30528d 100644
--- a/apple/Brushes/RNSVGPainter.mm
+++ b/apple/Brushes/RNSVGPainter.mm
@@ -232,6 +232,15 @@ void PatternFunction(void *info, CGContextRef context)
CGFloat rx = [self getVal:[_points objectAtIndex:2] relative:width];
CGFloat ry = [self getVal:[_points objectAtIndex:3] relative:height];
+ if (rx <= 0 || ry <= 0) {
+ // Gradient with radius = 0 should be rendered as solid color of the last stop
+ rx = width;
+ ry = height;
+ CGGradientRelease(gradient);
+ NSArray *gradientArray = @[_colors.firstObject, _colors.lastObject, _colors[_colors.count-2], _colors.lastObject];
+ gradient = CGGradientRetain([RCTConvert RNSVGCGGradient:gradientArray]);
+ }
+
double ratio = ry / rx;
CGFloat fx = [self getVal:[_points objectAtIndex:0] relative:width] + offsetX;