latitudeComparison.frink

Download or view latitudeComparison.frink in plain text format


/** This program allows you to draw multiple country outlines shifted by
    longitude so you can compare how latitudes in each country compare. */


use Country.frink

drawCountry[g is graphics, code, longitudeOffset] :=
{
   countries = Country.getCountryList[]
   country = countries@code
   firstPoly = true
   
   for poly = country.borders
   {
      p = new polygon
      for [x, y] = poly
         p.addPoint[x degrees + longitudeOffset, -y degrees]
      g.add[p]

      // Label first (which will be the largest) polygon
      if firstPoly
      {
         [cx, cy] = p.getCentroid[]
         g.text[code, cx, cy]
         firstPoly = false;
      }
   }

   return g
}

g = new graphics
g.font["SansSerif", 1 degree]
g.drawCountry[g, "US", 0 degrees]
g.drawCountry[g, "DE", -120 degrees]
g.drawCountry[g, "GB", -120 degrees]
g.drawCountry[g, "PL", -120 degrees]
//g.drawCountry[g, "UG", -120 degrees]
g.drawCountry[g, "UA", -120 degrees]
g.drawCountry[g, "JP", -238 degrees]

use Grid.frink
grid = new Grid
grid.color[0,0,0,.2]
grid.makeHorizontalLines[g, 1 degree, true]
grid.color[0,0,0,.3]
grid.makeHorizontalLines[g, 10 degree, false]
grid.color[0,0,0]
grid.makeHorizontalLabels[g, 10 degree, -degree, false]
g.add[grid.getGrid[]]

g.show[]
g.invertGrays[].show[]
g.write["latitudeComparison.png", 1024, 600]
//g.browse["latitudeComparison.png"]


Download or view latitudeComparison.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 20136 days, 5 hours, 2 minutes ago.