mapDymaxion.frink

Download or view mapDymaxion.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

// Download maps from  http://planetpixelemporium.com/planets.html
img = new image["file:mars_1k_color.jpg"]
//img = new image["file:earthmap1k.jpg"]
//img = new image["file:jupitermap.jpg"]
//img = new image["file:uranusmap.jpg"]

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

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

gr = new graphics
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.write["mars1.svg", 1000, 500]
gr.write["mars1.png", 4000, 2000]
gr.write["mars1.jpg", 4000, 2000]
gr.show[]


Download or view mapDymaxion.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 19972 days, 6 hours, 17 minutes ago.