API Documentation

Getting Started

To get started using orbit.js, you must add the following lines of code to your file:

         
            <script type="text/javascript"
               src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
            </script>
            <script defer type="text/javascript" src="orbit.js"></script>
            <link rel="stylesheet" href="orbit.css">
         
      

API Objects

To create an instance of orbit.js, simply use the following line of code:

         
            const Orbit = new Orbit(width, height, radius, colour);
         
      

The parameter width specifies the position of the width of the sun being orbited. The parameter height specifies the position of the height of the sun being orbited. The parameter radius specifies the radius of the sun being orbited. The parameter colour is optional and specifies the colour of the sun being orbited. When left unspecified, colour will default to orange.



To create an instance of a Planet, simply use the following line of code:

         
            Orbit.makePlanet(speed, colour, radius, orbit, name)
         
      

The parameter speed specifies how fast the planet will orbit the sun. The parameter colour specifies the colour of the planet. The parameter radius specifies the radius of the planet. The parameter orbit specifies the radius that the planet orbits the sun. The parameter name specifies the names of the planet.

API Functions

orbit()

         
            Orbit.orbit(planets);
         
      

The orbit function is called with one argument: planets. Planets is an array of planets that the animation will begin with. Elements in planets can be strings with the names of planets in the solar system. Or they can be Planet objects. If the developer wants the animation to begin with some planets from the solar system, this is done using a string with that planet's name, ex. 'jupiter'. However, if the developer would like the animation to begin with alternate planets, these must be added using makePlanet and pushed to the planets array.

displayPlanets()

         
            Orbit.displayPlanets();
         
      

The displayPlanets function is called with 0 arguments. This function will add a table to the DOM allowing a user to toggle between which planets they want to display. This table will also allow users to remove planets entirely from the list of planets. This table also serves to provide the user with information pertaining to each planet in orbit.

addPlanet()

         
            Orbit.addPlanet();
         
      

The addPlanet function is called with 0 arguments. This function will add input text boxes and a submit button to the DOM allowing the user to add a customized planet to the animation.

planetInfo()

         
            Orbit.planetInfo();
         
      

The planetInfo function is called with 0 arguments. The function will allow the user to hover over the sun object to reveal information about the atmosphere of each planet in the animation. By clicking on the sun, the informational pop-up will cycle through each of the planets being animated.