update method
更新累计角 swirlDeg 和钳制到零至一的强度 mix。
excluded 为 true 的位置保持原值,列表存在时须与物体数等长。
Implementation
void update(double swirlDeg, double mix, {List<bool>? excluded}) {
final strength = luckyUnit(mix);
for (var j = 0; j < _rest.length; j++) {
if (excluded != null && excluded[j]) continue;
final seed = j + 1;
final w = _base + _speedRange * (_speedSeed * seed % 1);
final orbit = (_orbitBase + _base * (_orbitSeed * seed % 1)) * _limit;
final theta = luckyDegToRad(
kLuckyFullTurnDeg * (_phaseSeed * seed % 1) + swirlDeg * w);
var px = _rest[j].dx + (orbit * math.cos(theta) - _rest[j].dx) * strength;
var py = _rest[j].dy +
(orbit * math.sin(theta) -
_lift *
_radius *
math.sin(kLuckyHalfDivisor * theta).abs() *
strength -
_rest[j].dy) *
strength;
final distance = math.sqrt(px * px + py * py);
if (distance > _limit) {
px *= _limit / distance;
py *= _limit / distance;
}
x[j] = px;
y[j] = py;
angle[j] = luckyDegToRad(swirlDeg * w * kLuckyHalfDivisor * strength);
}
}