jCanvas Syntax 语法 - caleb531/jcanvas-docs GitHub Wiki

Syntax 语法

All jCanvas methods are regular jQuery methods, and are used in the same manner. Calling a jCanvas method will apply to all canvas elements in the jQuery collection.
所有的jCanvas方法都使用的是jQuery方法的规则,它们使用相同的方式。调用一个jCanvas方法,会应用到jQuery集合中的所有canvas元素上。

Basic Usage 基本用法

Most jCanvas methods accept a map of properties, which may be listed in any order.
大部分的jCanvas方法,都接收一个属性映射,映射可以使用任何顺序列出。

// Draw a circle on the canvas 在画布上画一个圆   
$('canvas').drawArc({   
  fillStyle: 'black',   
  x: 100, y: 100,   
  radius: 50   
});  

Numeric Values 数字型值

Most numeric property values are measured in pixels, although some are relative to the values of other properties. The description for any property will usually mention these special cases when necessary.
大部分的数字型属性值,都以像素来衡量(为单位),尽管有些是与其它属性相关的值。任意属性的描述通常都会在必要时,提及这些特殊情况。

Chaining 链式结构

Most jCanvas methods support chaining for cleaner and faster code.
大部分的jCanvas方法都支持链式结构,以使代码更清晰,更快捷。

$('canvas').drawArc({
  fillStyle: 'black',
  x: 100, y: 100,
  radius: 50
})
.drawArc({
  fillStyle: '#36b',
  x: 300, y: 150,
  radius: 50
});

Multiple Canvases 多重画布

As demonstrated in the examples above, jCanvas can draw the same drawing on multiple canvases.
像上边例子显示的那样,jCanvas可以在多个画布上进行相同的绘制。

// Applies to all canvas elements应用到所有的画布元素上
$('canvas').drawArc({
  fillStyle: 'black',
  x: 100, y: 100,
  radius: 50
});
// Applies to all canvas elements with a class of 'demo' 应用到所有带类名demo的画布元素上
$('canvas.demo').drawArc({
  fillStyle: 'black',
  x: 100, y: 100,
  radius: 50
});