【 tulaoshi.com - ASP 】
下面的代码是调用的DirectX的组件实现的时钟。它有三根指针,会实时地随系统时间的改变而改变。
不过我没有做刻度,因为我觉得用程序画出来的刻度不漂亮,用PHOTOSHOP画一口钟作为背景要漂亮多了。
<html
<head
<title指针式时钟</title
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
</head
<body bgcolor="#FFFFFF" text="#000000"
<div id="LayClock" style="position:absolute; width:101; height:101px; z-index:2; left: 203px; top: 101px"
<object id="DAControl" width=101 height=101 align=LEFT hspace=0
classid="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D"
</object
<SCRIPT LANGUAGE="VBScript"
<!--
Set m = DAControl.PixelLibrary
pi = 3.14159265359
Sub window_onLoad
a = time
min1 = minute(time)
hr1 = hour(time)
sec1 = second(time)
Set xPos = m.Mul(m.DANumber(150), m.Cos(m.Mul(m.LocalTime,m.DANumber(0.3))))
Set yPos = m.Mul(m.DANumber(35), m.Cos(m.Mul(m.LocalTime,m.DANumber(0.5))))
Set clock = m.Overlay(hands(hr1,min1,sec1),hands(hr1,min1,sec1))
DAControl.Image = clock
DAControl.Start
End Sub
Function hands(hr,min,sec)
Set bvr60 = m.DANumber(60)
Set secFromMidnight = m.Add(m.DANumber(hr*3600+min*60+sec),m.LocalTime)
Set secBvr = m.Mod(secFromMidnight,bvr60)
Set minBvr = m.Mod(m.Div(secFromMidnight,bvr60),bvr60)
Set hrBvr = m.Mod(m.Div(secFromMidnight,m.DANumber(3600)),m.DANumber(12))
ptsSec = Array( -10, -2, 42, -1, 42, 1, -10,2 )
ptsMin = Array(-7, -2, 36, -1, 36, 1, -7, 2 )
ptsHr = Array(-5, -3, 32, -1, 32, 1, -5, 3 )
Set temp1 = m.Mul(m.DANumber(-pi/30),m.Sub(secBvr,m.DANumber(15)))
Set temp2 = m.Mul(m.DANumber(-pi/30),m.Sub(minBvr,m.DANumber(15)))
Set temp3 = m.Mul(m.DANumber(-pi/6),m.Sub(hrBvr,m.DANumber(3)))
Set imgSec = m.PolyLine(ptsSec).Fill(m.DefaultLineStyle,m.SolidColorImage(m.cyan))
Set imgSec = imgSec.TransForm(m.Rotate2Anim(temp1))
Set imgMin = m.PolyLine(ptsMin).Fill(m.DefaultLineStyle,m.SolidColorImage(m.yellow))
Set imgMin = imgMin.TransForm(m.Rotate2Anim(temp2))
Set imgHr = m.PolyLine(ptsHr).Fill(m.DefaultLineStyle,m.SolidColorImage(m.green))
Set imgHr = imgHr.TransForm(m.Rotate2Anim(temp3))
Set hands = m.Overlay(imgSec,m.Overlay(imgMin,imgHr))
End Function
--
</SCRIPT</div
</body
</html