plattysoft / Leonids

A Particle System for standard Android UI: http://plattysoft.github.io/Leonids/
Apache License 2.0
2.28k stars 397 forks source link

Random opacity from range? #67

Open ShaharAvigezer opened 7 years ago

ShaharAvigezer commented 7 years ago

Hi, great library! Is there a possibility to generate different opacities for the particles?

Thanks!

plattysoft commented 7 years ago

Not out of the box I'm afraid. There is an AlphaModifer (to perform fade in and fade out) but not an AlphaInitializer, which is what you want.

You can create the Initializer yourself and modify the code of ParticleSystem to create it and add it to the initializer list.

Now that I think about it, it makes sense to add a "add generic initializer" method to the ParticleSystem class to allow extensions like the one you are asking for.

ShaharAvigezer commented 7 years ago

Ok, thanks for the reply! Is there any way to set bounds for the animation? for example, I want to keep it only within a certain view.

plattysoft commented 7 years ago

That you can do using the constructor that receives a view Id, in that case the ParticleSystem is created as a child of that View, which means that

a) It is placed at that particular z-index in the hierarchy (original purpose was to put particles on the background) b) It is only as big as the parent (which is what you want)

Note that the parent view must be a ViewGroup, I suggest you use FrameLayout.