ColorMatrix.tint constructor

ColorMatrix.tint(
  1. UvColor tint, {
  2. double amount = 0.5,
})

Returns a tint transform that blends colors toward tint.

Implementation

factory ColorMatrix.tint(UvColor tint, {double amount = 0.5}) {
  final resolved = _resolveRgb(tint);
  final factor = amount.clamp(0.0, 1.0);
  if (resolved == null || factor <= 0) return identity;
  final keep = 1.0 - factor;
  return ColorMatrix(<double>[
    keep,
    0,
    0,
    0,
    resolved.r * factor,
    0,
    keep,
    0,
    0,
    resolved.g * factor,
    0,
    0,
    keep,
    0,
    resolved.b * factor,
    0,
    0,
    0,
    1,
    0,
  ]);
}