Skip to content

Instantly share code, notes, and snippets.

@hannahherbig
Created December 4, 2011 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannahherbig/1428985 to your computer and use it in GitHub Desktop.
Save hannahherbig/1428985 to your computer and use it in GitHub Desktop.
polar clock in Shoes
def helper from_edge, number
twopi = Shoes::TWO_PI
angle1 = twopi / 4 * 3
angle2 = (angle1 + number * twopi) % twopi
width = @clock.width
radius = width - from_edge * 2
arc width / 2, width / 2, radius, radius, angle1, angle2
end
Shoes.app title: "Polar Clock", width: 500, height: 500, resizable: false do
# some neat little options, click on the window to toggle whether or not
# they're shown
# spokes: draw spokes?
# c24: use 24 hours instead of 12?
@checks = flow do
@spokes, @c24 = check, check
end
@checks.toggle
click { @checks.toggle }
@clock = flow top: 0, left: 0, width: 500, height: 500
animate 20 do
@clock.clear do
r = @clock.width / 2
hr = @c24.checked? ? 24 : 12
if @spokes.checked?
nofill
strokewidth 1
star r, r, hr, r, 0
end
nofill
strokewidth 20
now = Time.now
time = now.to_f + now.utc_offset
helper 25 * 1, time / 60 / 60 % hr / hr
helper 25 * 2, time / 60 % 60 / 60
helper 25 * 3, time % 60 / 60
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment