drawMoon method

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

Draws the Moon

Most tweakable params should be accessible in the constants at the top

We draw the moon, offset the earth, around it's rotation The shadow is calculated by looking at the suns position And figuring out the opposite angle.

Implementation

void drawMoon(
    Canvas canvas, Size size, SpaceViewModel viewModel, SpaceConfig config) {
  _imageMap["moon"]?.drawRotatedSquare(
      canvas: canvas,
      size: viewModel.moonSize,
      offset: viewModel.moonOffset,
      rotation: viewModel.moonRotation,
      paint: standardPaint);

  _imageMap["shadow"]?.drawRotatedSquare(
      canvas: canvas,
      size: viewModel.moonSize,
      offset: viewModel.moonOffset,
      rotation: viewModel.sunRotation,
      paint: standardPaint);
}