Skip to content

Radial gradient: length colour stops are measured against max(radiusX, radiusY), so on a tall ellipse they land short #59968

Open

Description

@YevheniiKotyrlo

Description

A radial gradient's length colour stop lands nearer the centre than CSS puts it whenever the ellipse is taller than it is wide. CSS Images 4 places colour stops along the gradient ray, which runs from the centre to the right and ends at the ending shape, so a length stop is measured along the horizontal radius (radial gradient syntax). React Native resolves length stops against max(radiusX, radiusY) on both platforms (RadialGradient.kt L247, RCTRadialGradient.mm L177-L178), then draws them over an ellipse whose horizontal radius is radiusX.

For radial-gradient(ellipse 50px 150px at center, red 40px, blue 40px), CSS turns red to blue 40px right of the centre and 120px below it. React Native turns it at 40 / 150 of the ellipse: 13.3px right and 40px below. An ellipse whose horizontal radius is the larger one draws as CSS does.

Steps to reproduce

  1. git clone https://github.com/YevheniiKotyrlo/rn-radial-gradient-length-stops && cd rn-radial-gradient-length-stops. ReproducerApp/App.tsx centres one 100 × 300 box on a white screen with backgroundImage: 'radial-gradient(ellipse 50px 150px at center, red 40px, blue 40px)'.
  2. Android, with a device on adb: ./reproduce-android.sh. iOS, on a Mac with a device connected: DEVELOPMENT_TEAM=<your team> ./reproduce-ios.sh <device identifier>. Each builds the app in Release, installs and launches it, takes a screenshot, and runs node measure.mjs screenshot.png, which finds the box by its red and blue pixels and measures where the red turns blue, rightwards and downwards from the box's centre, in the box's own units.

Expected: the red ellipse reaches 40 right of the centre and 120 below it, as in a browser; the script then exits 0. Stops given as percentages, and length stops on an ellipse that is wider than tall, keep where they are.

Actual: on both platforms the red ellipse reaches about 13 right of the centre and 40 below it, and the script exits 1. On a Galaxy S23 (Android 14):

red turns blue rightwards at 13.3; CSS puts the 40px stop at 40, max(radiusX, radiusY) at 13.3
red turns blue downwards at 40.0; CSS puts the 40px stop at 120, max(radiusX, radiusY) at 40.0
SUMMARY: the 40px stop lands at 13.3 rightwards and 40.0 downwards, as 40 / max(50, 150) of the radii puts it, where CSS puts it at 40 and 120

On an iPad Pro (12.9-inch, 4th generation):

red turns blue rightwards at 13.5; CSS puts the 40px stop at 40, max(radiusX, radiusY) at 13.3
red turns blue downwards at 40.0; CSS puts the 40px stop at 120, max(radiusX, radiusY) at 40.0
SUMMARY: the 40px stop lands at 13.5 rightwards and 40.0 downwards, as 40 / max(50, 150) of the radii puts it, where CSS puts it at 40 and 120

React Native Version

0.90.0-nightly-20261111-1273ca128

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx @react-native-community/cli info

System:
  OS: Windows 11 10.0.26300
  CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor          "
  Memory: 57.85 GB / 255.67 GB
Binaries:
  Node:
    version: 26.12.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 12.2.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.26100.0
IDEs:
  Android Studio: AI-262.9437.185.2621.16467767
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
    path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 21.0.0-alpha.1
    wanted: 21.0.0-alpha.1
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.90.0-nightly-20261111-1273ca128
    wanted: 0.90.0-nightly-20261111-1273ca128
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

MINGW64_NT-10.0-26300 x86_64, node v26.12.1, device SM-S911B on Android 14
react-native 0.90.0-nightly-20261111-1273ca128
radial-gradient(ellipse 50px 150px at center, red 40px, blue 40px)
== ./gradlew assembleRelease -PreactNativeArchitectures=arm64-v8a
BUILD SUCCESSFUL in 2m 32s
== adb install, launch com.reproducerapp, screenshot
screenshot: screenshot.png
screenshot 1080x2340; the box at x 390-689, y 720-1619: 100 x 300, 3 pixels a unit
the box's centre: #ff0000
red turns blue rightwards at 13.3; CSS puts the 40px stop at 40, max(radiusX, radiusY) at 13.3
red turns blue downwards at 40.0; CSS puts the 40px stop at 120, max(radiusX, radiusY) at 40.0
SUMMARY: the 40px stop lands at 13.3 rightwards and 40.0 downwards, as 40 / max(50, 150) of the radii puts it, where CSS puts it at 40 and 120

# ./reproduce-ios.sh on the iPad Pro
macOS 27.2; Xcode 27.2 Build version 27B52 ; node v26.12.1; pod 1.17.0; device iPad Pro (12.9-inch) (4th generation) (iPad8,11)
$ yarn install --frozen-lockfile
react-native 0.90.0-nightly-20261111-1273ca128
radial-gradient(ellipse 50px 150px at center, red 40px, blue 40px)
$ pod install
$ xcodebuild -workspace ReproducerApp.xcworkspace -scheme ReproducerApp -configuration Release -destination id=<device identifier> build
** BUILD SUCCEEDED **
screenshot: screenshot.png
screenshot 2048x2732; the box at x 924-1123, y 1066-1665: 100 x 300, 2 pixels a unit
the box's centre: #ea3323
red turns blue rightwards at 13.5; CSS puts the 40px stop at 40, max(radiusX, radiusY) at 13.3
red turns blue downwards at 40.0; CSS puts the 40px stop at 120, max(radiusX, radiusY) at 40.0
SUMMARY: the 40px stop lands at 13.5 rightwards and 40.0 downwards, as 40 / max(50, 150) of the radii puts it, where CSS puts it at 40 and 120

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/rn-radial-gradient-length-stops

Screenshots and Videos

Galaxy S23 iPad Pro

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions