plattysoft / Leonids

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

Change size of particles in Leonids Particle System Lib #40

Open malomasti opened 8 years ago

malomasti commented 8 years ago

I am using the Leonids Particle System Lib, using the JAR library. When you use, for example, the .OneShot function, as in:

new ParticleSystem(Activity.this, 200, R.drawable.particle, (int)(t_star/2.0f)) .setSpeedRange(0.1f, 0.2f) .oneShot(view, time);

the lib loads the R.drawable.particle, and emits the oneshot with the exact height and width in pixels than the original image. I want to control the exact size of the particles, since the effect should be different depending on the density of the used device (and LDPI, MDPI, etc. are not the exact approach, since the exact size control is desired)

Is if there are any ways to change the width or height of the particles in px or dp?

dgcooke commented 8 years ago

This is how I do it, may not be the best way but it works.

Bitmap chestImage = BitmapFactory.decodeResource(PerformanceActivity.this.getResources(),R.drawable.dust_circle_centre_fuchsia); Bitmap resizedChestImage = Bitmap.createScaledBitmap(chestImage, 20, 20, false);

new ParticleSystem(PerformanceActivity.this, 10, resizedChestImage, 4000,R.id.frameView) .setInitialRotationRange(0, 360) .addModifier(new AlphaModifier(255, 0, 200, 4000)) .addModifier(new ScaleModifier(1.0f, 2f, 0, 3000)) .oneShot(frontImageView, 4);

Hope it Helps Damien