drawSolarSystem.frink

View or download 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]

for planet = [Planet.Mercury, Planet.Venus, Planet.Earth, Planet.Mars]
for time = now[] to now[] + 2 year step 5 days
{
   [L, B, R] = planet.getCoordinates[time]
   x = R cos[B] cos[L]
   y = R cos[B] sin[L]
   // z = R sin B

   g.color[.2,.2,.2]
   // 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,20 jupiterradius/au, 20 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]


View or download 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 17419 days, 16 hours, 44 minutes ago.