drawSpace method

void drawSpace(
  1. Canvas canvas,
  2. Size size
)

drawSpace

Draws everything in space Psuedo: Calculate Orbital Rotations Draw the Background Draw the Stars Draw the Sun Draw the Earth Draw the Moon

Implementation

void drawSpace(Canvas canvas, Size size) {
  final time = spaceClockTime;
  final config =
      overrideTheme ?? (isDark ? darkSpaceConfig : lightSpaceConfig);

  final viewModel = SpaceViewModel.of(time, config, size);

  // Draw the various layers, back to front
  drawBackground(canvas, size, viewModel);
  drawStars(canvas, size, viewModel.backgroundRotation,
      time.millisecondsSinceEpoch / 1000.0);

  if (showSun) drawSun(canvas, size, viewModel, config);

  //We draw the moon behind for the "top" pass of the circle
  if (time.second < 15 || time.second > 45) {
    if (showMoon) drawMoon(canvas, size, viewModel, config);
    if (showEarth) drawEarth(canvas, size, viewModel, config);
  } else {
    if (showEarth) drawEarth(canvas, size, viewModel, config);
    if (showMoon) drawMoon(canvas, size, viewModel, config);
  }
}