react-native-radial-gradient icon indicating copy to clipboard operation
react-native-radial-gradient copied to clipboard

[BUG]: Does not support transparent backgrounds.

Open TrebuhD opened this issue 6 years ago • 12 comments

I'm trying to interpolate between a regular color and a transparent one in order to have 2 radial gradients that interact with each other. Unfortunately it seems transparent gets ignored and interpreted as black. Transparent hex values also don't work.

      <RadialGradient
        style={{ width: 200, height: 200 }}
        colors={['#00ffff', 'transparent']}
        stops={[0.3]}
        center={[100, 100]}
        radius={200}
      />

results in image

Whereas the black pixels should be transparent.

TrebuhD avatar Jan 01 '19 17:01 TrebuhD

in android , you can use colors={['rgba(0,255,255,1)','rgba(0,255,255,0)']}. it is ok in android but don't work in ios.

ali226281 avatar Jan 13 '19 20:01 ali226281

I've the same issue : On Android my transparent radial gradients are correctly rendered but on iOS the transparent color is transformed in black color.

TheWebartist avatar Jan 23 '19 14:01 TheWebartist

@TrebuhD @TheWebartist did you guys found any fix for this? @surajit-bitcanny @surajitsarkar19

ManigandanRaamanathan avatar Jan 29 '19 17:01 ManigandanRaamanathan

I haven't been able to achieve this effect using this library. I'm not sure it's possible with the current implementation in the java code.

I was able to throw something together using this library, but we're not using it in production: https://github.com/iyegoroff/react-native-image-filter-kit. It's an image filter library, but you can create a transparent image and generate a radial gradient on top of that.

You could try using https://github.com/react-native-community/react-native-svg, it might be more performant.

TrebuhD avatar Jan 29 '19 17:01 TrebuhD

Hey guys,

I fixed this issue on iOS and sent pull request to this repository. But for now you can use fixed version from my fork:

npm install shkatulo/react-native-radial-gradient --save

shkatulo avatar May 22 '19 07:05 shkatulo

The PR in question is #12.

ffMathy avatar Jun 11 '19 18:06 ffMathy

Not sure if the owner (@surajitsarkar19) is still active. Has anyone heard from him recently?

ffMathy avatar Jun 13 '19 19:06 ffMathy

+1 for Android issue. Even specifying colors like colors={['rgba(0,255,255,1)','rgba(0,255,255,0)']} are rendering a 'square' not 'circle'. Same result with iOS (PR !12 is merged and I can verify that fix from @shkatulo is in codebase of module, but its not working on iOS too).

Any clue ??

klodha avatar Oct 12 '19 12:10 klodha

If this project is anymore active?

klodha avatar Oct 16 '19 08:10 klodha

No idea. It's a shame, because it's such an important feature, and this library is very simple and easy to use.

ffMathy avatar Oct 16 '19 10:10 ffMathy

I can totally understand if @surajitsarkar19 is no longer interested in maintaining the project, everyone has their priorities. Though if he could have mentioned state on repo home page (like deprecated / no longer being maintained), new users like me could have saved ton of time by not opting for this plugin.

Anyways, I don't have enough experience with native programming (a reason why I am using React Native) but hopefully someone having in depth idea about how native rendering is working will be able to get it resolved.

For now, I switched to SVG option.

klodha avatar Oct 16 '19 10:10 klodha

+1 for Android issue. Even specifying colors like colors={['rgba(0,255,255,1)','rgba(0,255,255,0)']} are rendering a 'square' not 'circle'. Same result with iOS (PR !12 is merged and I can verify that fix from @shkatulo is in codebase of module, but its not working on iOS too).

Any clue ??

Just rebuilt project, where I use fixed code. Still works for me on both platforms, if I create gradient like this:

<RadialGradient 
                colors={[ '#C86DD7FF', '#C86DD760', '#C86DD700' ]} 
                center={[ gradX, gradY ]}
                radius={radius}
                style={StyleSheet.absoluteFillObject}/>

shkatulo avatar Oct 16 '19 11:10 shkatulo