Skip to content

Commit

Permalink
Update SinusPulsator to accept "reverse" parameter
Browse files Browse the repository at this point in the history
The "reverse" parameter allows the effect to begin in the applied state, progressing towards the unapplied state. Useful for ImageOverlayPulsate effect to fade out from an ImageOverlay effect.
  • Loading branch information
Davi-DeGanne committed Jan 31, 2015
1 parent bc6bb0b commit 52c76e9
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class SinusPulsator implements PulsatorProvider {
*/
private boolean cycle = true;

/**
* start the pulsator at 1 (true) or 0 (false).
*/
private boolean reverse = false;

/**
* Initialize the Pulsator.
*
Expand All @@ -53,6 +58,7 @@ public void initialize(@Nonnull final Properties parameter) {
period = 1000.f;
}
this.cycle = Boolean.parseBoolean(parameter.getProperty("cycle", Boolean.toString(true)));
this.reverse = Boolean.parseBoolean(parameter.getProperty("reverse", Boolean.toString(false)));
}

/**
Expand All @@ -64,15 +70,10 @@ public void initialize(@Nonnull final Properties parameter) {
@Override
public float getValue(final long msTime) {
long t = msTime - startTime;
if (cycle) {
return getSinusValue(t);
} else {
if (t > period * HALF) {
return 1.0f;
} else {
return getSinusValue(t);
}
}
if (!cycle && t > period * HALF)
return (reverse? 0.0f: 1.0f);
else
return getSinusValue(t + (reverse? (long)(period * HALF): 0l));
}

/**
Expand Down

0 comments on commit 52c76e9

Please sign in to comment.