Created
December 4, 2011 03:02
-
-
Save hannahherbig/1428985 to your computer and use it in GitHub Desktop.
polar clock in Shoes
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
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