Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradient userSpaceOnUse is not working with viewBox(or incorrect scale?) #2558

Open
burakgormek opened this issue Nov 29, 2024 · 1 comment

Comments

@burakgormek
Copy link

burakgormek commented Nov 29, 2024

Description

gradientUnits="userSpaceOnUse" is not working with viewBox

With viewBox(iOS & Android & Web):
imageimageimage


Without viewBox(iOS & Android & Web):
imageimageimage

I think userSpaceOnUse is not correctly scaling with viewBox but I'm not sure. objectBoundingBox is working as expected like on web.

Steps to reproduce

Expo snack has reproducible example of svg

Snack or a link to a repository

https://snack.expo.dev/XdF3aIhDlSkjbhRBbHpzK

SVG version

15.9.0

React Native version

0.76.3

Platforms

Android, iOS

JavaScript runtime

None

Workflow

None

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@burakgormek
Copy link
Author

I took a glance at the native code, and seems like LinearGradient does not scale with viewBox.

<Svg width="800" height="800" viewBox="0 0 10 10">
  <LinearGradient
    id="test"
    x1="0%"
    y1="0%"
    x2="0%"
    y2="100%"
    gradientUnits="userSpaceOnUse"
  >
    <Stop offset="0%" stopColor="green" />
    <Stop offset="100%" stopColor="red" />
  </LinearGradient>
</Svg>

Svg is scaled but the gradient remains 10x10, so only small a parts of it applied to the shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant