drawDymaxion.frink

View or download drawDymaxion.frink in plain text format


/** Draws the countries of the world using the Buckminster Fuller "Dymaxion"
    icosahedral projection.
*/


use Country.frink
use geometry.frink
use Dymaxion.frink

g = new graphics
g.stroke[0.1 degree]
g.font["SansSerif", "bold", 1.5 degree]

for [code, country] = Country.getCountryList[]
{
   cc = new color[randomFloat[0,1], randomFloat[0,1], randomFloat[0,1], .8]
   
   for poly = country.borders
   {
      p = new filledPolygon
      pl = new polyline
      for [long, lat] = poly
      {
         [x,y, tri] = Dymaxion.latLongToXY[lat degree, long degree]
         p.addPoint[x,-y]
         p.addPoint[x,-y]
      }

      g.color[cc]
      g.add[p]
      g.color[0,0,0,0.5]
      g.add[pl]
      

      // Draw country names.
      [clong, clat] = polygonCentroid[poly]
      g.color[0,0,0]
      [x,y] = Dymaxion.latLongToXY[clat degree, clong degree]
      g.text[code, x, -y]
   }
}


// Draw the numbers of the "triangles" used in the projection.
/*g.font["SansSerif" , 2 deg]
for lat = -90 deg to 90 deg step 10 deg
   for long = -180 deg to 180 deg step 10 deg
   {
      [x,y,tri] = Dymaxion.latLongToXY[lat, long]
      text=format[lat,deg,0] + "," + format[long,deg,0]
      g.text[tri,x,-y]
   }
*/


// Draw lines of latitude
/*
g.color[0.5, 0.5, 0.5, 0.5]   
for lat = -90 deg to 90 deg step 10 deg
{
   p = new polyline
   lasttri = 0
   for long = -180 deg to 180 deg step 1 deg
   {
      [x,y,tri,lcd] = Dymaxion.latLongToXY[lat, long]
      text=format[lat,deg,0] + "," + format[long,deg,0]
      if (lasttri == tri)
         p.addPoint[x,-y]
      else
      {
         g.add[p]
         p = new polyline
      }
      lasttri = tri
   }
   g.add[p]
}
   
// Draw lines of longitude
g.color[0.5, 0.5, 0.5, 0.5]   
for long = -180 deg to 180 deg step 10 deg
{
   p = new polyline
   lasttri = 0
   for lat = -90 deg to 90 deg step 1 deg
   {
      [x,y,tri,lcd] = Dymaxion.latLongToXY[lat, long]
      text=format[lat,deg,0] + "," + format[long,deg,0]
      if (lasttri == tri)
         p.addPoint[x,-y]
      else
      {
         g.add[p]
         p = new polyline
      }
      lasttri = tri
   }
   g.add[p]
} */


g.show[]
//g.write["world.svg", 1000, 500]
g.write["world.png", 1000, 500]


View or download drawDymaxion.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 17590 days, 6 hours, 55 minutes ago.