Leonids icon indicating copy to clipboard operation
Leonids copied to clipboard

Particles image , How to rotate Y axis-angle?

Open karthick-subramani opened this issue 8 years ago • 4 comments

Hi, I had issues like unable to rotate in z -axis side of particles image from leonids lib, right now its rotating like x-axis angle. how to make like z-axis rotation in gravity bottom. I am expecting to do like below gif file, in that each particles rotate like z-axis and x-axis.

confetti_new - copy

karthick-subramani avatar Jul 28 '16 01:07 karthick-subramani

I think you mean to rotate on the z-axis.

The library is based on 2D so the particles are flat and do not rotate.

This could be done using the transformation matrix on Particles inside the draw method, but it is not currently implemented.

plattysoft avatar Jul 28 '16 08:07 plattysoft

Can you able to suggest where exactly to change for transformation matrix on Particles system method.

karthick-subramani avatar Jul 28 '16 09:07 karthick-subramani

As I said, in the draw method of Particle: https://github.com/plattysoft/Leonids/blob/master/LeonidsLib/src/main/java/com/plattysoft/leonids/Particle.java#L91

You have a Matrix, so you just have to apply the modification you want, it is likely that you want to do skew: https://developer.android.com/reference/android/graphics/Matrix.html#postSkew(float, float, float, float)

And then have the parameters to update with the rest of the variables inside update: https://github.com/plattysoft/Leonids/blob/master/LeonidsLib/src/main/java/com/plattysoft/leonids/Particle.java#L77

plattysoft avatar Jul 28 '16 10:07 plattysoft

postSkew(float, float, float, float) , its not working fine. Any other way to do that animation.

karthick-subramani avatar Aug 02 '16 07:08 karthick-subramani