drawSolarSystem.frink

Download or view drawSolarSystem.frink in plain text format


// This program draws the current position of planets in the solar system,
// with necessary exaggerated scale.

use planets.frink

time = now[]

g = new graphics

//g.backgroundColor[0,0,.3]

g.color[.5,.5,.5]
// Draw the sun (20 times normal size)
g.fillEllipseCenter[0,0,20 sunradius/au, 20 sunradius/au]

time = now[]
for planet = Planet.planets
{   
   [L, B, R] = planet.getCoordinates[time]
   x = R cos[B] cos[L]
   y = R cos[B] sin[L]
   // z = R sin B

   g.color[.5,.5,.5]
   // Draw approximation of orbit
   g.drawEllipseCenter[0,0,2 R/au,2 R/au]

   // Draw planets (each 20 times bigger than Jupiter, and that's still not
   // nearly enough, so make an even bigger circle around them.)
   g.color[0,0,0]
   //g.text[planet.getName[], x/au, y/au]
   g.fillEllipseCenter[x/au,y/au,10 jupiterradius/au, 10 jupiterradius/au]
   g.drawEllipseCenter[x/au,y/au,200 jupiterradius/au, 200 jupiterradius/au]

   if planet == Planet.Earth
   {
      g.color[0,0,1,.5]
      g.fillEllipseCenter[x/au,y/au,2 * .34 au/au, 2 * .34 au/au]
   }
}
g.show[]
g.print[]
//g.write["planetBackground.png",1024,768]
g.write["planetBackground.svg",2048,undef]


Download or view drawSolarSystem.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20218 days, 0 hours, 18 minutes ago.