recolor method

Future<BeautifulPopup> recolor(
  1. Color color
)

Recolor the BeautifulPopup. This method is kind of slow.R

Implementation

Future<BeautifulPopup> recolor(Color color) async {
  this.primaryColor = color;
  final illustrationData = await rootBundle.load(instance.illustrationKey);
  final buffer = illustrationData.buffer.asUint8List();
  img.Image? asset;
  asset = img.readPng(buffer);
  if (asset != null) {
    img.adjustColor(
      asset,
      saturation: 0,
      // hue: 0,
    );
    img.colorOffset(
      asset,
      red: color.red,
      // I don't know why the effect is nicer with the number ╮(╯▽╰)╭
      green: color.green ~/ 3,
      blue: color.blue ~/ 2,
      alpha: 0,
    );
  }
  final paint = await PaintingBinding.instance?.instantiateImageCodec(
      asset != null ? Uint8List.fromList(img.encodePng(asset)) : buffer);
  final nextFrame = await paint?.getNextFrame();
  _illustration = nextFrame?.image;
  return this;
}