# colorFilter property

ColorFilter colorFilter

A color filter to apply when a shape is drawn or when a layer is composited.

See ColorFilter for details.

When a shape is being drawn, colorFilter overrides color and shader.

## Implementation

    ColorFilter get colorFilter {
      switch (_data.getInt32(_kColorFilterOffset, _kFakeHostEndian)) {
        case ColorFilter._TypeNone:
          return null;
        case ColorFilter._TypeMode:
          return new ColorFilter.mode(
            new Color(_data.getInt32(_kColorFilterColorOffset, _kFakeHostEndian)),
            BlendMode.values[_data.getInt32(_kColorFilterBlendModeOffset, _kFakeHostEndian)],
          );
        case ColorFilter._TypeMatrix:
          return new ColorFilter.matrix(_objects[_kColorFilterMatrixIndex]);
        case ColorFilter._TypeLinearToSrgbGamma:
          return const ColorFilter.linearToSrgbGamma();
        case ColorFilter._TypeSrgbToLinearGamma:
          return const ColorFilter.srgbToLinearGamma();
      }

      return null;
    }

void colorFilter= (ColorFilter value)

## Implementation

    set colorFilter(ColorFilter value) {
      if (value == null) {
        _data.setInt32(_kColorFilterOffset, ColorFilter._TypeNone, _kFakeHostEndian);
        _data.setInt32(_kColorFilterColorOffset, 0, _kFakeHostEndian);
        _data.setInt32(_kColorFilterBlendModeOffset, 0, _kFakeHostEndian);

        if (_objects != null) {
          _objects[_kColorFilterMatrixIndex] = null;
        }
      } else {
        _data.setInt32(_kColorFilterOffset, value._type, _kFakeHostEndian);

        if (value._type == ColorFilter._TypeMode) {
          assert(value._color != null);
          assert(value._blendMode != null);

          _data.setInt32(_kColorFilterColorOffset, value._color.value, _kFakeHostEndian);
          _data.setInt32(_kColorFilterBlendModeOffset, value._blendMode.index, _kFakeHostEndian);
        } else if (value._type == ColorFilter._TypeMatrix) {
          assert(value._matrix != null);

          _objects ??= new List<dynamic>(_kObjectCount);
          _objects[_kColorFilterMatrixIndex] = Float32List.fromList(value._matrix);
        }
      }
    }