05-19-2017, 09:53 PM

Moire Happy Times!

Code:

`' Moire Flower Clock.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-19`

' The Moire Flower Series Meets Analog clock 2017-04-27 [B+=MGA]

' Public Domain

randomize timer

const x0 = xmax/2

const y0 = ymax/2

const cr = y0/2

d = 1 : n = 12

while 1

cls

for i = 1 to n

cx = x0 + ymax/4*cos(i*2*pi/n-pi/2)

cy = y0 + ymax/4*sin(i*2*pi/n-pi/2)

cx2 = x0 + (ymax/4-r)*cos(i*2*pi/n-pi/2)

cy2 = y0 + (ymax/4-r)*sin(i*2*pi/n-pi/2)

for a = 0 to ymax/4 step 10

circle cx, cy, a color rgb(225, 100, 100)

circle cx2,cy2, a color rgb(128, 0, 40)

next

next

timehms timer, hour, mint, ssec

hours = hour+(mint/60)

if ( hours > 12 ) then hours -= 12

ha = hours *(2*PI)/12 : drawHand ha, cr * 0.5

ma = mint *(2*PI)/60 : drawHand ma, cr * 0.75

sa = ssec *(2*PI)/60 : drawHand sa, cr

circle x0, y0, 2, 1, 0

showpage

delay 40

r += d

if r > ymax/4 then r = ymax/5 : d *= -1

if r < 0 then r = 0 : d *= -1

wend

sub drawHand(a, r)

dim h()

rr = 1/r * 900

h << x0 + r * cos(a-pi/2) : h << y0 + r * sin(a-pi/2)

h << x0 + rr * cos(a) : h << y0 + rr * sin(a)

h << x0 + 3*rr * cos(a+pi/2) : h << y0 + 3*rr * sin(a+pi/2)

h << x0 + rr * cos(a+pi) : h << y0 + rr * sin(a+pi)

h << x0 + r * cos(a-pi/2) : h << y0 + r * sin(a-pi/2)

color 15 : drawpoly h filled : color 0 : drawpoly h

end

B += x