-
Notifications
You must be signed in to change notification settings - Fork 13
Effector
BloomEffector is the most important class of the library, you can build an effector in the following ways:
new BloomEffector.Builder()
.setDuration(800)
.setAnchor(view.getWidth() / 2, view.getHeight() / 2)
.build()
Let's take a look at all the methods that can be used by the effector:
Method | Description |
---|---|
setDuration(long duration) | Sets the length of the bloom effect animation in milliseconds |
setInterpolator(TimeInterpolator interpolator) | Set the interpolator of the bloom effect animation. |
setAnchor(float anchorX, float anchorY) | Set anchor points for all the particles |
setSpeedRange(float minSpeed, float maxSpeed) | Set the speed range for the particles |
setScaleRange(float minScale, float maxScale) | Set the scale range for the particles |
setSkewRange(float minSkew, float maxSkew) | Set the skew range for the particles |
setRotationSpeedRange(float minRotationSpeedRange, float maxRotationSpeedRange) | Set the rotation speed range for the particles |
setAcceleration(float acceleration, int accelerationAngle) | Set particle acceleration |
setAccelerationRange(float minAcceleration, float maxAcceleration, int minAccelerationAngel, int maxAccelerationAngel) | Set particle acceleration |
setFadeOut(long startTime, TimeInterpolator interpolator) | Set the fade out effect for all particle |
setFadeOut(long startTime) | Set the fade out effect for all particle |
BloomEffector build() | Build an effector |
Anchor can control the initial direction of motion of all particles, the anchor can control the initial direction of motion of all particles. The principle is that all particles will be angled with this anchor coordinate (x, y) to get the next angle of motion of the particle.
If the anchor point is set to the coordinates of the center point of the view, then all particles will be angled with the coordinates of the center point, that is, all particles will be offset relative to the center point, and the final particle animation effect is as follows:
Control the movement speed of particles
The speed of the particle will take a random value from the speed range you set.
The formula is as follows:
float randomSpeed = mRandom.nextFloat()*(mMaxSpeed-mMinSpeed) + mMinSpeed;
Control the scale of particles
The scale of the particle will take a random value from the scale range you set.
The formula is as follows:
float scale = mRandom.nextFloat() * (mMaxScale - mMinScale) + mMinScale
Control the skew of particles
The skew of the particle will take a random value from the skew range you set.
The formula is as follows:
float skew = mRandom.nextFloat() * (mMaxSkew - mMinSkew) + mMinSkew;
Controls the rotation acceleration of the particle. If this value is not set, the particle will not rotate.
The rotation animation of the particle will take a random value from the rotation speed range you set.
The formula is as follows:
float rotationSpeed = mRandom.nextFloat()*(mMaxRotationSpeed-mMinRotationSpeed) + mMinRotationSpeed;
Controls particle acceleration and acceleration direction, the acceleration direction is determined by the acceleration angle you set, calculated as follows:
float angelInRadsAcc = (float) (accelerationAngle*Math.PI / 180f)
//The x axis acceleration:
accelerationX = (float) (value * Math.cos(angleInRadsAcc));
//The y axis acceleration:
accelerationY = (float) (value * Math.sin(angleInRadsAcc));
The acceleration is measured in pixels per square millisecond:
float finalTranslateX = accelerationX*milliSecond*milliSecond;
float finalTranslateY = accelerationY*milliSecond*milliSecond;
Control the particle's fadeout effect, the fact is to control the alpha value of the particle.The fadeout start time can be [0-duration].