1
This commit is contained in:
@@ -74,6 +74,11 @@
|
||||
|
||||
CGFloat x = startX + i * (self.barWidth + self.barSpacing);
|
||||
CGFloat height = minHeight;
|
||||
if (self.barHeightPattern.count > i) {
|
||||
CGFloat base = [self.barHeightPattern[i] floatValue];
|
||||
base = MIN(MAX(base, 0.15), 0.9);
|
||||
height = MAX(minHeight, maxHeight * base);
|
||||
}
|
||||
CGFloat y = (maxHeight - height) / 2;
|
||||
|
||||
barLayer.frame = CGRectMake(x, y, self.barWidth, height);
|
||||
@@ -141,9 +146,15 @@
|
||||
CGFloat phase = (CGFloat)i / self.barLayers.count * M_PI * 2;
|
||||
CGFloat wave = sin(time * 3 + phase) * 0.3 + 0.7; // 0.4 - 1.0
|
||||
|
||||
// 计算高度
|
||||
CGFloat heightFactor = rms * wave;
|
||||
CGFloat height = minHeight + range * heightFactor;
|
||||
CGFloat baseFactor = 0.2;
|
||||
if (self.barHeightPattern.count > i) {
|
||||
baseFactor = [self.barHeightPattern[i] floatValue];
|
||||
baseFactor = MIN(MAX(baseFactor, 0.15), 0.9);
|
||||
}
|
||||
// 计算高度:基准高度 + 随 RMS 波动
|
||||
CGFloat dynamicFactor = rms * (0.35 + 0.15 * wave); // 0.35~0.5
|
||||
CGFloat heightFactor = MIN(1.0, baseFactor + dynamicFactor * (1.0 - baseFactor));
|
||||
CGFloat height = maxHeight * heightFactor;
|
||||
height = MAX(minHeight, MIN(maxHeight, height));
|
||||
|
||||
// 更新位置
|
||||
|
||||
Reference in New Issue
Block a user