; CLOCK.ANA -- Clock + tick mark display routines for making spiffy movies.
;	The clock is a little box with a pair of hands and marks for a
;	12-hour clock but no numbers.

SUBR TICS,S,X,Y
; Draws a little scale indicator in the form of a bar with five arcseconds
; marked with tics, the end pair of tics being longer.  S is the image
; scale in arcseconds per pixel.
;
IF !NARG LT 3 THEN Y=16
IF !NARG LT 2 THEN X=100
IF !NARG LT 1 THEN READ,'Scale (arcsec/pixel)',S
FOR I=0,5 {XX=FIX(X+I/S+.5) YY=Y+5
    IF I EQ 0 OR I EQ 5 THEN YY=Y+8
    xymov,XX,Y,0 xymov,XX,YY,1}
xymov,X,Y,0 xymov,X+5/S,Y,1
END

; For the clock display routines, the parameters X, Y and S are the positions
; of the center of the clock on the display and the size of the clock, all in
; pixels.

SUBR ERACLOCK,I,X,Y,S
; Erases the clock display and provides the background square.  I is the 
; intensity to use for the background.
IF !NARG LT 4 THEN S=25.0
IF !NARG LT 3 THEN Y=25
IF !NARG LT 2 THEN X=25
IF !NARG LT 1 THEN I=50
SIZ=FIX(S*2+1.5)
E=BYTE(ZERO(INTARR(SIZ,SIZ))+I)
TV,E,X-S,!iyhigh-(Y+S)
RETURN
END


SUBR TVCLOCK,X,Y,S
; Draws the face of the clock.
IF !NARG LT 3 THEN S=25.0
IF !NARG LT 2 THEN Y=25
IF !NARG LT 1 THEN X=25
SM=.8
FOR P=0,11 {
    ANG=2*#PI*P/12.
    xymov, FIX(X+SIN(ANG)*S+.5), FIX(Y+COS(ANG)*S+.5) ,0
    xymov, FIX(X+SIN(ANG)*S*SM+.5), FIX(Y+COS(ANG)*S*SM+.5) ,1
}
RETURN
END


SUBR TVTIME,SEC,X,Y,S
; Draws the hands of the clock for a specific time, given in seconds (SEC).
IF !NARG LT 4 THEN S=25.0
IF !NARG LT 3 THEN Y=25
IF !NARG LT 2 THEN X=25
SH=2*#PI*SEC/60.
MH=SH/60.
HH=MH/12.
xymov,FIX(X+SIN(MH)*S+.5),FIX(Y+COS(MH)*S+.5),0
xymov,FIX(X+.5),FIX(Y+.5),1
xymov,FIX(X+SIN(HH)*S/2+.5),FIX(Y+COS(HH)*S/2+.5),1
RETURN
END
