数码资讯
HTML5画布(数字时钟)实例代码
复制代码代码如下所示: 帆布dClock 你的浏览器太旧了。升级! VaR的时钟document.getelementbyid(时钟); VaR CXT = clock.getcontext(2D); 数字时钟显示 功能(m,n){欣欣 cxt.clearrect(0, 0, 500,500); v
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
复制代码代码如下所示:
帆布dClock
你的浏览器太旧了。升级!
VaR的时钟document.getelementbyid(时钟);
VaR CXT = clock.getcontext(2D);
数字时钟显示
功能(m,n){欣欣
cxt.clearrect(0, 0, 500,500);
var现在=新日期;
无功功率= now.gethours();
VaR最小= now.getminutes();
VaR秒= now.getseconds();
VaR毫秒= now.getmilliseconds();
小时=小时= 10小时:0小时以上;
分钟= > = 10分钟:0 +分钟;
秒= 10秒:0秒以上;
毫秒=(毫秒= 10毫秒= 0,毫秒< 10)(00毫秒):毫秒;
bdigital(m,n,h);
bdigital(M + 160,N分钟);
bdigital(M + 320,N秒);
/ /数字(M + 480,n,毫秒);
三位数显示
函数(x,y,努姆数字){
var = % 10;
Var Shi =(parseInt(Num / 10))% 10;
Var Bai = parseInt((parseInt(Num / 10)) / 10)% 10;
数字(x,y,白);
数字(x,70,y,史);
数字(x,140,y,GE);
}
双位数显示
功能bdigital(x,y,努姆){
var = % 10;
Var Shi =(parseInt(Num / 10))% 10;
数字(X,Y,石);
数字(x,70,y,GE);
}
绘画:
在小时和分钟之间
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 140,80, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 140,100, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
分钟/秒之间/
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 300,80, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 300,100, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
在秒和毫秒之间。
/ / cxt.linewidth = 5;
/ / cxt.strokestyle =# 000 ;
/ / cxt.fillstyle =# 000 ;
( / / CXT。调用);
/ / cxt.arc(M + N + 460,100, 3, 0,360,假);
( / / CXT。填写);
( / / CXT。closepath);
( / / CXT。中风);
}
数字显示器。
函数数字(x,y,努姆){
设置/样式
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
函数A(){
Cxt.beginPath();
Cxt.moveTo(x,y);
Cxt.lineTo(x + 50,y);
Cxt.closePath();
Cxt.stroke();
}
函数B(){
Cxt.beginPath();
Cxt.moveTo(x + 55,y + 5);
Cxt.lineTo(x + 55,y + 55);
Cxt.closePath();
Cxt.stroke();
}
函数C(){
Cxt.beginPath();
Cxt.moveTo(x + 55,y + 60);
Cxt.lineTo(x + 55,y + 110);
Cxt.closePath();
Cxt.stroke();
}
函数d(){
Cxt.beginPath();
Cxt.moveTo(x + 50,y + 115);
Cxt.lineTo(x,y + 115);
Cxt.closePath();
Cxt.stroke();
}
函数E(){
Cxt.beginPath();
Cxt.moveTo(x 5,y + 110);
Cxt.lineTo(x 5,y + 60);
Cxt.closePath();
Cxt.stroke();
}
函数f(){
Cxt.beginPath();
Cxt.moveTo(x 5,y + 55);
Cxt.lineTo(x 5,y + 5);
Cxt.closePath();
Cxt.stroke();
}
函数g(){
Cxt.beginPath();
Cxt.moveTo(x,y + 57.5);
Cxt.lineTo(x + 50,y + 57.5);
Cxt.closePath();
Cxt.stroke();
}
0
函数0(){
a();b();c();d();E();f();
}
1
函数一(){
B();C();
}
2
函数2(){
a();b();d();E();G();
}
3
函数三(){
a();b();c();d();G();
}
4
函数四(){
B();c();f();G();
}
5
函数五(){
a();c();d();f();G();
}
6
函数六(){
a();c();d();E();f();G();
}
7
函数七(){
a();b();c();
}
/ / 8
函数八(){
A();B();C();D();E();f();G();
}
9
函数九(){
a();b();c();d();f();G();
}
数字n
函数号(n){
开关(n){
案例0:零();破;
案例1:一();打破;
案例2:二();中断;
案例3:三();中断;
案例4:四();中断;
案例5:五();中断;
案例6:六();中断;
案例7:七();中断;
案例8:八();中断;
案例9:九();中断;
}
}
编号(努姆);
}
欣欣(1, 45);
setInterval(Showtime(1,45)
帆布dClock
你的浏览器太旧了。升级!
VaR的时钟document.getelementbyid(时钟);
VaR CXT = clock.getcontext(2D);
数字时钟显示
功能(m,n){欣欣
cxt.clearrect(0, 0, 500,500);
var现在=新日期;
无功功率= now.gethours();
VaR最小= now.getminutes();
VaR秒= now.getseconds();
VaR毫秒= now.getmilliseconds();
小时=小时= 10小时:0小时以上;
分钟= > = 10分钟:0 +分钟;
秒= 10秒:0秒以上;
毫秒=(毫秒= 10毫秒= 0,毫秒< 10)(00毫秒):毫秒;
bdigital(m,n,h);
bdigital(M + 160,N分钟);
bdigital(M + 320,N秒);
/ /数字(M + 480,n,毫秒);
三位数显示
函数(x,y,努姆数字){
var = % 10;
Var Shi =(parseInt(Num / 10))% 10;
Var Bai = parseInt((parseInt(Num / 10)) / 10)% 10;
数字(x,y,白);
数字(x,70,y,史);
数字(x,140,y,GE);
}
双位数显示
功能bdigital(x,y,努姆){
var = % 10;
Var Shi =(parseInt(Num / 10))% 10;
数字(X,Y,石);
数字(x,70,y,GE);
}
绘画:
在小时和分钟之间
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 140,80, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 140,100, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
分钟/秒之间/
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 300,80, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
cxt.fillstyle =# 000 ;
Cxt.beginPath();
Cxt.arc(M + N + 300,100, 3, 0,360,假);
Cxt.fill();
Cxt.closePath();
Cxt.stroke();
在秒和毫秒之间。
/ / cxt.linewidth = 5;
/ / cxt.strokestyle =# 000 ;
/ / cxt.fillstyle =# 000 ;
( / / CXT。调用);
/ / cxt.arc(M + N + 460,100, 3, 0,360,假);
( / / CXT。填写);
( / / CXT。closepath);
( / / CXT。中风);
}
数字显示器。
函数数字(x,y,努姆){
设置/样式
cxt.linewidth = 5;
cxt.strokestyle =# 000 ;
函数A(){
Cxt.beginPath();
Cxt.moveTo(x,y);
Cxt.lineTo(x + 50,y);
Cxt.closePath();
Cxt.stroke();
}
函数B(){
Cxt.beginPath();
Cxt.moveTo(x + 55,y + 5);
Cxt.lineTo(x + 55,y + 55);
Cxt.closePath();
Cxt.stroke();
}
函数C(){
Cxt.beginPath();
Cxt.moveTo(x + 55,y + 60);
Cxt.lineTo(x + 55,y + 110);
Cxt.closePath();
Cxt.stroke();
}
函数d(){
Cxt.beginPath();
Cxt.moveTo(x + 50,y + 115);
Cxt.lineTo(x,y + 115);
Cxt.closePath();
Cxt.stroke();
}
函数E(){
Cxt.beginPath();
Cxt.moveTo(x 5,y + 110);
Cxt.lineTo(x 5,y + 60);
Cxt.closePath();
Cxt.stroke();
}
函数f(){
Cxt.beginPath();
Cxt.moveTo(x 5,y + 55);
Cxt.lineTo(x 5,y + 5);
Cxt.closePath();
Cxt.stroke();
}
函数g(){
Cxt.beginPath();
Cxt.moveTo(x,y + 57.5);
Cxt.lineTo(x + 50,y + 57.5);
Cxt.closePath();
Cxt.stroke();
}
0
函数0(){
a();b();c();d();E();f();
}
1
函数一(){
B();C();
}
2
函数2(){
a();b();d();E();G();
}
3
函数三(){
a();b();c();d();G();
}
4
函数四(){
B();c();f();G();
}
5
函数五(){
a();c();d();f();G();
}
6
函数六(){
a();c();d();E();f();G();
}
7
函数七(){
a();b();c();
}
/ / 8
函数八(){
A();B();C();D();E();f();G();
}
9
函数九(){
a();b();c();d();f();G();
}
数字n
函数号(n){
开关(n){
案例0:零();破;
案例1:一();打破;
案例2:二();中断;
案例3:三();中断;
案例4:四();中断;
案例5:五();中断;
案例6:六();中断;
案例7:七();中断;
案例8:八();中断;
案例9:九();中断;
}
}
编号(努姆);
}
欣欣(1, 45);
setInterval(Showtime(1,45)
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。