apply method

  1. @override
void apply(
  1. ActorComponent? component,
  2. double mix
)
override

Implementation

@override
void apply(ActorComponent? component, double mix) {
  RadialGradientColor radial = component as RadialGradientColor;

  int ridx = 0;
  int wi = 0;

  if (mix == 1.0) {
    radial.secondaryRadiusScale = value[ridx++];
    radial.start[0] = _value[ridx++];
    radial.start[1] = _value[ridx++];
    radial.end[0] = _value[ridx++];
    radial.end[1] = _value[ridx++];

    while (ridx < _value.length && wi < radial.colorStops.length) {
      radial.colorStops[wi++] = _value[ridx++];
    }
  } else {
    double imix = 1.0 - mix;
    radial.secondaryRadiusScale =
        radial.secondaryRadiusScale * imix + value[ridx++] * mix;
    radial.start[0] = radial.start[0] * imix + _value[ridx++] * mix;
    radial.start[1] = radial.start[1] * imix + _value[ridx++] * mix;
    radial.end[0] = radial.end[0] * imix + _value[ridx++] * mix;
    radial.end[1] = radial.end[1] * imix + _value[ridx++] * mix;

    while (ridx < _value.length && wi < radial.colorStops.length) {
      radial.colorStops[wi] = radial.colorStops[wi] * imix + _value[ridx++];
      wi++;
    }
  }
  radial.markPaintDirty();
}