drawSun method

void drawSun(
  1. Canvas canvas,
  2. Size size,
  3. SpaceViewModel viewModel,
  4. SpaceConfig config,
)

Draw the Sun

We have 4 Layers, we can draw them 8 times (flipped once) to increase randomness

The layers are Blended/Transformed based on the kernels/arrays in the config This was just experimented with until I liked the way it looks

The idea was to have it look bright and gaseous, with the occasional sunspot

Implementation

void drawSun(
    Canvas canvas, Size size, SpaceViewModel viewModel, SpaceConfig config) {
  sunBasePaint.shader = config.sunGradient.createShader(Rect.fromCircle(
      center: viewModel.sunOffset, radius: viewModel.sunBaseRadius));

  canvas.drawCircle(
      viewModel.sunOffset, viewModel.sunBaseRadius, sunBasePaint);

  //We are going to go through layers 1-3 twice, once flipped
  for (final layer in config.sunLayers) {
    sunLayerPaint.blendMode = layer.mode;
    _imageMap[layer.image]?.drawRotatedSquare(
        canvas: canvas,
        size: viewModel.sunSize,
        offset: viewModel.sunOffset,
        rotation: viewModel.sunRotation * layer.speed,
        paint: sunLayerPaint,
        flip: layer.flipped);
  }
}