Skip to content

Instantly share code, notes, and snippets.

@morganp
Forked from latentflip/meta-clock.rb
Created July 21, 2010 13:44
Show Gist options
  • Save morganp/484498 to your computer and use it in GitHub Desktop.
Save morganp/484498 to your computer and use it in GitHub Desktop.
center = [500,500]
radius = 500
height = 100
width = 100
num_edge = 50
num_hour = 10
num_min = 10
length_hour = 300
length_min = 400
(0...num_edge).each do |num|
angle = num*((2.0*Math::PI)/num_edge)
y = center[1] + radius*Math::sin(angle)
x = center[0] + radius*Math::cos(angle)
geom = " -geometry #{width}x#{height}+#{x.to_i}+#{y.to_i} -bg HotPink &"
open("| xclock #{geom}")
end
height = 75
width = 75
(0...num_hour).each do |num|
hour = Time.now.hour % 12
angle = hour * ((2.0*Math::PI)/11)
y = center[1] + (Float(num)/num_hour)*length_hour*Math::sin(angle - Math::PI/2)
x = center[0] + (Float(num)/num_hour)*length_hour*Math::cos(angle - Math::PI/2)
geom = " -geometry #{width}x#{height}+#{x.to_i}+#{y.to_i} -bg RoyalBlue &"
open("| xclock #{geom}")
end
(0...num_min).each do |num|
min = Time.now.min
angle = min * ((2.0*Math::PI)/59)
y = center[1] + (Float(num)/num_min)*length_min*Math::sin(angle - Math::PI/2)
x = center[0] + (Float(num)/num_min)*length_min*Math::cos(angle - Math::PI/2)
geom = " -geometry #{width}x#{height}+#{x.to_i}+#{y.to_i} -bg Tomato &"
open("| xclock #{geom}")
end
@morganp
Copy link
Author

morganp commented Jul 21, 2010

Totally forking this crazy fractal clock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment