Last active
August 29, 2015 13:57
-
-
Save rthbound/7c16483b13eaac87a3c5 to your computer and use it in GitHub Desktop.
Make a gif of the Moon as seen from Earth for one lunar year, starting now - http://gfycat.com/SilverPositiveBluet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "usno/imagery" | |
require "open-uri" | |
require "RMagick" | |
include Magick | |
def animate(n,f) | |
i=0 | |
time = Time.now | |
1.upto(n).to_a.map {|t| time + (t * f * 60 * 60) }.map {|x| USNO::Imagery::Moon.new(time: x).call.data }.each do |url| | |
i += 1 | |
open(i.to_s + "_image.png", 'wb') do |file| | |
file << open(url).read | |
end | |
end | |
ImageList.new(*1.upto(n).to_a.map(&:to_s).map {|x| "#{x}_image.png" }).write("animated_moon.gif") | |
end | |
# A "Lunar year" is about 355 days, we want 1 image per day | |
animate(355, 24) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Our moon
Mars seen from earth
Other options - https://github.com/rthbound/usno-imagery#usage