draw method

Future<Image?> draw(
  1. int seed
)

Convert seed into img.Image

Implementation

Future<img.Image?> draw(int seed) async {
  if (imageCache.containsKey(seed)) return imageCache[seed];

  this._seed = seed;
  img.Image? body = await (_getPart("body", _random(min: 1, max: 15)));
  img.Image? fur = await (_getPart("fur", _random(min: 1, max: 10)));
  img.Image? eyes = await (_getPart("eyes", _random(min: 1, max: 15)));
  img.Image? mouth = await (_getPart("mouth", _random(min: 1, max: 10)));
  img.Image? accessorie =
      await (_getPart("accessorie", _random(min: 1, max: 20)));

  if (body == null ||
      fur == null ||
      eyes == null ||
      mouth == null ||
      accessorie == null) return null;

  return imageCache[seed] = img.drawImage(
      img.drawImage(img.drawImage(img.drawImage(body, fur), eyes), mouth),
      accessorie);
}