1.3.1 • Published 8 years ago

cclock v1.3.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

#cClock

A flat and dynamic clock by Canvas

##Index

##中文说明

##Index

###Quick start

###Install by npm or bower

$ npm install cclock
$ bower install cclock

###Include files

<script src="cClock.js"></script>

Apply cClock and call the function as simple as

<canvas id="cClock" width="400" height="400">A flat and dynamic clock.</canvas>
cClock({
    id: 'cClock'
});

All done !

###Options

The cClock has awesome and customizable feature.

cClock({
    id: 'cClock',
    options: {
        option1: value1,
        option2: value2,
        ...
    },
    showTime: {
        hour: hour,
        minute: minute,
        second: second
    }
});

The Parameters are :

  1. cClock's id, should be String.

  2. A object to custom cClock including available options which are listed below. A null object means default options.

  3. Optional, a object to make the cClock at including time. Also can be true to make it at default time which is 10 : 08 : 30.

OptionTypeDefaultDescription
hourLengthNumber0.65The length of hour hand.
hourWidthNumber2The width of hour hand.
minuteLengthNumber0.85The length of minute hand.
minuteWidthNumber2The width of minute hand.
secondLengthNumber0.8The length of second hand.
secondWidthNumber2The width of second hand.
handColorString"#000"The color of hands.
handStyleString"butt"The style of hands. Only "round" and "square" are permitted.
centerRadiusNumber5The radius of center circle.
hourBackLengthNumber0.2The length of back hour hand.
minuteBackLengthNumber0.2The length of back minute hand.
secondBackLengthNumber0.2The length of back second hand.
borderWidthNumber2The width of border.
borderColorString"#000"The color of border.
paddingNumber0The distance between border and dial.
bgColorString"#fff"The backgound color of clock.
hourDialWidthNumber2The width of hour dial.
hourDialLengthNumber0.15The length of hour dial.
minuteDialWidthNumber2The width of minute dial.
minuteDialLengthNumber0.08The length of minute dial.
dialColorString"#000"The color of dial.

###Attentions

  1. The width and height of cClock depend on <canvas>.

  2. So assign the width and height in this tag and make sure the tag is a square which means width equal height !

  3. The length of some options should be assigned decimal, which means "decimal times the radius length".

  4. If the length or width of one option equal 0, the option will not display.

  5. For example, if "secondLength: 0", then there is no second hand.

  6. There will be no minute dial if there is no hour dial.

###License

MIT License


##中文说明

###使用说明

###通过 npm 或 bower 安装

$ npm install jzoom
$ bower install cclock

###引入文件

<script src="cClock.js"></script>

添加 <canvas> 标签,设置宽高,并在标签内部添加一些描述,

<canvas id="cClock" width="400" height="400">A flat and dynamic clock.</canvas>

运行函数,

cClock({
    id: 'cClock'
});

即可实现默认效果。

###配置选项

cClock 拥有丰富的自定义功能。

cClock({
    id: 'cClock',
    options: {
        option1: value1,
        option2: value2,
        ...
    },
    showTime: {
        hour: hour,
        minute: minute,
        second: second
    }
});

参数分别为:

  1. cClock 标签的 id 属性, String 类型。

  2. 自定义 cClock 外观的配置对象,可选参数列于下表,空对象表示默认效果。

  3. 可选,传入一个时间对象,可使 cClock 静止在设置的时间,也可传入 true 使之静止在默认时间 —— 10 : 08 : 30。

选项类型默认值描述
hourLengthNumber0.65时针的长度
hourWidthNumber2时针的宽度
minuteLengthNumber0.85分针的长度
minuteWidthNumber2分针的宽度
secondLengthNumber0.8秒针的长度
secondWidthNumber2秒针的宽度
handColorString"#000"指针的颜色
handStyleString"butt"指针的类型,还可设置为"round"、"square"
centerRadiusNumber5中心圆的半径
hourBackLengthNumber0.2时针后部的长度
minuteBackLengthNumber0.2分针后部的长度
secondBackLengthNumber0.2秒针后部的长度
borderWidthNumber2边框的宽度
borderColorString"#000"边框的颜色
paddingNumber0边框和刻度之间的内边距
bgColorString"#fff"时钟的背景色
hourDialWidthNumber2小时刻度的宽度
hourDialLengthNumber0.15小时刻度的长度
minuteDialWidthNumber2分钟刻度的宽度
minuteDialLengthNumber0.08分钟刻度的长度
dialColorString"#000"刻度的颜色

###注意事项

  1. 时钟的大小取决于 <canvas> 的宽高。

  2. 必须要给该标签设置宽高,并且保证是一个正方形,也就是宽高要相等。

  3. 一些与长度有关的选项需设置为小数,与时钟半径有关。

  4. 如果选项的长度或宽度设置为 0 ,则表示不显示该选项有关的内容。

  5. 例如,如果设置 "secondLength: 0" ,就表示不需要秒针。

  6. 如果把小时刻度设置为不显示,那么分钟刻度也不会显示。

##开源协议

基于 MIT 协议

1.3.1

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago