Speed up development with full-stack environments for every branch.

Learn More

2D solar system animation using Canvas using Dart2js

1406 Runs 1904 Views 138 Copies


praful 60

published 4 years ago


2D Solar System Simulation

A 2D solar system visualization using Canvas.

You can open the example in Dart Editor and run it by clicking web/solar.html. Or, you can try this live demo.

The solar.dart file contains all the Dart code used in this sample. Two classes, PlanetaryBody and SolarSystem are defined in that file.

The PlanetaryBody class contains the representation of a plantetary body. This class calculates a planetary body's position for a given time index, and then draws it and any child planets.

The SolarSystem class maintains a list of planetary bodies. It knows how to draw the solar system background and the planets. This class uses requestAnimationFrame to redraw the solar system at appropriate time intervals.

Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).