createPaint method

Paint createPaint([
  1. double intensity = 1
])

A fill paint in the effect color, or the element's color when the effect has none, at the effect opacity scaled by intensity. With an Effect.endColor it is a gradient across the element.

Implementation

Paint createPaint([double intensity = 1]) {
  if (!intensity.isFinite || intensity < 0 || intensity > 1) {
    throw ArgumentError.value(intensity, 'intensity');
  }
  Color faded(Color color) =>
      color.withValues(alpha: color.a * effect.opacity * intensity);
  final source = adapt((effect.color ?? _elementColor).toColor());
  final paint = Paint()..color = faded(source);
  if (effect.endColor case final end?) {
    paint.color = const Color(0xFFFFFFFF);
    paint.shader = LinearGradient(
      colors: [faded(source), faded(adapt(end.toColor()))],
    ).createShader(_path.getBounds().inflate(effect.width + effect.spread));
  }
  return paint;
}