HourHand.Center.x = 0
HourHand.Center.y = 0
HourHand.Length = 140
HourHand.Shade
= _RGBA(255, 0, 0, 255)MinuteHand.Length = HourHand.Length / phi
MinuteHand.Shade
= _RGBA(0, 255, 0, 255)SecondHand.Length = HourHand.Length / (phi ^ 2)
SecondHand.Shade
= _RGBA(255, 0, 255, 255)
CALL ccircle
(HourHand.HandPosition.x
, HourHand.HandPosition.y
, 5, _RGBA(_RED32(HourHand.Shade
), _GREEN32(HourHand.Shade
), _BLUE32(HourHand.Shade
), 200)) FOR k
= 0 TO 12 * 3600 - (12 * 3) STEP (12 * 3) CALL ccircle
(MinuteHand.HandPosition.x
, MinuteHand.HandPosition.y
, 3, _RGBA(_RED32(MinuteHand.Shade
), _GREEN32(MinuteHand.Shade
), _BLUE32(HourHand.Shade
), 100))
HourHand.Angle = -((TheTime.Hour + (TheTime.Minute / 60)) / 12) * 2 * pi + pi / 2
MinuteHand.Angle = -((TheTime.Minute + (TheTime.Second / 60)) / 60) * 2 * pi + pi / 2
SecondHand.Angle = -(TheTime.Second / 60) * 2 * pi + pi / 2
HourHand.HandPosition.x
= HourHand.Center.x
+ HourHand.Length
* COS(HourHand.Angle
) HourHand.HandPosition.y
= HourHand.Center.y
+ HourHand.Length
* SIN(HourHand.Angle
) MinuteHand.Center.x = HourHand.HandPosition.x
MinuteHand.Center.y = HourHand.HandPosition.y
MinuteHand.HandPosition.x
= MinuteHand.Center.x
+ MinuteHand.Length
* COS(MinuteHand.Angle
) MinuteHand.HandPosition.y
= MinuteHand.Center.y
+ MinuteHand.Length
* SIN(MinuteHand.Angle
) SecondHand.Center.x = MinuteHand.HandPosition.x
SecondHand.Center.y = MinuteHand.HandPosition.y
SecondHand.HandPosition.x
= SecondHand.Center.x
+ SecondHand.Length
* COS(SecondHand.Angle
) SecondHand.HandPosition.y
= SecondHand.Center.y
+ SecondHand.Length
* SIN(SecondHand.Angle
)
CALL ccircle
(SecondHand.HandPosition.x
, SecondHand.HandPosition.y
, 3, SecondHand.Shade
) CALL lineSmooth
(SecondHand.Center.x
, SecondHand.Center.y
, SecondHand.HandPosition.x
, SecondHand.HandPosition.y
, SecondHand.Shade
) CALL ccircle
(MinuteHand.HandPosition.x
, MinuteHand.HandPosition.y
, 3, MinuteHand.Shade
) CALL lineSmooth
(MinuteHand.Center.x
, MinuteHand.Center.y
, MinuteHand.HandPosition.x
, MinuteHand.HandPosition.y
, MinuteHand.Shade
) CALL ccircle
(HourHand.HandPosition.x
, HourHand.HandPosition.y
, 3, HourHand.Shade
) CALL lineSmooth
(HourHand.Center.x
, HourHand.Center.y
, HourHand.HandPosition.x
, HourHand.HandPosition.y
, HourHand.Shade
)
TheTime.Hour = t \ 3600
t = t - TheTime.Hour * 3600
IF (TheTime.Hour
> 12) THEN TheTime.Hour
= TheTime.Hour
- 12 TheTime.Minute = t \ 60
t = t - TheTime.Minute * 60
TheTime.Second = t
'translated from
'https://en.wikipedia.org/w/index.php?title=Xiaolin_Wu%27s_line_algorithm&oldid=852445548
steep
= ABS(y1
- y0
) > ABS(x1
- x0
)
dx = x1 - x0
dy = y1 - y0
gradient = dy / dx
gradient = 1
'handle first endpoint
DIM xend
, yend
, xgap
, xpxl1
, ypxl1
yend = y0 + gradient * (xend - x0)
xgap
= (1 - ((x0
+ .5) - INT(x0
+ .5))) xpxl1 = xend 'this will be used in the main loop
plX = ypxl1
plY = xpxl1
plI
= (1 - (yend
- INT(yend
))) * xgap
plX = ypxl1 + 1
plY = xpxl1
plI
= (yend
- INT(yend
)) * xgap
plX = xpxl1
plY = ypxl1
plI
= (1 - (yend
- INT(yend
))) * xgap
plX = xpxl1
plY = ypxl1 + 1
plI
= (yend
- INT(yend
)) * xgap
intery = yend + gradient 'first y-intersection for the main loop
'handle second endpoint
yend = y1 + gradient * (xend - x1)
xgap
= ((x1
+ .5) - INT(x1
+ .5)) xpxl2 = xend 'this will be used in the main loop
plX = ypxl2
plY = xpxl2
plI
= (1 - (yend
- INT(yend
))) * xgap
plX = ypxl2 + 1
plY = xpxl2
plI
= (yend
- INT(yend
)) * xgap
plX = xpxl2
plY = ypxl2
plI
= (1 - (yend
- INT(yend
))) * xgap
plX = xpxl2
plY = ypxl2 + 1
plI
= (yend
- INT(yend
)) * xgap
'main loop
FOR x
= xpxl1
+ 1 TO xpxl2
- 1 plY = x
plI
= (1 - (intery
- INT(intery
)))
plY = x
plI
= (intery
- INT(intery
))
intery = intery + gradient
FOR x
= xpxl1
+ 1 TO xpxl2
- 1 plX = x
plI
= (1 - (intery
- INT(intery
)))
plX = x
plI
= (intery
- INT(intery
))
intery = intery + gradient
plot:
' Change to regular PSET for standard coordinate orientation.