Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
95
Task/Draw-a-clock/Amazing-Hopper/draw-a-clock.hopper
Normal file
95
Task/Draw-a-clock/Amazing-Hopper/draw-a-clock.hopper
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
Execute with:
|
||||
$ hopper jm/clock.jambo -x -o bin/clock
|
||||
$ rxvt -g 500x250 -fn "xft:FantasqueSansMono-Regular:pixelsize=1" -e ./bin/clock
|
||||
*/
|
||||
|
||||
#include <jambo.h>
|
||||
|
||||
#define ONESECOND 1000
|
||||
|
||||
Main
|
||||
Cls
|
||||
xp=120, yp=160, size=100, hs=0,ms=0,ss=0, w=0, PI_12=0, PI_60=0
|
||||
|
||||
lasth=0, lastm=0, lasts=0, lasttime=0
|
||||
Let (hs:=Mul(0.45, size)), Let (ms:=Mul(0.75,size)), Let (ss:=ms)
|
||||
Let (PI_12:= Div(M_PI,12))
|
||||
Let (PI_60:= Div(M_PI,60))
|
||||
|
||||
Color back '14'
|
||||
Gosub 'Draw body clock'
|
||||
|
||||
Tic ( last time )
|
||||
Loop
|
||||
On time ( ONE SECOND ~= last time ){
|
||||
Gosub 'draw clock'
|
||||
}
|
||||
Until ( Keypressed )
|
||||
End
|
||||
|
||||
Subrutines
|
||||
|
||||
Define 'draw clock'
|
||||
h=0, m=0,s=0, t=0
|
||||
Get only time, Move to 't'
|
||||
Hours(t), Minutes(t), Seconds(t), Move to 'h, m, s'
|
||||
|
||||
Color back '0'
|
||||
Draw a line (xp, yp, #(xp+(hs*sin(d2r(lasth)))), \
|
||||
#(yp+(hs*cos(d2r(lasth)))) )
|
||||
Draw a line (#(xp-1), #(yp-1), #(xp+(hs*sin(d2r(lasth)))),\
|
||||
#(yp+(hs*cos(d2r(lasth)))) )
|
||||
Draw a line (#(xp+1), #(yp+1), #(xp+(hs*sin(d2r(lasth)))),\
|
||||
#(yp+(hs*cos(d2r(lasth)))) )
|
||||
|
||||
Draw a line (xp, yp, #(xp+(ms*sin(d2r(lastm)))), \
|
||||
#(yp+(ms*cos(d2r(lastm)))) )
|
||||
Draw a line (#(xp-1), #(yp-1), #(xp+(ms*sin(d2r(lastm)))),\
|
||||
#(yp+(ms*cos(d2r(lastm)))) )
|
||||
|
||||
Draw a line (xp, yp, #(xp+(ss*sin(d2r(lasts)))), \
|
||||
#(yp+(ss*cos(d2r(lasts)))) )
|
||||
|
||||
Let ( lasts := #(s*6-90) )
|
||||
Let ( lastm := #(m*6-90) )
|
||||
Let ( lasth := #((h * 30)+(m/12)*6-90) )
|
||||
|
||||
Color back '15'
|
||||
Draw a line (xp, yp, #(xp+(hs*sin(d2r(lasth)))), \
|
||||
#(yp+(hs*cos(d2r(lasth)))) )
|
||||
Draw a line (#(xp-1), #(yp-1), #(xp+(hs*sin(d2r(lasth)))),\
|
||||
#(yp+(hs*cos(d2r(lasth)))) )
|
||||
Draw a line (#(xp+1), #(yp+1), #(xp+(hs*sin(d2r(lasth)))),\
|
||||
#(yp+(hs*cos(d2r(lasth)))) )
|
||||
|
||||
Color back '3'
|
||||
Draw a line (xp, yp, #(xp+(ms*sin(d2r(lastm)))),\
|
||||
#(yp+(ms*cos(d2r(lastm)))) )
|
||||
Draw a line (#(xp-1), #(yp-1), #(xp+(ms*sin(d2r(lastm)))),\
|
||||
#(yp+(ms*cos(d2r(lastm)))) )
|
||||
|
||||
Color back '13'
|
||||
Draw a line (xp, yp, #(xp+(ss*sin(d2r(lasts)))), \
|
||||
#(yp+(ss*cos(d2r(lasts)))) )
|
||||
Return
|
||||
|
||||
Define 'Draw body clock'
|
||||
Draw a circle ( xp, yp, size )
|
||||
Draw a circle ( xp, yp, {size} Minus '5' )
|
||||
|
||||
/* hour circles ticks*/
|
||||
Loop for( i=1, #( i<=12), ++i )
|
||||
Let (w:=#(2*i*PI_12))
|
||||
Loop for ( j=5, #(j>0), --j )
|
||||
Draw a circle ( #(xp+size*sin(w)), #(yp+size*cos(w)), j )
|
||||
Next
|
||||
Next
|
||||
|
||||
/* minutes ticks */
|
||||
Loop for ( i=1, #( i<=60), ++i )
|
||||
Let (w:=#(2*i*PI_60))
|
||||
Draw a line ( #(xp+(size-20)*sin(w)), #(yp+(size-20)*cos(w)),\
|
||||
#(xp+(size-10)*sin(w)), #(yp+(size-10)*cos(w)))
|
||||
Next
|
||||
Return
|
||||
Loading…
Add table
Add a link
Reference in a new issue