RosettaCodeData/Task/Draw-a-clock/Processing-Python-mode/draw-a-clock.processing-py

24 lines
512 B
Plaintext

last_sec = second()
def draw():
global last_sec
if last_sec != second():
draw_clock()
last_sec = second()
def draw_clock():
background(192)
translate(width / 2, height / 2)
s = second() * TWO_PI / 60.0
m = minute() * TWO_PI / 60.0
h = hour() * TWO_PI / 12.0
rotate(s)
strokeWeight(1)
line(0, 0, 0, -width * 0.5)
rotate(-s + m)
strokeWeight(2)
line(0, 0, 0, -width * 0.4)
rotate(-m + h)
strokeWeight(4)
line(0, 0, 0, -width * 0.2)