HTML5 canvas超逼真的模拟时钟特效
HTML5 canvas超逼真的模拟时钟特效
简要教程
thooClock是一款效果非常逼真的HTML5 canvas模拟时钟特效。该时钟特效使用jQuery和HTML5 Canvas API来制作,模拟现实生活中的时钟。并且它还具有定时闹钟的功能。
使用方法
使用该模拟时钟插件首先需要引入jQuery和jquery.thooClock.js文件。
<script type="text/javascript" src="js/jquery-latest.min.js"></script> <script type="text/javascript" src="js/jquery.thooClock.js"></script>
HTML结构
可以使用一个空的
来作为时钟的容器。
<p id="myclock"></p>
初始化插件
在页面DOM元素加载完毕之后,可以通过thooClock()方法来初始化该时钟插件。
<script type="text/javascript"> $('#myDIV').thooClock(); </script>
配置参数
下面是该时钟插件的可用配置参数:
size:默认值:250。时钟的大小。
dialColor:默认值:'#000000'。时钟的前景色。可以是hex,颜色关键字,rgb或rgba颜色值。
dialBackgroundColor:默认值:'transparent'。时钟的背景颜色。
secondHandColor:默认值:'#F3A829'。时钟秒针的颜色。
minuteHandColor:默认值:'#222222'。时钟分针的颜色。
hourHandColor:默认值:'#222222'。时钟时针的颜色。
alarmHandColor:默认值:'#FFFFFF'。闹钟指示的颜色(闹钟指示只有在alarmTime设置为'hh:mm')时才可见。
alarmHandTipColor:默认值:'#026729'。闹钟指示的提示框颜色。
hourCorrection:默认值:'+0'。小时校正。例如:+5或-3。
alarmCount:默认值:1。闹钟会响多少次。
alarmTime:响闹钟的时间。可以是Date对象或字符串:hh,hh:mm,hh:mm:ss。
showNumerals:是否在时钟上显示数字。
brandText:时钟的品牌名称。
brandText2:时钟的产地名称。
onAlarm:闹钟的回调函数。
offAlarm:闹钟结束时的回调函数。
onEverySecond:这个函数会在每一秒都触发一次。
方法
设置闹钟时间
可以使用一个字符串来设置闹钟时间:
// must be "hh", "hh:mm" or "hh:mm:ss" var strTime = '14:25' $.fn.thooClock.setAlarm(strTime);
也可以使用一个Date对象来设置闹钟时间:
var alarm_date=new Date(); alarm_date.setHours(8,19,30); $.fn.thooClock.setAlarm(alarm_date);
清除闹钟
$.fn.thooClock.clearAlarm();
以上就是HTML5 canvas超逼真的模拟时钟特效的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
