EddyVerbruggen / nativescript-gradient

:art: Easily add fancy (or subtle) gradient backgrounds to your views

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The colors support transparency???

dianjuar opened this issue · comments

Hi I wonder if the gradient colors support transparency.
To be more specific, I need do a gradient from black to transparent...

I need something like this.
screen shot 2017-06-23 at 11 00 27

But I have this.
screen shot 2017-06-23 at 11 02 31

The code is:

<GridLayout class="product-image">
  <Image [src]="productActual.image" stretch="aspectFill"></Image>
  <Gradient class="gadient-top" direction="to bottom" colors="#000000, #FFFFFF" verticalAlignment="top" > </Gradient>
</GridLayout>

I DID IT!!!! I HACK IT!!!!

Viewing the attribute colors of <Gradient>, I saw there is a compatibility with the CSS colors.
I test it with "red" and rgb(255, 0, 0) and the result was the same, so I use RGBA Colors to get my transparency, I simple use rgba(0, 0, 0, 0) to get a full transparent color.

screen shot 2017-06-23 at 11 19 40

<GridLayout class="product-image">
  <Image [src]="productActual.image" stretch="aspectFill"></Image>
  <Gradient class="gadient-top" direction="to bottom" colors="#000000, rgba(0, 0, 0, 0)" verticalAlignment="top" > </Gradient>
</GridLayout>

Maybe in your readme, in the usage section, you need to tell that your colors definitions are compatible with CSS Colors

@dianjuar Thats a really cool trick.

Hey @dianjuar, nice job!

It was mentioned in the readme that anything you can pass to NativeScript's new Color(...) constructors would work, but I've now made it more clear.