+[](https://travis-ci.org/wechat-miniprogram/api-typings)
+
+Type definitions for APIs of Wechat Mini Program in TypeScript
+
+## Install
+
+Install by NPM:
+```bash
+# install definitions for latest base library
+npm install miniprogram-api-typings
+```
+
+or specify a base library version:
+
+```bash
+# install definitions for base library version 2.4.1
+npm install miniprogram-api-typings@2.4.1
+```
+
+## Versions
+
+Check out all available versions corresponding to base library version in [VERSIONS.md](https://github.com/wechat-miniprogram/api-typings/blob/master/VERSIONS.md)
+Definitions of Wechat APIs (`lib.wx.api.d.ts`) are auto-generated together with our [documentations](https://developers.weixin.qq.com/miniprogram/dev/index.html), therefore PRs including that file will __not__ be merged. If you found some APIs defined wrongly, create an issue instead.
+
+Both PR and issue are welcomed for definitions of pages (`Page`), custom components (`Component`) and other else, since they are written manually. Help us improve this definition if you have any bug reports or suggestions! Thanks for contributing!
+
+### Contributors
+
+- [Baran](https://github.com/baranwang)
+- [MinLiang Zeng](https://github.com/zenml/)
+
+### Automated tests
+
+We use [`tsd`](https://github.com/SamVerschueren/tsd) to check if this definition is working properly. All test cases are under folder `test`.
+
+To perform an automated test, clone this repo, `npm install --save-dev` and `npm test`.
+
+If you have test case that fails the test, an issue or PR will be great. Strong test case that passes are also welcomed.
+ /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.rotate3d(number x, number y, number z, number angle)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate3d.html)
+ /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scale(number sx, number sy)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale.html)
+ *
+ * 缩放 */
+ scale(
+ /** 当仅有 sx 参数时,表示在 X 轴、Y 轴同时缩放sx倍数 */
+ sx: number,
+ /** 在 Y 轴缩放 sy 倍数 */
+ sy?: number
+ ): Animation
+ /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.scale3d(number sx, number sy, number sz)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale3d.html)
+ /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translate(number tx, number ty)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate.html)
+ *
+ * 平移变换 */
+ translate(
+ /** 当仅有该参数时表示在 X 轴偏移 tx,单位 px */
+ tx?: number,
+ /** 在 Y 轴平移的距离,单位为 px */
+ ty?: number
+ ): Animation
+ /** [[Animation](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html) Animation.translate3d(number tx, number ty, number tz)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate3d.html)
+ /** [CanvasContext.arc(number x, number y, number r, number sAngle, number eAngle, boolean counterclockwise)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arc.html)
+ /** [CanvasContext.arcTo(number x1, number y1, number x2, number y2, number radius)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arcTo.html)
+ /** [CanvasContext.bezierCurveTo(number cp1x, number cp1y, number cp2x, number cp2y, number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.bezierCurveTo.html)
+ /** [CanvasContext.clearRect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.clearRect.html)
+ /** [CanvasContext.drawImage(string imageResource, number sx, number sy, number sWidth, number sHeight, number dx, number dy, number dWidth, number dHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html)
+ /** [CanvasContext.drawImage(string imageResource, number sx, number sy, number sWidth, number sHeight, number dx, number dy, number dWidth, number dHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html)
+ /** [CanvasContext.drawImage(string imageResource, number sx, number sy, number sWidth, number sHeight, number dx, number dy, number dWidth, number dHeight)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html)
+ /** [CanvasContext.fillRect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fillRect.html)
+ /** [CanvasContext.fillText(string text, number x, number y, number maxWidth)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fillText.html)
+*
+* 在画布上绘制被填充的文本
+*
+* **示例代码**
+*
+*
+* ```javascript
+const ctx = wx.createCanvasContext('myCanvas')
+
+ctx.setFontSize(20)
+ctx.fillText('Hello', 20, 20)
+ctx.fillText('MINA', 100, 100)
+
+ctx.draw()
+```
+*  */
+ fillText(
+ /** 在画布上输出的文本 */
+ text: string,
+ /** 绘制文本的左上角 x 坐标位置 */
+ x: number,
+ /** 绘制文本的左上角 y 坐标位置 */
+ y: number,
+ /** 需要绘制的最大宽度,可选 */
+ maxWidth?: number
+ ): void
+ /** [CanvasContext.lineTo(number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.lineTo.html)
+*
+* 增加一个新点,然后创建一条从上次指定点到目标点的线。用 `stroke` 方法来画线条
+*
+* **示例代码**
+*
+*
+* ```javascript
+const ctx = wx.createCanvasContext('myCanvas')
+ctx.moveTo(10, 10)
+ctx.rect(10, 10, 100, 50)
+ctx.lineTo(110, 60)
+ctx.stroke()
+ctx.draw()
+```
+*  */
+ lineTo(
+ /** 目标位置的 x 坐标 */
+ x: number,
+ /** 目标位置的 y 坐标 */
+ y: number
+ ): void
+ /** [CanvasContext.moveTo(number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.moveTo.html)
+*
+* 把路径移动到画布中的指定点,不创建线条。用 `stroke` 方法来画线条
+*
+* **示例代码**
+*
+*
+* ```javascript
+const ctx = wx.createCanvasContext('myCanvas')
+ctx.moveTo(10, 10)
+ctx.lineTo(100, 10)
+
+ctx.moveTo(10, 50)
+ctx.lineTo(100, 50)
+ctx.stroke()
+ctx.draw()
+```
+*  */
+ moveTo(
+ /** 目标位置的 x 坐标 */
+ x: number,
+ /** 目标位置的 y 坐标 */
+ y: number
+ ): void
+ /** [CanvasContext.quadraticCurveTo(number cpx, number cpy, number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.quadraticCurveTo.html)
+ /** [CanvasContext.rect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.rect.html)
+ /** [CanvasContext.setShadow(number offsetX, number offsetY, number blur, string color)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setShadow.html)
+ /** [CanvasContext.setTransform(number scaleX, number skewX, number skewY, number scaleY, number translateX, number translateY)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTransform.html)
+ /** [CanvasContext.strokeRect(number x, number y, number width, number height)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeRect.html)
+ /** [CanvasContext.strokeText(string text, number x, number y, number maxWidth)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeText.html)
+ *
+ * 给定的 (x, y) 位置绘制文本描边的方法
+ *
+ * 最低基础库: `1.9.90` */
+ strokeText(
+ /** 要绘制的文本 */
+ text: string,
+ /** 文本起始点的 x 轴坐标 */
+ x: number,
+ /** 文本起始点的 y 轴坐标 */
+ y: number,
+ /** 需要绘制的最大宽度,可选 */
+ maxWidth?: number
+ ): void
+ /** [CanvasContext.transform(number scaleX, number skewX, number skewY, number scaleY, number translateX, number translateY)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.transform.html)
+ *
+ * 使用矩阵多次叠加当前变换的方法
+ *
+ * 最低基础库: `1.9.90` */
+ transform(
+ /** 水平缩放 */
+ scaleX: number,
+ /** 水平倾斜 */
+ skewX: number,
+ /** 垂直倾斜 */
+ skewY: number,
+ /** 垂直缩放 */
+ scaleY: number,
+ /** 水平移动 */
+ translateX: number,
+ /** 垂直移动 */
+ translateY: number
+ ): void
+ /** [CanvasContext.translate(number x, number y)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.translate.html)
+ /** [[CanvasGradient](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.html) CanvasContext.createCircularGradient(number x, number y, number r)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createCircularGradient.html)
+ /** [[CanvasGradient](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.html) CanvasContext.createLinearGradient(number x0, number y0, number x1, number y1)](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createLinearGradient.html)
+* - 其他蓝牙相关 API 必须在 [wx.openBluetoothAdapter](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html) 调用之后使用。否则 API 会返回错误(errCode=10000)。