shadowRect static method

Image shadowRect(
  1. double width,
  2. double height,
  3. double spreadRadius,
  4. double blurRadius,
  5. PdfColor color,
)

Implementation

static im.Image shadowRect(
  double width,
  double height,
  double spreadRadius,
  double blurRadius,
  PdfColor color,
) {
  final shadow = im.Image(
    width: (width + spreadRadius * 2).round(),
    height: (height + spreadRadius * 2).round(),
    format: im.Format.uint8,
    numChannels: 4,
  );

  im.fillRect(
    shadow,
    x1: spreadRadius.round(),
    y1: spreadRadius.round(),
    x2: (spreadRadius + width).round(),
    y2: (spreadRadius + height).round(),
    color: im.ColorUint8(4)
      ..r = color.red * 255
      ..g = color.green * 255
      ..b = color.blue * 255
      ..a = color.alpha * 255,
  );

  return im.gaussianBlur(shadow, radius: blurRadius.round());
}