excel时钟制作方法

发布网友 发布时间:2022-04-20 10:29

我来回答

2个回答

懂视网 时间:2022-04-23 18:18

时钟特效

js代码

var canvas = document.getElementById("clock");var clock = canvas.getContext("2d"); 
function zhong() {
 clock.save(); //开始画外层圆
 clock.translate(200, 200);
 clock.strokeStyle = 'black';
 clock.lineWidth = 3;
 clock.beginPath();
 clock.arc(0, 0, 195, 0, 2 * Math.PI);
 clock.stroke(); //时钟上的数字
 var shuzi = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2];
 clock.font = "30px Arial";
 clock.textAlign = "center";
 clock.textBaseline = "middle";
 shuzi.forEach(function(number, i) { 
 var rad = 2 * Math.PI / 12 * i; 
 var x = Math.cos(rad) * 180; 
 var y = Math.sin(rad) * 180;
 clock.fillText(number, x, y);
 }); // 小圆点

 for(j = 0; j < 60; j++) { 
 var h = 2 * Math.PI / 60 * j; 
 var m = Math.cos(h) * 180; 
 var n = Math.sin(h) * 180;
 clock.fillStyle = 'black';
 clock.beginPath(); 
 if(j % 5 === 0) {  
 continue;
 }
 clock.arc(m, n, 3, 0, 2 * Math.PI);
 clock.fill();
 }
}function drawHour(hour,min) {
 clock.save(); 
 var rad = 2 * Math.PI / 12 * hour; 
 var red = 2 *Math.PI/12/60*min;
 clock.rotate(rad+red);
 clock.lineWidth = 10;
 clock.lineCap = "round";
 clock.beginPath();
 clock.moveTo(0, 5);
 clock.lineTo(0, -100);
 clock.stroke();
 clock.restore();
}function drawmin(min) {
 clock.save(); 
 var rad = 2 * Math.PI / 60 * min;
 clock.rotate(rad);
 clock.lineWidth = 5;
 clock.lineCap = "round";
 clock.beginPath();
 clock.moveTo(0, 10);
 clock.lineTo(0, -150);
 clock.stroke();
 clock.restore();
}function drawsec(sec) {
 clock.save(); 
 var rad = 2 * Math.PI / 60 * sec;
 clock.rotate(rad);
 clock.lineWidth = 2;
 clock.lineCap = "round";
 clock.strokeStyle = "red";
 clock.beginPath();
 clock.moveTo(0, 10);
 clock.lineTo(0, -180);
 clock.stroke();
 clock.restore();
}function dian() {
 clock.fillStyle = "white";
 clock.beginPath();
 clock.arc(0, 0, 2, 0, 2 * Math.PI);
 clock.fill();
}function xuanzhuan() {
 clock.clearRect(0,0,400,400);
 zhong(); 
 var now = new Date(); 
 var hour = now.getHours(); 
 var min = now.getMinutes(); 
 var sec = now.getSeconds();
 drawHour(hour,min);
 drawmin(min);
 drawsec(sec);
 dian();
 clock.restore();
}
xuanzhuan();
setInterval(xuanzhuan, 1000);

热心网友 时间:2022-04-23 15:26

excel中制作简易电子时钟,听起来似乎挺高大上的~~哈哈,简单几个代码就能搞定~~工具/材料
office办公软件
操作方法
01
点击左上角的文件

02
点击选项

03
点击自定义工功能区

04
这里把开发工具打上勾

05
点击确定

06
点击开发工具

07
点击最左边的图标

08
右击sheet1,,然后点击插入

09
点击模块

10
这里把这段代码粘贴进来
Sub 电子表()
ActiveSheet.Range("A1").Value = Time
Application.OnTime Time + TimeSerial(0, 0, 1), "电子表"
End Sub

11
然后直接关闭这个窗口就可以了
12
点击视图,然后点击宏,最后点击查看宏

13
这里点击执行

14
好啦,简易电子时钟就制作好啦

好了,以上就是大致内容了

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com