operate method

  1. @override
Color operate(
  1. Contexts context,
  2. String op,
  3. Color other
)
override

Operations have to be done per-channel, if not, channels will spill onto each other. Once we have our result, in the form of an integer triplet, we create a new Color node to hold the result.

Implementation

@override
Color operate(Contexts context, String op, Color other) {
  final alpha = this.alpha * (1 - other.alpha) + other.alpha;

  final rgb = <num>[
    for (var c = 0; c < 3; c++)
      _operate(context, op, this.rgb[c], other.rgb[c])
  ];

  return Color.fromList(rgb, alpha);

//3.0.0 20160714
// Color.prototype.operate = function (context, op, other) {
//     var rgb = new Array(3);
//     var alpha = this.alpha * (1 - other.alpha) + other.alpha;
//     for (var c = 0; c < 3; c++) {
//         rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);
//     }
//     return new Color(rgb, alpha);
// };
}