tnsmap.frink

Download or view tnsmap.frink in plain text format


/** Maps an image of the world onto an icosahedron using the the Buckminster
    Fuller "Dymaxion" icosahedral projection.
*/


use Dymaxion.frink

//img = new image["file:/home/eliasen/Pictures/punkte_auf_karte_clean_2000px.jpg"]
//img = new image["file:/home/eliasen/Pictures/GDEM_elevation_map_3600x1800.png"]
//img = new image["file:earthmap1k.jpg"]
img = new image["file:/home/eliasen/Pictures/4096px-Land_shallow_topo_2048.jpg"]
img = img.resize[4096 div 2,undef]

img.show[]
//img = img.unsharpMask[6,1]  // Optional unsharp mask (also stretches contrast.)
//img.show[]

use /home/eliasen/Pictures/tnscoords.txt
//println[coords]

w = img.getWidth[]
h = img.getHeight[]

longscale = 360 degrees / w
latscale = 180 degrees / h

gr = new graphics
gr.antialiased[false]
gr.font["SansSerif", "bold", 1.5 degree]

stepSize = 1
diameter = 7.6 * stepSize / w

for iy = 0 to h-1 step stepSize
{
   lat = -(iy*latscale) + 90 degrees
   for ix = 0 to w-1 step stepSize
   {
      long = ix*longscale - 180 degrees
      c = img.getPixelAsColor[ix,iy]
      [x,y, tri] = Dymaxion.latLongToXY[lat, long, false]
      gr.color[c]
      gr.fillEllipseCenter[x,-y,diameter,diameter]
   }
}

gr.color[1,1,0,.7]
diameter = 0.015
for [lat,long] = coords
{
   [x,y, tri] = Dymaxion.latLongToXY[lat deg, long deg, false]
   gr.fillEllipseCenter[x,-y,diameter,diameter]
}


insets = 0.985
println["writing..."]
gr.write["tnsmap3.svg", 1000, undef, insets]
gr.write["tnsmap3a.png", 4000, undef, insets]
gr.write["tnsmap3a.jpg", 4000, undef, insets]
gr.show[insets]


Download or view tnsmap.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, eliasen@mindspring.com