Android Open Source - Coloring-book Scale Modifier






From Project

Back to project page Coloring-book.

License

The source code is released under:

Apache License

If you think the Android project Coloring-book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.plattysoft.leonids.modifiers;
//from   w  ww.j a  v a 2  s .  c o m
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import com.plattysoft.leonids.Particle;

public class ScaleModifier implements ParticleModifier {

  private float mInitialValue;
  private float mFinalValue;
  private long mEndTime;
  private long mStartTime;
  private long mDuration;
  private float mValueIncrement;
  private Interpolator mInterpolator;

  public ScaleModifier (float initialValue, float finalValue, long startMilis, long endMilis, Interpolator interpolator) {
    mInitialValue = initialValue;
    mFinalValue = finalValue;
    mStartTime = startMilis;
    mEndTime = endMilis;
    mDuration = mEndTime - mStartTime;
    mValueIncrement = mFinalValue-mInitialValue;
    mInterpolator = interpolator;
  }
  
  public ScaleModifier (float initialValue, float finalValue, long startMilis, long endMilis) {
    this (initialValue, finalValue, startMilis, endMilis, new LinearInterpolator());
  }
  
  @Override
  public void apply(Particle particle, long miliseconds) {
    if (miliseconds < mStartTime) {
      particle.mScale = mInitialValue;
    }
    else if (miliseconds > mEndTime) {
      particle.mScale = mFinalValue;
    }
    else {
      float interpolaterdValue = mInterpolator.getInterpolation((miliseconds- mStartTime)*1f/mDuration);
      float newScale = mInitialValue + mValueIncrement*interpolaterdValue;
      particle.mScale = newScale;
    }
  }

}




Java Source Code List

com.kidsgames.gamebase.DrawerActivity.java
com.kidsgames.gamebase.DrawingView.java
com.kidsgames.menu.DrawerSliderActivity.java
com.kidsgames.menu.FixedSpeedScroller.java
com.kidsgames.menu.FixedSpeedViewPager.java
com.kidsgames.menu.MainMenu.java
com.kidsgames.menu.SlideAdapter.java
com.kidsgames.utils.ResourceId.java
com.plattysoft.leonids.AnimatedParticle.java
com.plattysoft.leonids.ParticleField.java
com.plattysoft.leonids.ParticleSystem.java
com.plattysoft.leonids.Particle.java
com.plattysoft.leonids.initializers.AccelerationInitializer.java
com.plattysoft.leonids.initializers.ParticleInitializer.java
com.plattysoft.leonids.initializers.RotationInitiazer.java
com.plattysoft.leonids.initializers.RotationSpeedInitializer.java
com.plattysoft.leonids.initializers.ScaleInitializer.java
com.plattysoft.leonids.initializers.SpeeddByComponentsInitializer.java
com.plattysoft.leonids.initializers.SpeeddModuleAndRangeInitializer.java
com.plattysoft.leonids.modifiers.AccelerationModifier.java
com.plattysoft.leonids.modifiers.AlphaModifier.java
com.plattysoft.leonids.modifiers.ParticleModifier.java
com.plattysoft.leonids.modifiers.ScaleModifier.java