|
|
@@ -34,11 +34,23 @@ public class SplashAnimView extends View {
|
|
|
public interface OnEndListener { void onEnd(); }
|
|
|
|
|
|
private static final long DURATION_MS = 2100;
|
|
|
- // 阶段边界(0..1)
|
|
|
- private static final float DRAW_END = 0.38f; // 描边生长完成
|
|
|
- private static final float FILL_START = 0.30f; // 填充开始出现
|
|
|
- private static final float FILL_FULL = 0.55f; // 填充不再透明
|
|
|
- private static final float SWEEP_END = 0.72f; // 渐变扫到位 & 描边完全淡出
|
|
|
+ /*
|
|
|
+ * 阶段边界(0..1)—— 2026-11-23 用户反馈「图压在歪线的上面特别丑」
|
|
|
+ *
|
|
|
+ * 原来是重叠的:描边 0.38 才画完,填充 0.30 就开始,必然有一段时间
|
|
|
+ * 彩色填充盖在还没走完的线条上,看起来像两套图形打架。
|
|
|
+ *
|
|
|
+ * 现在改成严格顺序,三段不重叠:
|
|
|
+ * 0.00 → 0.45 只画笔画(线条一笔一笔长出来)
|
|
|
+ * 0.45 → 0.58 笔画淡出(线条消失,画面短暂留白)
|
|
|
+ * 0.58 → 0.88 填充淡入 + 渐变扫过(图在干净的画面上出现)
|
|
|
+ * 0.88 → 1.00 留一点时间让人看清完整标志
|
|
|
+ */
|
|
|
+ private static final float DRAW_END = 0.45f; // 描边生长完成
|
|
|
+ private static final float STROKE_OUT_END = 0.58f; // 描边完全淡出(此前不动填充)
|
|
|
+ private static final float FILL_START = 0.58f; // 填充开始(描边已淡出)
|
|
|
+ private static final float FILL_FULL = 0.90f; // 填充完全成型
|
|
|
+ private static final float SWEEP_END = 0.90f; // 渐变扫到位
|
|
|
|
|
|
/*
|
|
|
* 轮廓点:从 logo-mark.png(512×512 带透明通道)提取的 4 个外轮廓,
|
|
|
@@ -88,22 +100,64 @@ public class SplashAnimView extends View {
|
|
|
float dy = h * 0.44f - s / 2f;
|
|
|
bounds.set(dx, dy, dx + s, dy + s);
|
|
|
for (int i = 0; i < CONTOURS.length; i++) {
|
|
|
- float[] pts = CONTOURS[i];
|
|
|
- Path p = new Path();
|
|
|
- p.moveTo(dx + pts[0] * s, dy + pts[1] * s);
|
|
|
- for (int j = 2; j + 1 < pts.length; j += 2) {
|
|
|
- p.lineTo(dx + pts[j] * s, dy + pts[j + 1] * s);
|
|
|
- }
|
|
|
- p.close();
|
|
|
+ /*
|
|
|
+ * 用 Catmull-Rom 转三次贝塞尔平滑(2026-11-23 用户反馈「线条歪扭、颗粒度差」)。
|
|
|
+ *
|
|
|
+ * 原因:原来对 50~60 个轮廓点逐个 lineTo 直线连接,
|
|
|
+ * 点是从 PNG 边缘提取的,本身就带像素锯齿,
|
|
|
+ * 直线段一多,曲线就变成一堆折线,放大后歪歪扭扭。
|
|
|
+ * 改法:把相邻点当成样条控制点,用 cubicTo 画平滑曲线,
|
|
|
+ * 曲线穿过所有原点(Catmull-Rom 插值特性),只抹掉折角不改形状。
|
|
|
+ */
|
|
|
+ Path p = crClosedPath(CONTOURS[i], dx, dy, s);
|
|
|
paths[i] = p;
|
|
|
lengths[i] = new PathMeasure(p, false).getLength();
|
|
|
}
|
|
|
- strokePaint.setStrokeWidth(s * 0.012f);
|
|
|
+ strokePaint.setStrokeWidth(Math.max(1.5f, s * 0.010f));
|
|
|
gradient = new LinearGradient(bounds.left, bounds.bottom, bounds.right, bounds.top,
|
|
|
GRADIENT_COLORS, GRADIENT_POS, Shader.TileMode.CLAMP);
|
|
|
fillPaint.setShader(gradient);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 把归一化点序列转成平滑闭合曲线(Catmull-Rom → 三次贝塞尔)。
|
|
|
+ *
|
|
|
+ * 每段 P1→P2 用控制点
|
|
|
+ * c1 = P1 + (P2 − P0) / 6
|
|
|
+ * c2 = P2 − (P3 − P1) / 6
|
|
|
+ * 其中 P0/P3 是前后相邻点(首尾环绕,保证闭合处也平滑)。
|
|
|
+ * 这样曲线经过每个原始点,但不出现折角。
|
|
|
+ */
|
|
|
+ private static Path crClosedPath(float[] pts, float dx, float dy, float s) {
|
|
|
+ int n = pts.length / 2;
|
|
|
+ Path p = new Path();
|
|
|
+ if (n < 3) return p;
|
|
|
+
|
|
|
+ float[] x = new float[n];
|
|
|
+ float[] y = new float[n];
|
|
|
+ for (int i = 0; i < n; i++) {
|
|
|
+ x[i] = dx + pts[i * 2] * s;
|
|
|
+ y[i] = dy + pts[i * 2 + 1] * s;
|
|
|
+ }
|
|
|
+
|
|
|
+ p.moveTo(x[0], y[0]);
|
|
|
+ for (int i = 0; i < n; i++) {
|
|
|
+ int i0 = (i - 1 + n) % n;
|
|
|
+ int i1 = i;
|
|
|
+ int i2 = (i + 1) % n;
|
|
|
+ int i3 = (i + 2) % n;
|
|
|
+
|
|
|
+ float c1x = x[i1] + (x[i2] - x[i0]) / 6f;
|
|
|
+ float c1y = y[i1] + (y[i2] - y[i0]) / 6f;
|
|
|
+ float c2x = x[i2] - (x[i3] - x[i1]) / 6f;
|
|
|
+ float c2y = y[i2] - (y[i3] - y[i1]) / 6f;
|
|
|
+
|
|
|
+ p.cubicTo(c1x, c1y, c2x, c2y, x[i2], y[i2]);
|
|
|
+ }
|
|
|
+ p.close();
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onAttachedToWindow() {
|
|
|
super.onAttachedToWindow();
|
|
|
@@ -134,11 +188,14 @@ public class SplashAnimView extends View {
|
|
|
float t = progress;
|
|
|
// ① 描边生长(ease-out:起笔快、收笔稳)
|
|
|
float drawT = easeOut(clamp(t / DRAW_END));
|
|
|
- // ② 填充:透明度过渡 + 渐变沿对角线扫入
|
|
|
+ /*
|
|
|
+ * ② 描边淡出:在 DRAW_END → STROKE_OUT_END 之间归零。
|
|
|
+ * 这段区间内不画填充,让线条干干净净地消失。
|
|
|
+ */
|
|
|
+ float strokeAlpha = 1f - clamp((t - DRAW_END) / (STROKE_OUT_END - DRAW_END));
|
|
|
+ // ③ 填充:描边完全消失后才开始(FILL_START == STROKE_OUT_END)
|
|
|
float fillT = clamp((t - FILL_START) / (FILL_FULL - FILL_START));
|
|
|
float sweepT = clamp((t - FILL_START) / (SWEEP_END - FILL_START));
|
|
|
- // ③ 描边在填充成型后淡出
|
|
|
- float strokeAlpha = 1f - clamp((t - FILL_FULL) / (SWEEP_END - FILL_FULL));
|
|
|
|
|
|
if (fillT > 0f && gradient != null) {
|
|
|
gradMatrix.setTranslate(
|