Ripple size and easing

- make sparkles a little larger
- adjust easings
- adjust fade in/out

Test: visual
Fixes: 184444641
Fixes: 184443654
Change-Id: Id157edb7e41e8e55bd57bb376497431f9a3c90f0
This commit is contained in:
Lucas Dupin
2021-04-04 11:38:04 -07:00
parent 19c6382263
commit d1da7e0af9
2 changed files with 12 additions and 11 deletions

View File

@@ -41,8 +41,8 @@ public final class RippleAnimationSession {
private static final int ENTER_ANIM_DURATION = 450;
private static final int EXIT_ANIM_DURATION = 300;
private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
private static final Interpolator FAST_OUT_LINEAR_IN =
new PathInterpolator(0.4f, 0f, 1f, 1f);
private static final Interpolator FAST_OUT_SLOW_IN =
new PathInterpolator(0.4f, 0f, 0.2f, 1f);
private Consumer<RippleAnimationSession> mOnSessionEnd;
private final AnimationProperties<Float, Paint> mProperties;
private AnimationProperties<CanvasProperty<Float>, CanvasProperty<Paint>> mCanvasProperties;
@@ -173,7 +173,7 @@ public final class RippleAnimationSession {
private void startAnimation(Animator expand) {
expand.setDuration(ENTER_ANIM_DURATION);
expand.addListener(new AnimatorListener(this));
expand.setInterpolator(FAST_OUT_LINEAR_IN);
expand.setInterpolator(FAST_OUT_SLOW_IN);
expand.start();
mAnimateSparkle = true;
}

View File

@@ -48,7 +48,7 @@ final class RippleShader extends RuntimeShader {
+ " float s = 0.0;\n"
+ " for (float i = 0; i < 4; i += 1) {\n"
+ " float l = i * 0.01;\n"
+ " float h = l + 0.1;\n"
+ " float h = l + 0.2;\n"
+ " float o = smoothstep(n - l, h, n);\n"
+ " o *= abs(sin(PI * o * (t + 0.55 * i)));\n"
+ " s += o;\n"
@@ -73,18 +73,19 @@ final class RippleShader extends RuntimeShader {
+ " return (sub - start) / (end - start); \n"
+ "}\n";
private static final String SHADER_MAIN = "vec4 main(vec2 p) {\n"
+ " float fadeIn = subProgress(0., 0.175, in_progress);\n"
+ " float fadeOutNoise = subProgress(0.375, 1., in_progress);\n"
+ " float fadeOutRipple = subProgress(0.375, 0.75, in_progress);\n"
+ " float fadeIn = subProgress(0., 0.1, in_progress);\n"
+ " float scaleIn = subProgress(0., 0.45, in_progress);\n"
+ " float fadeOutNoise = subProgress(0.5, 1., in_progress);\n"
+ " float fadeOutRipple = subProgress(0.5, 0.75, in_progress);\n"
+ " vec2 center = mix(in_touch, in_origin, fadeIn);\n"
+ " float ring = softRing(p, center, in_maxRadius, fadeIn, 0.45);\n"
+ " float alpha = 1. - fadeOutNoise;\n"
+ " float ring = softRing(p, center, in_maxRadius, scaleIn, 0.45);\n"
+ " float alpha = min(fadeIn, 1. - fadeOutNoise);\n"
+ " vec2 uv = p * in_resolutionScale;\n"
+ " vec2 densityUv = uv - mod(uv, in_noiseScale);\n"
+ " float sparkle = sparkles(densityUv, in_noisePhase) * ring * alpha;\n"
+ " float fade = min(fadeIn, 1. - fadeOutRipple);\n"
+ " vec4 circle = in_color * (softCircle(p, center, in_maxRadius "
+ " * fadeIn, 0.2) * fade);\n"
+ " * scaleIn, 0.2) * fade);\n"
+ " float mask = in_hasMask == 1. ? sample(in_shader).a > 0. ? 1. : 0. : 1.;\n"
+ " return mix(circle, vec4(sparkle), sparkle) * mask;\n"
+ "}";
@@ -134,7 +135,7 @@ final class RippleShader extends RuntimeShader {
}
public void setResolution(float w, float h, int density) {
float densityScale = density * DisplayMetrics.DENSITY_DEFAULT_SCALE;
float densityScale = density * DisplayMetrics.DENSITY_DEFAULT_SCALE * 1.25f;
setUniform("in_resolutionScale", new float[] {1f / w, 1f / h});
setUniform("in_noiseScale", new float[] {densityScale / w, densityScale / h});
}