Skip to content

Instantly share code, notes, and snippets.

@latentflip
Created July 21, 2010 13:39
Show Gist options
  • Save latentflip/484493 to your computer and use it in GitHub Desktop.
Save latentflip/484493 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

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