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,1000 jupiterradius/au, 1000 jupiterradius/au]
   g.drawEllipseCenter[x/au,y/au,200 jupiterradius/au, 200 jupiterradius/au]
}
g.show[]
g.print[]
//g.write["planetBackground.png",1024,768]
//g.write["planetBackground.svg",1024,768]


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 19945 days, 15 hours, 48 minutes ago.