Analog Clock

Post Reply
Raspberrypi
Posts: 6
Joined: Thu Jun 30, 2016 9:43 pm
My devices: iPad
Flag: United States of America

Analog Clock

Post by Raspberrypi »

A Clock program i made back in july
I think ot won't show well on a phone though since i programmed it on an iPad Air lol

Code: Select all

OPTION ANGLE DEGREES
DATA 0, "XII", 30, "I", 60, "II", 90, "III", 120, "IV", 150, "V", 180, "VI", 210, "VII", 240, "VIII", 270, "IX", 300, "X", 330, "XI"
init:
GET ORIENTATION p
OPTION TEXT POS CENTRAL
cu = p
LET middle.x = SCREEN_WIDTH()/2 ! LET middle.y = SCREEN_HEIGHT()/2
GRAPHICS
SHADOW ON
REFRESH OFF
LOOP:
RESTORE
GRAPHICS CLEAR 1, 1, 1
drawClock:
DRAW COLOR 0, 0, 0
DRAW SIZE 4
DRAW CIRCLE middle.x, middle.y SIZE 300
DRAW CIRCLE middle.x, middle.y SIZE 5
DO 
READ a, b$ 'get angle and label
x = middle.x + COS(a - 90) * 270
y = middle.y + SIN(a - 90) * 270
DRAW FONT SIZE 25
DRAW TEXT b$ AT x, y
UNTIL NOT DATA_EXIST() 
LET a.sec = CURRENT_SECOND() * 6 
LET a.minute = CURRENT_MINUTE() * 6
LET a.hour = CURRENT_HOUR() * 30
DRAW COLOR 1, 0, 0
DRAW LINE middle.x, middle.y TO middle.x + COS(a.sec - 90) * 250, middle.y + SIN(a.sec - 90) * 250
DRAW COLOR 0.1, 0.1, 0.6
DRAW LINE middle.x, middle.y TO middle.x + COS(a.minute - 90) * 250, middle.y + SIN(a.minute - 90) * 250
DRAW COLOR 0.3, 0.3, 0.3
DRAW LINE middle.x, middle.y TO middle.x + COS(a.hour - 90) * 180, middle.y + SIN(a.hour - 90) * 180
printTime:
DRAW FONT SIZE 20
DRAW COLOR 0.3, 0.3, 0.3
DRAW TEXT CURRENT_HOUR() AT middle.x - 40, SCREEN_HEIGHT() - 40
DRAW COLOR 0, 0, 0
DRAW TEXT " : " AT middle.x - 20, SCREEN_HEIGHT() - 40
DRAW COLOR 0.1, 0.1, 0.6
DRAW TEXT CURRENT_MINUTE() AT middle.x , SCREEN_HEIGHT() - 40
DRAW COLOR 0, 0, 0
DRAW TEXT " : " AT middle.x + 20, SCREEN_HEIGHT() - 40
DRAW COLOR 1, 0, 0
DRAW TEXT CURRENT_SECOND() AT middle.x + 40, SCREEN_HEIGHT() - 40
checkOrientation:
GET ORIENTATION x
IF x <> cu THEN ! GOTO init ! ENDIF
REFRESH
GOTO LOOP 

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Analog Clock

Post by Henko »

I think you should make a small modification to get a real clock:

LET a.hour = CURRENT_HOUR() * 30 + CURRENT_MINUTE()/2

Post Reply