| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 13785 人关注过本帖
标题:刚做的不用图片的时钟
只看楼主 加入收藏
jwi
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-11-3
收藏
得分:0 
呵呵,真厉害!有些地方确实是挺复杂的,先考下来 慢慢研究吧!以后再多弄点复杂的哦!我支持啊!
2006-11-03 08:59
MicroSoft
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:2
帖 子:499
专家分:3
注 册:2006-10-12
收藏
得分:0 

<html xmlns:v="urn:schemas-microsoft-com:vml">
<script defer>
function clock () {
var nowtime=new Date()
nowhour=nowtime.getHours()
if (nowhour>=12)
nowhour-=12
nowminute=nowtime.getMinutes()
nowsecond=nowtime.getSeconds()
nowmill=nowtime.getMilliseconds()
var harc,marc,sarc,mmarc
harc=(nowhour+nowminute/60+nowsecond/3600+nowmill/3600000)*30
marc=(nowminute+nowsecond/60+nowmill/60000)*6
sarc=(nowsecond+nowmill/1000)*6
//角度的字符串
nh=(180-harc)*Math.PI/180<!--将当前时针的角度换算成弧度-->
harcT=Math.sin(nh)*250+500 <!--250和下面的350,400是用来表示指针的长短的-->
<!--在此以当前系统时间来“纠正”时针箭头热点的Y向位置(即距离top的位置)。500表示平移到规定的“500,500”圆点上。-->
harcL=Math.cos(nh)*250+500
<!--在此以当前系统时间来“纠正”时针箭头热点我的X向位置(即距离Left的位置)。500表示平移到规定的“500,500”圆点上。-->
harcStr=harcT+","+harcT<!--得到由当前时间映射的时针箭头处热点的坐标(harcT,harcT)-->
document.all.hourline.to.value=harcStr
<!--将(harcT,harcT)赋值给hourline的TO,即箭头热点。并通过document来显示在客户端的BROWER上。-->
<!--下面的分针和秒针原理相同。-->
<!--在不断的“纠正”中,显示就永远的和系统时间一样了-->
//分钟的字符串
nm=(180-marc)*Math.PI/180
marcT=Math.sin(nm)*350+500
marcL=Math.cos(nm)*350+500
marcStr=marcT+","+marcL
document.all.minuteline.to.value=marcStr
//秒的字符串
sm=(180-sarc)*Math.PI/180
sarcT=Math.sin(sm)*400+500
sarcL=Math.cos(sm)*400+500
sarcStr=sarcT+","+sarcL
document.all.secondline.to.value=sarcStr
document.all.txt.innerHTML="现在时间是:"+nowtime.getHours()+":"+nowtime.getMinutes()+":"+nowtime.getSeconds()
setTimeout("clock()","50")
}
</script>
<STYLE>
v\:* { Behavior: url(#default#VML) }
</STYLE>
<body onLoad="clock()"><v:group id="clock" Coordsize="1000,1000" style="width:200;height:200;position:relative">
<v:Oval id="outercircle" style="width:1000;height:1000;z-index:10;" fillcolor="gray" />
<v:oval id="innercircle" style="position:relative;top:75;left:75;width:850;height:850;z-index:15" fillcolor="white" />
<v:line id="hourline" style="position:relative;z-index:20" from="500,500" to="800,800" strokeColor="gray">
<!--初始化时针位置,两点“500,500”和“800,800”确定一条直线-->
<v:stroke startarrow="oval" endarrow="classic" dashstyle="Dot" strokeColor="red" />
</v:line>
<v:line id="minuteline" style="position:relative;z-index:20" from="500,500" to="500,900" strokeColor="black">
<!--//初始化分针位置,两点“500,500”和“500,200”确定一条直线。-->
<v:stroke endarrow="classic" dashstyle="Dot"/>
</v:line>
<v:line id="secondline" style="position:relative;z-index:20" from="500,500" to="400,900" strokeColor="black"> <!--//初始化秒针位置,两点“500,500”和“400,900”确定一条直线。-->
<v:stroke endarrow="classic" dashstyle="Dot"/>
</v:line>
<span style="position:relative;top:0;left:92;z-index:25">12</span>
<!--这几条语句是确定表面的数字位置的。不过 楼主确定的好象不是很正,从分针初始化的位置看的出来,初始化的分针是垂线。我来修改一下,望楼主原谅我的不知天高地厚-->
<span style="position:relative;top:92;left:169;z-index:25">3</span>
<span style="position:relative;top:186;left:58;z-index:25">6</span>
<span style="position:relative;top:93;left:-40;z-index:25">9</span>
<v:/group>
<div id=txt style="position:relative;top:220;left:40;border:1px solid black;font-size:12px;width:125;padding:3px"></div><!--通过ID关联将时间一数字形式现在在这里-->
</body>
</html>


[此贴子已经被作者于2006-11-3 9:08:00编辑过]


[glow=255,green,2]相信微软,相信我!~[/glow]
2006-11-03 09:07
MicroSoft
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:2
帖 子:499
专家分:3
注 册:2006-10-12
收藏
得分:0 

好象时间不是很准确啊

图片附件: 游客没有浏览图片的权限,请 登录注册

[此贴子已经被作者于2006-11-3 9:11:15编辑过]


[glow=255,green,2]相信微软,相信我!~[/glow]
2006-11-03 09:09
食恶不色
Rank: 2
等 级:新手上路
威 望:3
帖 子:632
专家分:5
注 册:2006-11-8
收藏
得分:0 

46楼的代码有一点错误!!!
我用红色标出!!!
本人也是新手!!!希望大家以后多多关照啊!

前面已经有位朋友(kelehai)解释了部分的代码
我用蓝体字<!--说明-->来做个补充我学过几天的C++
也做过几天的网站
有不正确的地方望各位不吝赐教!

<html xmlns:v="urn:schemas-microsoft-com:vml">
<script defer>
function clock () {
var nowtime=new Date()
nowhour=nowtime.getHours()
if (nowhour>=12)
nowhour-=12
nowminute=nowtime.getMinutes()
nowsecond=nowtime.getSeconds()
nowmill=nowtime.getMilliseconds()
var harc,marc,sarc,mmarc
harc=(nowhour+nowminute/60+nowsecond/3600+nowmill/3600000)*30
marc=(nowminute+nowsecond/60+nowmill/60000)*6
sarc=(nowsecond+nowmill/1000)*6
//角度的字符串
nh=(180-harc)*Math.PI/180<!--将当前时针的角度换算成弧度-->
harcT=Math.sin(nh)*250+500 <!--250和下面的350,400是用来表示指针的长短的-->
<!--在此以当前系统时间来“纠正”时针箭头热点的Y向位置(即距离top的位置)。500表示平移到规定的“500,500”圆点上。-->
harcL=Math.cos(nh)*250+500
<!--在此以当前系统时间来“纠正”时针箭头热点我的X向位置(即距离Left的位置)。500表示平移到规定的“500,500”圆点上。-->
//应该该为harcStr=harcT+","+harcL
harcStr=harcT+","+harcT<!--得到由当前时间映射的时针箭头处热点的坐标(harcT,harcT)-->
document.all.hourline.to.value=harcStr
<!--将(harcT,harcT)赋值给hourline的TO,即箭头热点。并通过document来显示在客户端的BROWER上。-->
<!--下面的分针和秒针原理相同。-->
<!--在不断的“纠正”中,显示就永远的和系统时间一样了-->
//分钟的字符串
nm=(180-marc)*Math.PI/180
marcT=Math.sin(nm)*350+500
marcL=Math.cos(nm)*350+500
marcStr=marcT+","+marcL
document.all.minuteline.to.value=marcStr
//秒的字符串
sm=(180-sarc)*Math.PI/180
sarcT=Math.sin(sm)*400+500
sarcL=Math.cos(sm)*400+500
sarcStr=sarcT+","+sarcL
document.all.secondline.to.value=sarcStr
document.all.txt.innerHTML="现在时间是:"+nowtime.getHours()+":"+nowtime.getMinutes()+":"+nowtime.getSeconds()
setTimeout("clock()","50")
}
</script>
<STYLE>
v\:* { Behavior: url(#default#VML) }
</STYLE>
<body onLoad="clock()"><v:group id="clock" Coordsize="1000,1000" style="width:200;height:200;position:relative">
<v:Oval id="outercircle" style="width:1000;height:1000;z-index:10;" fillcolor="gray" />
<v:oval id="innercircle" style="position:relative;top:75;left:75;width:850;height:850;z-index:15" fillcolor="white" />
<v:line id="hourline" style="position:relative;z-index:20" from="500,500" to="800,800" strokeColor="gray">
<!--初始化时针位置,两点“500,500”和“800,800”确定一条直线-->
<v:stroke startarrow="oval" endarrow="classic" dashstyle="Dot" strokeColor="red" />
</v:line>
<v:line id="minuteline" style="position:relative;z-index:20" from="500,500" to="500,900" strokeColor="black">
<!--//初始化分针位置,两点“500,500”和“500,200”确定一条直线。-->
<v:stroke endarrow="classic" dashstyle="Dot"/>
</v:line>
<v:line id="secondline" style="position:relative;z-index:20" from="500,500" to="400,900" strokeColor="black"> <!--//初始化秒针位置,两点“500,500”和“400,900”确定一条直线。-->
<v:stroke endarrow="classic" dashstyle="Dot"/>
</v:line>
<span style="position:relative;top:0;left:92;z-index:25">12</span>
<!--这几条语句是确定表面的数字位置的。不过 楼主确定的好象不是很正,从分针初始化的位置看的出来,初始化的分针是垂线。我来修改一下,望楼主原谅我的不知天高地厚-->
<span style="position:relative;top:92;left:169;z-index:25">3</span>
<span style="position:relative;top:186;left:58;z-index:25">6</span>
<span style="position:relative;top:93;left:-40;z-index:25">9</span>
<v:/group>
<div id=txt style="position:relative;top:220;left:40;border:1px solid black;font-size:12px;width:125;padding:3px"></div><!--通过ID关联将时间一数字形式现在在这里-->
</body>
</html>


做人要厚道,看帖要回帖!回帖是尊重,回帖是美德! 美德要发扬,我们要顶帖!顶帖是好事,千万莫灌水!
2006-11-09 08:46
川流不息
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2000
专家分:47
注 册:2006-11-8
收藏
得分:0 

牛人永遠是牛人,前進的方向就是你了。


日月更替,天地輪回,人間已是幾回春。 江山不老,人正少年,只手能擎半邊天。
2006-11-09 09:51
lvzehong
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-4-29
收藏
得分:0 
高手...佩服...

为什么中华之软件业崛起而学习!
2006-11-16 15:08
freekick
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-11-24
收藏
得分:0 
[讨论]不错不错
不错不错看不懂
2006-12-09 04:53
zhongshi
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2004-12-10
收藏
得分:0 

10#兄弟强悍,都翻译过来啦.

2006-12-12 10:51
hsjljh
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2005-10-26
收藏
得分:0 
超强啊 佩服佩服啊
2006-12-20 21:57
chenxkfox
Rank: 1
等 级:新手上路
威 望:1
帖 子:123
专家分:0
注 册:2005-8-18
收藏
得分:0 
佩服!

,SQL SERVER 群号:17280478
2006-12-22 09:47
快速回复:刚做的不用图片的时钟
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017511 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved