/** 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] first = true 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. The polygons in Country.frink are sorted so // that the largest polygon is first. Label only the largest. if first { [clong, clat] = polygonCentroid[poly] g.color[0,0,0] [x,y] = Dymaxion.latLongToXY[clat degree, clong degree] g.text[code, x, -y] } first = false } } // 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]