Celebrating the New Year with Shoes

A bit late for most of the world, but I’ll post it anyways.

Finished cleaning the apartment and waiting for guests to arrive, I thought I’d play around a bit with Shoes. Turns out it’s a lot of fun!

require "time"

midnights = [ [ 5, 'Rio de Janeiro' ],
              [ 4, 'Santiago' ],
              [ 3.5, "St. John's" ],
              [ 3, 'Halifax' ],
              [ 2, 'Montréal' ],
              [ 1, 'Winnipeg' ],
              [ 0, 'Edmonton' ],
              [ -1, 'Vancouver' ],
              [ -2, 'Anchorage' ],
              [ -3, 'Honolulu' ],
              [ -4, 'Auckland' ]  ]

new_year = Time.parse "2008-01-01"

Shoes.app do
  background rgb(0,0,0)

  stack do
    seconds_left = (new_year - Time.now).to_i

    midnight_ps = midnights.map do |offset,place|
      para "#{place}: #{seconds_left - offset * 3600}", :stroke => white
    end

    animate(1) do |i|
      seconds_left = (new_year - Time.now).to_i

      midnight_ps.each_with_index do |p,i|
        offset, place = midnights[i]
        s = seconds_left - offset * 3600

        stroke = s > 0 ? white : gray(90)

        if s.abs < 500
          size = 200
        else
          size = 100_000 / s.abs
        end

        p.replace "#{place}: #{s}", :font => "Arial #{size}px", :stroke => stroke
      end
    end
  end
end
write a reply

this editor supports Markdown.