Home Web Front-end H5 Tutorial HTML5 canvas超逼真的模拟时钟特效

HTML5 canvas超逼真的模拟时钟特效

Mar 30, 2017 pm 01:19 PM

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>
Copy after login

HTML结构

可以使用一个空的

来作为时钟的容器。

<p id="myclock"></p>
Copy after login

初始化插件

在页面DOM元素加载完毕之后,可以通过thooClock()方法来初始化该时钟插件。

<script type="text/javascript">
  $(&#39;#myDIV&#39;).thooClock();
</script>
Copy after login

配置参数

下面是该时钟插件的可用配置参数:

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 = &#39;14:25&#39;
$.fn.thooClock.setAlarm(strTime);
Copy after login

也可以使用一个Date对象来设置闹钟时间:

var alarm_date=new Date();
alarm_date.setHours(8,19,30);
$.fn.thooClock.setAlarm(alarm_date);
Copy after login

清除闹钟

$.fn.thooClock.clearAlarm();
Copy after login

以上就是HTML5 canvas超逼真的模拟时钟特效的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

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

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

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.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

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

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

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

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

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

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

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

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

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

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

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

See all articles