setSubmobjectColorsByRadialGradient method

void setSubmobjectColorsByRadialGradient({
  1. Vector3? center,
  2. double? radius,
  3. required Color innerColor,
  4. required Color outerColor,
})

Implementation

void setSubmobjectColorsByRadialGradient(
    {Vector3? center,
    double? radius,
    required Color innerColor,
    required Color outerColor}) {
  center ??= getCenter();
  radius ??= 1;

  for (var mob in getFamilyWithPoints()) {
    var t = (mob.getCenter() - center).norm() / radius;
    t = min(t, 1);
    var color = interpolateValue(innerColor, outerColor, t);
    mob.setColor(color: color, family: false);
  }
}