canvas时钟代码

canvas时钟代码源码下载

看看谁在用

查看文件目录结构

文件大小:0.00M

素材分类: 插件- 时间

更新时间:2024-08-12

基于canvas创建的动态时钟样式
function drawPanel() {
            // ======
            ctx.translate(150, 150);
            ctx.beginPath();
            ctx.arc(0, 0, 130, 0, 2 * Math.PI);
            ctx.fillStyle = "white";
            ctx.fill();
        }

        function hourNum() {
            var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
            ctx.beginPath();
            ctx.font = "30px fangsong";
            ctx.textAlign = "center";
            ctx.textBaseline = "middle";
            ctx.fillStyle = "black";
            for (var i = 0; i < arr.length; i++) {
                ctx.fillText(
                    arr[i],
                    108 * Math.cos(((i * 30 - 60) * Math.PI) / 180),
                    108 * Math.sin(((i * 30 - 60) * Math.PI) / 180)
                );
            }
        }

        function centerDot() {
            ctx.beginPath();
            ctx.arc(0, 0, 8, 0, 2 * Math.PI);
            ctx.fill();
            ctx.beginPath();
            ctx.fillStyle = "gray";
            ctx.arc(0, 0, 5, 0, 2 * Math.PI);
            ctx.fill();
        }

        function hourHand(hours, minutes) {
            var radius =
                ((2 * Math.PI) / 12) * hours + (((1 / 6) * Math.PI) / 60) * minutes;
            ctx.save();
            ctx.beginPath();
            ctx.lineWidth = 5;
            ctx.lineCap = "round";
            ctx.strokeStyle = "black";
            ctx.rotate(radius);
            ctx.moveTo(0, 0);
            ctx.lineTo(0, -50);
            ctx.stroke();
            ctx.restore();
        }

        function minuteHand(minutes) {
            2 * Math.PI;
            var radius = ((2 * Math.PI) / 60) * minutes;
            ctx.save();
            ctx.beginPath();
            ctx.lineWidth = 3;
            ctx.lineCap = "round";
            ctx.strokeStyle = "black";
            ctx.rotate(radius);
            ctx.moveTo(0, 0);
            ctx.lineTo(0, -70);

            ctx.stroke();
            ctx.restore();
        }
        function secondHand(seconds) {
            var radius = ((2 * Math.PI) / 60) * seconds;
            ctx.save();
            ctx.beginPath();
            ctx.lineWidth = 1;
            ctx.lineCap = "round";
            ctx.strokeStyle = "red";
            ctx.rotate(radius);
            ctx.moveTo(0, 0);
            ctx.lineTo(0, -90);
            ctx.stroke();
            ctx.restore();
        }

canvas时钟代码

正在加载文件目录...

.
.下载了 此素材

也许你还喜欢

  1. JS+CSS3动态时钟样式特效
  2. Neumorphic样式时钟网页代码
  3. js+css3带秒针的时钟特效
  4. 时间滚动计时 js css代码
  5. 创意条状动态时间小部件
  6. jQuery和CSS3精美时钟插件
  7. 时钟样式jQuery时间选择插件
  8. html5时钟闹铃特效代码
俄罗斯方块CSS3动画
  • 标签大全|网站地图|关于我们|用户协议
  • 背景样式编辑器|按钮样式编辑器|背景动效编辑器|图片布局编辑器|在线工具