react-native/packages
Nishan 221d1eceda fix: start and end points linear gradient algorithm (#47003)
Summary:
- Current implementation does not follow CSS spec for rectangle boxes with corner angles. It is using non spec compliant algorithm to calculate start and end points. This PR follows the spec compliant algorithm to implement and makes sure Web, iOS and Android gradients are identical with corner angles.
- Also, currently it is using `CAGradientLayer` which does not support spec compliant start and end points i.e. start and end point can be outside of rectangle bounds. This leads to inconsistent gradients on iOS for corner angles compared to web and android. So this PR replaces it with `CGGradient`.
- I have also moved some files to make it easier to add more background image types in future.

## Changelog:

[GENERAL] [FIXED] - Linear gradient start and end point algorithm.

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/47003

Test Plan:
- Added multiple gradient example which should be identical in all platforms (Web, iOS and Android) and tested thoroughly on all platforms. I think some visual test cases can help here.
- I have referred to [blink's](https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/core/css/css_gradient_value.cc) implementation.

## Aside

Took a while to understand the [spec](https://www.w3.org/TR/css-images-3/#corner-gradient-example), but felt great after getting it. Gradients should be 100% identical on all platforms now. Sorry i missed testing cornered angles + rectangles earlier and I found out it is inconsistent on platforms just this weekend  😅

<img width="1389" alt="Screenshot 2024-10-14 at 12 24 45 AM" src="https://github.com/user-attachments/assets/2f61eb87-502b-4b8c-88f3-d8a3cca9a7a3">

Reviewed By: joevilches

Differential Revision: D64497127

Pulled By: jorge-cab

fbshipit-source-id: 2647176ae2ee74b6c71f9061465b07dccdabcfc1
2024-11-20 17:17:52 -08:00
..
assets replace '$TEMPORARY$string<>' with 'string' (#46876) 2024-10-07 19:18:14 -07:00
babel-plugin-codegen RN: Fix lint/sort-imports Errors (#47109) 2024-10-18 04:07:02 -07:00
community-cli-plugin fix/cli start (#47450) 2024-11-06 07:26:30 -08:00
core-cli-utils Bump main to 0.77 2024-09-12 09:23:23 -07:00
debugger-frontend Update debugger-frontend from ff343d8...b61aae3 (#47593) 2024-11-13 11:27:38 -08:00
dev-middleware dev-middleware: Only rewrite hostnames if they match device connection hosts (#47685) 2024-11-20 06:56:21 -08:00
eslint-config-react-native Revert to @babel/eslint-parser in eslint-config (#47333) 2024-11-01 05:31:37 -07:00
eslint-plugin-react-native Update hermes-parser and related packages in fbsource to 0.24.0 (#46802) 2024-10-03 08:20:16 -07:00
eslint-plugin-specs Update hermes-parser and related packages in fbsource to 0.24.0 (#46802) 2024-10-03 08:20:16 -07:00
gradle-plugin RNGP - Do not attempt to substring to 1024 while logging. (#47509) 2024-11-08 04:57:15 -08:00
helloworld update targetSdk to 35 (#47738) 2024-11-20 11:06:31 -08:00
hermes-inspector-msggen Bump main to 0.77 2024-09-12 09:23:23 -07:00
metro-config metro-config: Revert setting hermesParser: true in default Metro config (#47670) 2024-11-19 02:43:03 -08:00
normalize-color Bump main to 0.77 2024-09-12 09:23:23 -07:00
polyfills Implement always available js error handling (#47466) 2024-11-07 11:22:57 -08:00
react-native fix: start and end points linear gradient algorithm (#47003) 2024-11-20 17:17:52 -08:00
react-native-babel-preset Update hermes-parser and related packages in fbsource to 0.24.0 (#46802) 2024-10-03 08:20:16 -07:00
react-native-babel-transformer Update hermes-parser and related packages in fbsource to 0.24.0 (#46802) 2024-10-03 08:20:16 -07:00
react-native-bots fix: mitigate DangerJS transpilation bug (#47192) 2024-10-24 20:07:20 -07:00
react-native-codegen Fix generated EventEmitter code for nested objects in arrays. (#47514) 2024-11-20 16:25:34 -08:00
react-native-codegen-typescript-test Bump main to 0.77 2024-09-12 09:23:23 -07:00
react-native-info Bump main to 0.77 2024-09-12 09:23:23 -07:00
react-native-popup-menu-android Convert com.facebook.react.ViewManagerOnDemandReactPackage to Kotlin (#47682) 2024-11-20 04:05:26 -08:00
react-native-test-library Let lib maintainer be explicit with componentProvider mapping (#47520) 2024-11-12 07:38:03 -08:00
react-native-test-renderer Refactor Performance and PerformanceObserver internals (#46693) 2024-10-02 03:13:24 -07:00
rn-tester fix: start and end points linear gradient algorithm (#47003) 2024-11-20 17:17:52 -08:00
typescript-config Bump main to 0.77 2024-09-12 09:23:23 -07:00
virtualized-lists turn on by default optimization for memoization of virtualized list cells (#47724) 2024-11-20 16:00:03 -08:00