@tarojs/taro 4.0.0-canary.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +38 -17
- package/types/api/base/debug.d.ts +8 -8
- package/types/api/base/env.d.ts +2 -2
- package/types/api/base/index.d.ts +3 -3
- package/types/api/base/performance.d.ts +1 -1
- package/types/api/base/system.d.ts +6 -6
- package/types/api/base/weapp/app-event.d.ts +10 -10
- package/types/api/base/weapp/life-cycle.d.ts +1 -1
- package/types/api/canvas/index.d.ts +367 -63
- package/types/api/device/battery.d.ts +1 -1
- package/types/api/device/clipboard.d.ts +2 -2
- package/types/api/device/keyboard.d.ts +1 -1
- package/types/api/device/network.d.ts +3 -3
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/screen.d.ts +2 -2
- package/types/api/files/index.d.ts +7 -7
- package/types/api/framework/index.d.ts +2 -2
- package/types/api/location/index.d.ts +4 -4
- package/types/api/media/audio.d.ts +21 -12
- package/types/api/media/background-audio.d.ts +1 -1
- package/types/api/media/image.d.ts +10 -10
- package/types/api/media/video.d.ts +11 -11
- package/types/api/navigate/index.d.ts +1 -1
- package/types/api/network/download.d.ts +5 -5
- package/types/api/network/request.d.ts +8 -8
- package/types/api/network/upload.d.ts +7 -7
- package/types/api/network/websocket.d.ts +8 -8
- package/types/api/open-api/account.d.ts +1 -1
- package/types/api/open-api/address.d.ts +13 -5
- package/types/api/open-api/authorize.d.ts +1 -1
- package/types/api/open-api/channels.d.ts +16 -0
- package/types/api/open-api/device-voip.d.ts +40 -0
- package/types/api/open-api/invoice.d.ts +1 -1
- package/types/api/open-api/login.d.ts +15 -2
- package/types/api/open-api/privacy.d.ts +8 -0
- package/types/api/open-api/settings.d.ts +3 -2
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +148 -6
- package/types/api/open-api/user-info.d.ts +6 -1
- package/types/api/qq/index.d.ts +306 -1
- package/types/api/route/index.d.ts +5 -5
- package/types/api/storage/index.d.ts +10 -10
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +151 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +3 -2
- package/types/api/taro.hooks.d.ts +9 -9
- package/types/api/ui/animation.d.ts +32 -32
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +1 -1
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +2 -2
- package/types/api/ui/pull-down-refresh.d.ts +2 -2
- package/types/api/ui/scroll.d.ts +1 -1
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +2 -2
- package/types/api/wxml/index.d.ts +30 -24
- package/types/compile/compiler.d.ts +6 -2
- package/types/compile/config/h5.d.ts +9 -4
- package/types/compile/config/harmony.d.ts +43 -7
- package/types/compile/config/index.d.ts +1 -0
- package/types/compile/config/mini.d.ts +2 -16
- package/types/compile/config/project.d.ts +26 -8
- package/types/compile/config/rn.d.ts +22 -1
- package/types/compile/index.d.ts +8 -0
- package/types/compile/viteCompilerContext.d.ts +7 -3
- package/types/global.d.ts +2 -1
- package/types/index.d.ts +91 -46
- package/types/taro.api.d.ts +22 -14
- package/types/taro.component.d.ts +3 -0
- package/types/taro.config.d.ts +13 -4
- package/types/taro.lifecycle.d.ts +3 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -35,6 +35,10 @@ declare module '../../index' {
|
|
|
35
35
|
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
36
36
|
/** 生成文件的临时路径 */
|
|
37
37
|
tempFilePath: string
|
|
38
|
+
/** 图片路径(本地临时文件)。
|
|
39
|
+
* @supported alipay
|
|
40
|
+
*/
|
|
41
|
+
apFilePath?: string
|
|
38
42
|
/** 调用结果 */
|
|
39
43
|
errMsg: string
|
|
40
44
|
}
|
|
@@ -137,7 +141,46 @@ declare module '../../index' {
|
|
|
137
141
|
/** 画布宽度 */
|
|
138
142
|
width?: number
|
|
139
143
|
/** 在自定义组件下,当前组件实例的 this,以操作组件内 [canvas](/docs/components/canvas) 组件 */
|
|
140
|
-
|
|
144
|
+
compInst?: TaroGeneral.IAnyObject,
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
namespace toTempFilePath {
|
|
149
|
+
interface Option {
|
|
150
|
+
/** 指定的画布区域的左上角横坐标 */
|
|
151
|
+
x?: number
|
|
152
|
+
/** 指定的画布区域的左上角纵坐标 */
|
|
153
|
+
y?: number
|
|
154
|
+
/** 指定的画布区域的宽度 */
|
|
155
|
+
width?: number
|
|
156
|
+
/** 指定的画布区域的高度 */
|
|
157
|
+
height?: number
|
|
158
|
+
/** 输出的图片的高度 */
|
|
159
|
+
destHeight?: number
|
|
160
|
+
/** 输出的图片的宽度 */
|
|
161
|
+
destWidth?: number
|
|
162
|
+
/** 目标文件的类型
|
|
163
|
+
* @default "png"
|
|
164
|
+
*/
|
|
165
|
+
fileType?: keyof FileType
|
|
166
|
+
/** 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 */
|
|
167
|
+
quality?: number
|
|
168
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
169
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
170
|
+
/** 接口调用失败的回调函数 */
|
|
171
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
172
|
+
/** 接口调用成功的回调函数 */
|
|
173
|
+
success?: (result: SuccessCallbackResult) => void
|
|
174
|
+
}
|
|
175
|
+
interface FileType {
|
|
176
|
+
/** jpg 图片 */
|
|
177
|
+
jpg
|
|
178
|
+
/** png 图片 */
|
|
179
|
+
png
|
|
180
|
+
}
|
|
181
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
182
|
+
/** 生成文件的临时路径 */
|
|
183
|
+
tempFilePath: string
|
|
141
184
|
}
|
|
142
185
|
}
|
|
143
186
|
|
|
@@ -150,7 +193,7 @@ declare module '../../index' {
|
|
|
150
193
|
/** 画布宽度 */
|
|
151
194
|
width: number
|
|
152
195
|
/** 取消由 requestAnimationFrame 添加到计划中的动画帧请求。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。
|
|
153
|
-
* @supported weapp
|
|
196
|
+
* @supported weapp, alipay, tt
|
|
154
197
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.cancelAnimationFrame.html
|
|
155
198
|
*/
|
|
156
199
|
cancelAnimationFrame(requestID: number): void
|
|
@@ -160,7 +203,7 @@ declare module '../../index' {
|
|
|
160
203
|
*/
|
|
161
204
|
createImageData(): ImageData
|
|
162
205
|
/** 创建一个图片对象。 支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。
|
|
163
|
-
* @supported weapp
|
|
206
|
+
* @supported weapp, alipay, tt
|
|
164
207
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createImage.html
|
|
165
208
|
*/
|
|
166
209
|
createImage(): Image
|
|
@@ -172,7 +215,7 @@ declare module '../../index' {
|
|
|
172
215
|
path: Path2D
|
|
173
216
|
): Path2D
|
|
174
217
|
/** 支持获取 2D 和 WebGL 绘图上下文
|
|
175
|
-
* @supported weapp
|
|
218
|
+
* @supported weapp, alipay, tt
|
|
176
219
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.getContext.html
|
|
177
220
|
*/
|
|
178
221
|
getContext(contextType: string): RenderingContext
|
|
@@ -194,6 +237,11 @@ declare module '../../index' {
|
|
|
194
237
|
/** 在指定图片格式为 image/jpeg 或 image/webp的情况下,可以从 0 到 1 的区间内选择图片的质量。如果超出取值范围,将会使用默认值 0.92。其他参数会被忽略。 */
|
|
195
238
|
encoderOptions: number
|
|
196
239
|
): string
|
|
240
|
+
/** 把当前画布指定区域保存为图片
|
|
241
|
+
* @supported alipay
|
|
242
|
+
* @see https://opendocs.alipay.com/mini/api/toTempFilePath?pathHash=e79fe218
|
|
243
|
+
*/
|
|
244
|
+
toTempFilePath(oprion: toTempFilePath.Option): void
|
|
197
245
|
}
|
|
198
246
|
|
|
199
247
|
/** canvas 组件的绘图上下文
|
|
@@ -242,7 +290,7 @@ declare module '../../index' {
|
|
|
242
290
|
* - 绿色: 圆心 (100, 75)
|
|
243
291
|
* - 红色: 起始弧度 (0)
|
|
244
292
|
* - 蓝色: 终止弧度 (1.5 * Math.PI)
|
|
245
|
-
* @supported weapp, h5
|
|
293
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
246
294
|
* @example
|
|
247
295
|
* ```tsx
|
|
248
296
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -298,9 +346,13 @@ declare module '../../index' {
|
|
|
298
346
|
eAngle: number,
|
|
299
347
|
/** 弧度的方向是否是逆时针 */
|
|
300
348
|
counterclockwise?: boolean,
|
|
349
|
+
/** 弧度的方向是否是逆时针
|
|
350
|
+
* @supported tt
|
|
351
|
+
*/
|
|
352
|
+
anticlockwise?: boolean
|
|
301
353
|
): void
|
|
302
354
|
/** 根据控制点和半径绘制圆弧路径。
|
|
303
|
-
* @supported weapp, h5
|
|
355
|
+
* @supported weapp, alipay, jd, qq, h5, harmony_hybrid
|
|
304
356
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arcTo.html
|
|
305
357
|
*/
|
|
306
358
|
arcTo(
|
|
@@ -319,7 +371,7 @@ declare module '../../index' {
|
|
|
319
371
|
*
|
|
320
372
|
* - 在最开始的时候相当于调用了一次 `beginPath`。
|
|
321
373
|
* - 同一个路径内的多次 `setFillStyle`、`setStrokeStyle`、`setLineWidth`等设置,以最后一次设置为准。
|
|
322
|
-
* @supported weapp, h5
|
|
374
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
323
375
|
* @example
|
|
324
376
|
* ```tsx
|
|
325
377
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -349,7 +401,7 @@ declare module '../../index' {
|
|
|
349
401
|
* - 红色:起始点(20, 20)
|
|
350
402
|
* - 蓝色:两个控制点(20, 100) (200, 100)
|
|
351
403
|
* - 绿色:终止点(200, 20)
|
|
352
|
-
* @supported weapp, h5
|
|
404
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
353
405
|
* @example
|
|
354
406
|
* ```tsx
|
|
355
407
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -404,7 +456,7 @@ declare module '../../index' {
|
|
|
404
456
|
y: number,
|
|
405
457
|
): void
|
|
406
458
|
/** 清除画布上在该矩形区域内的内容
|
|
407
|
-
* @supported weapp, h5
|
|
459
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
408
460
|
* @example
|
|
409
461
|
* clearRect 并非画一个白色的矩形在地址区域,而是清空,为了有直观感受,对 canvas 加了一层背景色。
|
|
410
462
|
* ```html
|
|
@@ -432,7 +484,7 @@ declare module '../../index' {
|
|
|
432
484
|
height: number,
|
|
433
485
|
): void
|
|
434
486
|
/** 从原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内(不能访问画布上的其他区域)。可以在使用 `clip` 方法前通过使用 `save` 方法对当前画布区域进行保存,并在以后的任意时间通过`restore`方法对其进行恢复。
|
|
435
|
-
* @supported weapp, h5
|
|
487
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
436
488
|
* @example
|
|
437
489
|
* ```tsx
|
|
438
490
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -453,7 +505,7 @@ declare module '../../index' {
|
|
|
453
505
|
*/
|
|
454
506
|
clip(): void
|
|
455
507
|
/** 关闭一个路径。会连接起点和终点。如果关闭路径后没有调用 `fill` 或者 `stroke` 并开启了新的路径,那之前的路径将不会被渲染。
|
|
456
|
-
* @supported weapp, h5
|
|
508
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
457
509
|
* @example
|
|
458
510
|
* ```tsx
|
|
459
511
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -486,7 +538,7 @@ declare module '../../index' {
|
|
|
486
538
|
*/
|
|
487
539
|
closePath(): void
|
|
488
540
|
/** 创建一个圆形的渐变颜色。起点在圆心,终点在圆环。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](/docs/apis/canvas/CanvasGradient#addcolorstop) 来指定渐变点,至少要两个。
|
|
489
|
-
* @supported weapp, h5
|
|
541
|
+
* @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid
|
|
490
542
|
* @example
|
|
491
543
|
* ```tsx
|
|
492
544
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -510,7 +562,7 @@ declare module '../../index' {
|
|
|
510
562
|
r: number,
|
|
511
563
|
): CanvasGradient
|
|
512
564
|
/** 创建一个线性的渐变颜色。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](/docs/apis/canvas/CanvasGradient#addcolorstop) 来指定渐变点,至少要两个。
|
|
513
|
-
* @supported weapp, h5
|
|
565
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
514
566
|
* @example
|
|
515
567
|
* ```tsx
|
|
516
568
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -536,7 +588,7 @@ declare module '../../index' {
|
|
|
536
588
|
y1: number,
|
|
537
589
|
): CanvasGradient
|
|
538
590
|
/** 对指定的图像创建模式的方法,可在指定的方向上重复元图像
|
|
539
|
-
* @supported weapp, h5
|
|
591
|
+
* @supported weapp, alipay, jd, qq, h5, harmony_hybrid
|
|
540
592
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createPattern.html
|
|
541
593
|
*/
|
|
542
594
|
createPattern(
|
|
@@ -546,7 +598,7 @@ declare module '../../index' {
|
|
|
546
598
|
repetition: keyof CanvasContext.Repetition,
|
|
547
599
|
): CanvasPattern | null | Promise<CanvasPattern | null>
|
|
548
600
|
/** 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
|
|
549
|
-
* @supported weapp, h5
|
|
601
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
550
602
|
* @h5 第二次调用 draw 前需要等待上一次 draw 调用结束后再调用,否则新的一次 draw 调用栈不会清空而导致结果异常。
|
|
551
603
|
* @example
|
|
552
604
|
* 第二次 draw() reserve 为 true。所以保留了上一次的绘制结果,在上下文设置的 fillStyle 'red' 也变成了默认的 'black'。
|
|
@@ -579,9 +631,13 @@ declare module '../../index' {
|
|
|
579
631
|
reserve?: boolean,
|
|
580
632
|
/** 绘制完成后执行的回调函数 */
|
|
581
633
|
callback?: (...args: any[]) => any,
|
|
634
|
+
/** 是否使用硬件加速
|
|
635
|
+
* @supported jd
|
|
636
|
+
*/
|
|
637
|
+
useHardwareAccelerate?: boolean
|
|
582
638
|
): void | Promise<void>
|
|
583
639
|
/** 绘制图像到画布
|
|
584
|
-
* @supported weapp, h5
|
|
640
|
+
* @supported weapp, h5, harmony_hybrid
|
|
585
641
|
* @example
|
|
586
642
|
* 有三个版本的写法:
|
|
587
643
|
*
|
|
@@ -609,7 +665,7 @@ declare module '../../index' {
|
|
|
609
665
|
dy: number,
|
|
610
666
|
): void
|
|
611
667
|
/** 绘制图像到画布
|
|
612
|
-
* @supported weapp, h5
|
|
668
|
+
* @supported weapp, alipay, h5, harmony_hybrid
|
|
613
669
|
* @example
|
|
614
670
|
* 有三个版本的写法:
|
|
615
671
|
*
|
|
@@ -641,7 +697,7 @@ declare module '../../index' {
|
|
|
641
697
|
dHeight: number,
|
|
642
698
|
): void
|
|
643
699
|
/** 绘制图像到画布
|
|
644
|
-
* @supported weapp, h5
|
|
700
|
+
* @supported weapp, swan, jd, qq, tt, h5, harmony_hybrid
|
|
645
701
|
* @example
|
|
646
702
|
* 有三个版本的写法:
|
|
647
703
|
*
|
|
@@ -681,7 +737,7 @@ declare module '../../index' {
|
|
|
681
737
|
dHeight: number,
|
|
682
738
|
): void
|
|
683
739
|
/** 对当前路径中的内容进行填充。默认的填充色为黑色。
|
|
684
|
-
* @supported weapp, h5
|
|
740
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
685
741
|
* @example
|
|
686
742
|
* 如果当前路径没有闭合,fill() 方法会将起点和终点进行连接,然后填充。
|
|
687
743
|
*
|
|
@@ -718,7 +774,7 @@ declare module '../../index' {
|
|
|
718
774
|
*/
|
|
719
775
|
fill(): void
|
|
720
776
|
/** 填充一个矩形。用 [`setFillStyle`](/docs/apis/canvas/CanvasContext#setfillstyle) 设置矩形的填充色,如果没设置默认是黑色。
|
|
721
|
-
* @supported weapp, h5
|
|
777
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
722
778
|
* @example
|
|
723
779
|
* ```tsx
|
|
724
780
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -739,7 +795,7 @@ declare module '../../index' {
|
|
|
739
795
|
height: number,
|
|
740
796
|
): void
|
|
741
797
|
/** 在画布上绘制被填充的文本
|
|
742
|
-
* @supported weapp, h5
|
|
798
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
743
799
|
* @example
|
|
744
800
|
* ```tsx
|
|
745
801
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -761,7 +817,8 @@ declare module '../../index' {
|
|
|
761
817
|
maxWidth?: number,
|
|
762
818
|
): void
|
|
763
819
|
/** 增加一个新点,然后创建一条从上次指定点到目标点的线。用 `stroke` 方法来画线条
|
|
764
|
-
* @supported weapp, h5
|
|
820
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
821
|
+
|
|
765
822
|
* @example
|
|
766
823
|
* ```tsx
|
|
767
824
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -779,8 +836,8 @@ declare module '../../index' {
|
|
|
779
836
|
/** 目标位置的 y 坐标 */
|
|
780
837
|
y: number,
|
|
781
838
|
): void
|
|
782
|
-
/**
|
|
783
|
-
* @supported weapp, h5
|
|
839
|
+
/** 测量文本尺寸信息。目前仅返回文本宽度(width)。同步接口。
|
|
840
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
784
841
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.measureText.html
|
|
785
842
|
*/
|
|
786
843
|
measureText(
|
|
@@ -788,7 +845,7 @@ declare module '../../index' {
|
|
|
788
845
|
text: string,
|
|
789
846
|
): TextMetrics
|
|
790
847
|
/** 把路径移动到画布中的指定点,不创建线条。用 `stroke` 方法来画线条
|
|
791
|
-
* @supported weapp, h5
|
|
848
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
792
849
|
* @example
|
|
793
850
|
* ```tsx
|
|
794
851
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -814,7 +871,7 @@ declare module '../../index' {
|
|
|
814
871
|
* - 红色:起始点(20, 20)
|
|
815
872
|
* - 蓝色:控制点(20, 100)
|
|
816
873
|
* - 绿色:终止点(200, 20)
|
|
817
|
-
* @supported weapp, h5
|
|
874
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
818
875
|
* @example
|
|
819
876
|
* ```tsx
|
|
820
877
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -861,7 +918,7 @@ declare module '../../index' {
|
|
|
861
918
|
y: number,
|
|
862
919
|
): void
|
|
863
920
|
/** 创建一个矩形路径。需要用 [`fill`](/docs/apis/canvas/CanvasContext#fill) 或者 [`stroke`](/docs/apis/canvas/CanvasContext#stroke) 方法将矩形真正的画到 `canvas` 中
|
|
864
|
-
* @supported weapp, h5
|
|
921
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
865
922
|
* @example
|
|
866
923
|
* ```tsx
|
|
867
924
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -883,12 +940,12 @@ declare module '../../index' {
|
|
|
883
940
|
height: number,
|
|
884
941
|
): void
|
|
885
942
|
/** 重置绘图上下文状态
|
|
886
|
-
* @supported h5
|
|
943
|
+
* @supported h5, harmony_hybrid
|
|
887
944
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset
|
|
888
945
|
*/
|
|
889
946
|
reset(): void
|
|
890
947
|
/** 恢复之前保存的绘图上下文
|
|
891
|
-
* @supported weapp, h5
|
|
948
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
892
949
|
* @example
|
|
893
950
|
* ```tsx
|
|
894
951
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -905,7 +962,7 @@ declare module '../../index' {
|
|
|
905
962
|
*/
|
|
906
963
|
restore(): void
|
|
907
964
|
/** 以原点为中心顺时针旋转当前坐标轴。多次调用旋转的角度会叠加。原点可以用 `translate` 方法修改。
|
|
908
|
-
* @supported weapp, h5
|
|
965
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
909
966
|
* @example
|
|
910
967
|
* ```tsx
|
|
911
968
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -923,7 +980,7 @@ declare module '../../index' {
|
|
|
923
980
|
rotate: number,
|
|
924
981
|
): void
|
|
925
982
|
/** 保存绘图上下文。
|
|
926
|
-
* @supported weapp, h5
|
|
983
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
927
984
|
* @example
|
|
928
985
|
* ```tsx
|
|
929
986
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -940,7 +997,7 @@ declare module '../../index' {
|
|
|
940
997
|
*/
|
|
941
998
|
save(): void
|
|
942
999
|
/** 在调用后,之后创建的路径其横纵坐标会被缩放。多次调用倍数会相乘。
|
|
943
|
-
* @supported weapp, h5
|
|
1000
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
944
1001
|
* @example
|
|
945
1002
|
* ```tsx
|
|
946
1003
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -960,7 +1017,7 @@ declare module '../../index' {
|
|
|
960
1017
|
scaleHeight: number,
|
|
961
1018
|
): void
|
|
962
1019
|
/** 设置填充色。
|
|
963
|
-
* @supported weapp, h5
|
|
1020
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
964
1021
|
* @example
|
|
965
1022
|
* ```tsx
|
|
966
1023
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -975,7 +1032,7 @@ declare module '../../index' {
|
|
|
975
1032
|
color: string | CanvasGradient,
|
|
976
1033
|
): void
|
|
977
1034
|
/** 设置字体的字号
|
|
978
|
-
* @supported weapp, h5
|
|
1035
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
979
1036
|
* @example
|
|
980
1037
|
* ```tsx
|
|
981
1038
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -996,7 +1053,7 @@ declare module '../../index' {
|
|
|
996
1053
|
fontSize: number,
|
|
997
1054
|
): void
|
|
998
1055
|
/** 设置全局画笔透明度。
|
|
999
|
-
* @supported weapp, h5
|
|
1056
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1000
1057
|
* @example
|
|
1001
1058
|
* ```tsx
|
|
1002
1059
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1016,7 +1073,7 @@ declare module '../../index' {
|
|
|
1016
1073
|
alpha: number,
|
|
1017
1074
|
): void
|
|
1018
1075
|
/** 设置线条的端点样式
|
|
1019
|
-
* @supported weapp, h5
|
|
1076
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1020
1077
|
* @example
|
|
1021
1078
|
* ```tsx
|
|
1022
1079
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1051,7 +1108,7 @@ declare module '../../index' {
|
|
|
1051
1108
|
lineCap: keyof CanvasContext.LineCap,
|
|
1052
1109
|
): void
|
|
1053
1110
|
/** 设置虚线样式。
|
|
1054
|
-
* @supported weapp, h5
|
|
1111
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1055
1112
|
* @example
|
|
1056
1113
|
* ```tsx
|
|
1057
1114
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1071,7 +1128,7 @@ declare module '../../index' {
|
|
|
1071
1128
|
offset: number,
|
|
1072
1129
|
): void
|
|
1073
1130
|
/** 设置线条的交点样式
|
|
1074
|
-
* @supported weapp, h5
|
|
1131
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1075
1132
|
* @example
|
|
1076
1133
|
* ```tsx
|
|
1077
1134
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1110,7 +1167,7 @@ declare module '../../index' {
|
|
|
1110
1167
|
lineJoin: keyof CanvasContext.LineJoin,
|
|
1111
1168
|
): void
|
|
1112
1169
|
/** 设置线条的宽度
|
|
1113
|
-
* @supported weapp, h5
|
|
1170
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1114
1171
|
* @example
|
|
1115
1172
|
* ```tsx
|
|
1116
1173
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1142,7 +1199,7 @@ declare module '../../index' {
|
|
|
1142
1199
|
lineWidth: number,
|
|
1143
1200
|
): void
|
|
1144
1201
|
/** 设置最大斜接长度。斜接长度指的是在两条线交汇处内角和外角之间的距离。当 [CanvasContext.setLineJoin()](/docs/apis/canvas/CanvasContext#setlinejoin) 为 miter 时才有效。超过最大倾斜长度的,连接处将以 lineJoin 为 bevel 来显示。
|
|
1145
|
-
* @supported weapp, h5
|
|
1202
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1146
1203
|
* @example
|
|
1147
1204
|
* ```tsx
|
|
1148
1205
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1187,7 +1244,7 @@ declare module '../../index' {
|
|
|
1187
1244
|
miterLimit: number,
|
|
1188
1245
|
): void
|
|
1189
1246
|
/** 设定阴影样式。
|
|
1190
|
-
* @supported weapp, h5
|
|
1247
|
+
* @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid
|
|
1191
1248
|
* @example
|
|
1192
1249
|
* ```tsx
|
|
1193
1250
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1209,7 +1266,7 @@ declare module '../../index' {
|
|
|
1209
1266
|
color: string,
|
|
1210
1267
|
): void
|
|
1211
1268
|
/** 设置描边颜色。
|
|
1212
|
-
* @supported weapp, h5
|
|
1269
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1213
1270
|
* @example
|
|
1214
1271
|
* ```tsx
|
|
1215
1272
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1224,7 +1281,7 @@ declare module '../../index' {
|
|
|
1224
1281
|
color: string | CanvasGradient,
|
|
1225
1282
|
): void
|
|
1226
1283
|
/** 设置文字的对齐
|
|
1227
|
-
* @supported weapp, h5
|
|
1284
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1228
1285
|
* @example
|
|
1229
1286
|
* ```tsx
|
|
1230
1287
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1250,7 +1307,7 @@ declare module '../../index' {
|
|
|
1250
1307
|
align: keyof CanvasContext.Align,
|
|
1251
1308
|
): void
|
|
1252
1309
|
/** 设置文字的竖直对齐
|
|
1253
|
-
* @supported weapp, h5
|
|
1310
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1254
1311
|
* @example
|
|
1255
1312
|
* ```tsx
|
|
1256
1313
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1279,10 +1336,46 @@ declare module '../../index' {
|
|
|
1279
1336
|
textBaseline: keyof CanvasContext.TextBaseline,
|
|
1280
1337
|
): void
|
|
1281
1338
|
/** 使用矩阵重新设置(覆盖)当前变换的方法
|
|
1282
|
-
* @supported weapp, h5
|
|
1339
|
+
* @supported weapp, swan, jd, tt, h5, harmony_hybrid
|
|
1283
1340
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTransform.html
|
|
1284
1341
|
*/
|
|
1285
1342
|
setTransform(
|
|
1343
|
+
/** 水平缩放 */
|
|
1344
|
+
scaleX: number,
|
|
1345
|
+
/** 水平倾斜 */
|
|
1346
|
+
skewX: number,
|
|
1347
|
+
/** 垂直倾斜 */
|
|
1348
|
+
skewY: number,
|
|
1349
|
+
/** 垂直缩放 */
|
|
1350
|
+
scaleY: number,
|
|
1351
|
+
/** 水平移动 */
|
|
1352
|
+
translateX: number,
|
|
1353
|
+
/** 垂直移动 */
|
|
1354
|
+
translateY: number,
|
|
1355
|
+
): void
|
|
1356
|
+
/** 使用矩阵重新设置(覆盖)当前变换的方法
|
|
1357
|
+
* @supported alipay
|
|
1358
|
+
* @see https://opendocs.alipay.com/mini/api/wt6glg?pathHash=1d428fc1
|
|
1359
|
+
*/
|
|
1360
|
+
setTransform(
|
|
1361
|
+
/** 水平缩放 */
|
|
1362
|
+
scaleX: number,
|
|
1363
|
+
/** 垂直倾斜 */
|
|
1364
|
+
skewY: number,
|
|
1365
|
+
/** 水平倾斜 */
|
|
1366
|
+
skewX: number,
|
|
1367
|
+
/** 垂直缩放 */
|
|
1368
|
+
scaleY: number,
|
|
1369
|
+
/** 水平移动 */
|
|
1370
|
+
translateX: number,
|
|
1371
|
+
/** 垂直移动 */
|
|
1372
|
+
translateY: number,
|
|
1373
|
+
): void
|
|
1374
|
+
/** 使用矩阵重新设置(覆盖)当前变换的方法
|
|
1375
|
+
* @supported qq
|
|
1376
|
+
* @see https://q.qq.com/wiki/develop/miniprogram/API/canvas/canvasContext.html#settransform
|
|
1377
|
+
*/
|
|
1378
|
+
setTransform(
|
|
1286
1379
|
/** 水平缩放 */
|
|
1287
1380
|
scaleX: number,
|
|
1288
1381
|
/** 垂直缩放 */
|
|
@@ -1297,7 +1390,7 @@ declare module '../../index' {
|
|
|
1297
1390
|
translateY: number,
|
|
1298
1391
|
): void
|
|
1299
1392
|
/** 画出当前路径的边框。默认颜色色为黑色。
|
|
1300
|
-
* @supported weapp, h5
|
|
1393
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1301
1394
|
* @example
|
|
1302
1395
|
* ```tsx
|
|
1303
1396
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1332,7 +1425,7 @@ declare module '../../index' {
|
|
|
1332
1425
|
*/
|
|
1333
1426
|
stroke(): void
|
|
1334
1427
|
/** 画一个矩形(非填充)。 用 [`setStrokeStyle`](/docs/apis/canvas/CanvasContext#setstrokestyle) 设置矩形线条的颜色,如果没设置默认是黑色。
|
|
1335
|
-
* @supported weapp, h5
|
|
1428
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1336
1429
|
* @example
|
|
1337
1430
|
* ```tsx
|
|
1338
1431
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1353,7 +1446,7 @@ declare module '../../index' {
|
|
|
1353
1446
|
height: number,
|
|
1354
1447
|
): void
|
|
1355
1448
|
/** 给定的 (x, y) 位置绘制文本描边的方法
|
|
1356
|
-
* @supported weapp, h5
|
|
1449
|
+
* @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid
|
|
1357
1450
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeText.html
|
|
1358
1451
|
*/
|
|
1359
1452
|
strokeText(
|
|
@@ -1367,9 +1460,45 @@ declare module '../../index' {
|
|
|
1367
1460
|
maxWidth?: number,
|
|
1368
1461
|
): void
|
|
1369
1462
|
/** 使用矩阵多次叠加当前变换的方法
|
|
1370
|
-
* @supported weapp, h5
|
|
1463
|
+
* @supported weapp, jd, tt, h5, harmony_hybrid
|
|
1371
1464
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.transform.html
|
|
1372
1465
|
*/
|
|
1466
|
+
transform(
|
|
1467
|
+
/** 水平缩放 */
|
|
1468
|
+
scaleX: number,
|
|
1469
|
+
/** 水平倾斜 */
|
|
1470
|
+
skewX: number,
|
|
1471
|
+
/** 垂直倾斜 */
|
|
1472
|
+
skewY: number,
|
|
1473
|
+
/** 垂直缩放 */
|
|
1474
|
+
scaleY: number,
|
|
1475
|
+
/** 水平移动 */
|
|
1476
|
+
translateX: number,
|
|
1477
|
+
/** 垂直移动 */
|
|
1478
|
+
translateY: number,
|
|
1479
|
+
): void
|
|
1480
|
+
/** 使用矩阵叠加当前变换。矩阵由方法的参数进行描述,可以缩放、旋转、移动和倾斜上下文
|
|
1481
|
+
* @supported alipay
|
|
1482
|
+
* @see https://opendocs.alipay.com/mini/api/fv97do?pathHash=42ccd479
|
|
1483
|
+
*/
|
|
1484
|
+
transform(
|
|
1485
|
+
/** 水平缩放 */
|
|
1486
|
+
scaleX: number,
|
|
1487
|
+
/** 垂直倾斜 */
|
|
1488
|
+
skewY: number,
|
|
1489
|
+
/** 水平倾斜 */
|
|
1490
|
+
skewX: number,
|
|
1491
|
+
/** 垂直缩放 */
|
|
1492
|
+
scaleY: number,
|
|
1493
|
+
/** 水平移动 */
|
|
1494
|
+
translateX: number,
|
|
1495
|
+
/** 垂直移动 */
|
|
1496
|
+
translateY: number,
|
|
1497
|
+
): void
|
|
1498
|
+
/** 使用矩阵多次叠加当前变换的方法
|
|
1499
|
+
* @supported qq
|
|
1500
|
+
* @see https://q.qq.com/wiki/develop/miniprogram/API/canvas/canvasContext.html#transform
|
|
1501
|
+
*/
|
|
1373
1502
|
transform(
|
|
1374
1503
|
/** 水平缩放 */
|
|
1375
1504
|
scaleX: number,
|
|
@@ -1385,7 +1514,7 @@ declare module '../../index' {
|
|
|
1385
1514
|
translateY: number,
|
|
1386
1515
|
): void
|
|
1387
1516
|
/** 对当前坐标系的原点 (0, 0) 进行变换。默认的坐标系原点为页面左上角。
|
|
1388
|
-
* @supported weapp, h5
|
|
1517
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1389
1518
|
* @example
|
|
1390
1519
|
* ```tsx
|
|
1391
1520
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1447,13 +1576,34 @@ declare module '../../index' {
|
|
|
1447
1576
|
}
|
|
1448
1577
|
/** 参数 textBaseline 可选值 */
|
|
1449
1578
|
interface TextBaseline {
|
|
1450
|
-
/** 顶部对齐
|
|
1579
|
+
/** 顶部对齐
|
|
1580
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1581
|
+
*/
|
|
1451
1582
|
top
|
|
1452
|
-
/** 底部对齐
|
|
1583
|
+
/** 底部对齐
|
|
1584
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1585
|
+
*/
|
|
1453
1586
|
bottom
|
|
1454
|
-
/** 居中对齐
|
|
1587
|
+
/** 居中对齐
|
|
1588
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1589
|
+
*/
|
|
1455
1590
|
middle
|
|
1591
|
+
/**
|
|
1592
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1593
|
+
*/
|
|
1456
1594
|
normal
|
|
1595
|
+
/** 文本基线为悬挂基线。
|
|
1596
|
+
* @supported alipay, tt, h5
|
|
1597
|
+
*/
|
|
1598
|
+
hanging
|
|
1599
|
+
/** 文本基线是标准的字母基线
|
|
1600
|
+
* @supported alipay, tt, h5
|
|
1601
|
+
*/
|
|
1602
|
+
alphabetic
|
|
1603
|
+
/** 文字基线是表意字基线。如果字符本身超出了alphabetic 基线,那么ideograhpic基线位置在字符本身的底部。
|
|
1604
|
+
* @supported alipay, tt, h5
|
|
1605
|
+
*/
|
|
1606
|
+
ideographic
|
|
1457
1607
|
}
|
|
1458
1608
|
}
|
|
1459
1609
|
|
|
@@ -1463,7 +1613,7 @@ declare module '../../index' {
|
|
|
1463
1613
|
*/
|
|
1464
1614
|
interface CanvasGradient {
|
|
1465
1615
|
/** 添加颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染
|
|
1466
|
-
* @supported weapp
|
|
1616
|
+
* @supported weapp, alipay, swan, jd, qq, tt
|
|
1467
1617
|
* @example
|
|
1468
1618
|
* ```tsx
|
|
1469
1619
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1670,6 +1820,7 @@ declare module '../../index' {
|
|
|
1670
1820
|
/** origin: 发送完整的referrer; no-referrer: 不发送。
|
|
1671
1821
|
*
|
|
1672
1822
|
* 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本
|
|
1823
|
+
* @supported weapp
|
|
1673
1824
|
*/
|
|
1674
1825
|
referrerPolicy: string
|
|
1675
1826
|
/** 图片加载发生错误后触发的回调函数 */
|
|
@@ -1696,6 +1847,10 @@ declare module '../../index' {
|
|
|
1696
1847
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.html
|
|
1697
1848
|
*/
|
|
1698
1849
|
interface OffscreenCanvas {
|
|
1850
|
+
/** 画布宽度 */
|
|
1851
|
+
width: number
|
|
1852
|
+
/** 画布高度 */
|
|
1853
|
+
height: number
|
|
1699
1854
|
/** 创建一个图片对象。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法
|
|
1700
1855
|
*
|
|
1701
1856
|
* > 注意不允许混用 webgl 和 2d 画布创建的图片对象,使用时请注意尽量使用 canvas 自身的 createImage 创建图片对象。
|
|
@@ -1706,17 +1861,143 @@ declare module '../../index' {
|
|
|
1706
1861
|
/** 该方法返回 OffscreenCanvas 的绘图上下文
|
|
1707
1862
|
*
|
|
1708
1863
|
* > 当前仅支持获取 WebGL 绘图上下文
|
|
1709
|
-
* @supported weapp
|
|
1864
|
+
* @supported weapp, tt
|
|
1710
1865
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.getContext.html
|
|
1711
1866
|
*/
|
|
1712
|
-
getContext(contextType:
|
|
1867
|
+
getContext(contextType: 'webgl' | '2d'): RenderingContext
|
|
1713
1868
|
}
|
|
1714
1869
|
|
|
1715
1870
|
/** Canvas 2D API 的接口 Path2D 用来声明路径,此路径稍后会被CanvasRenderingContext2D 对象使用。CanvasRenderingContext2D 接口的 路径方法 也存在于 Path2D 这个接口中,允许你在 canvas 中根据需要创建可以保留并重用的路径。
|
|
1716
1871
|
* @supported weapp
|
|
1717
1872
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html
|
|
1718
1873
|
*/
|
|
1719
|
-
interface Path2D {
|
|
1874
|
+
interface Path2D {
|
|
1875
|
+
/** 添加路径到当前路径。
|
|
1876
|
+
* @supported weapp
|
|
1877
|
+
*/
|
|
1878
|
+
addPath(
|
|
1879
|
+
/** 添加的 Path2D 路径 */
|
|
1880
|
+
path: Path2D
|
|
1881
|
+
): void
|
|
1882
|
+
/** 添加一段圆弧路径
|
|
1883
|
+
* @supported weapp
|
|
1884
|
+
*/
|
|
1885
|
+
arc(
|
|
1886
|
+
/** 圆心横坐标 */
|
|
1887
|
+
x: number,
|
|
1888
|
+
/** 圆心纵坐标 */
|
|
1889
|
+
y: number,
|
|
1890
|
+
/** 圆形半径,必须为正数 */
|
|
1891
|
+
radius: number,
|
|
1892
|
+
/** 圆弧开始角度 */
|
|
1893
|
+
startAngle: number,
|
|
1894
|
+
/** 圆弧结束角度 */
|
|
1895
|
+
endAngle: number,
|
|
1896
|
+
/** 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle */
|
|
1897
|
+
counterclockwise: boolean
|
|
1898
|
+
): void
|
|
1899
|
+
/** 通过给定控制点添加一段圆弧路径
|
|
1900
|
+
* @supported weapp
|
|
1901
|
+
*/
|
|
1902
|
+
arcTo(
|
|
1903
|
+
/** 第一个控制点横坐标 */
|
|
1904
|
+
x1: number,
|
|
1905
|
+
/** 第一个控制点纵坐标 */
|
|
1906
|
+
y1: number,
|
|
1907
|
+
/** 第二个控制点横坐标 */
|
|
1908
|
+
x2: number,
|
|
1909
|
+
/** 第二个控制点纵坐标 */
|
|
1910
|
+
y2: number,
|
|
1911
|
+
/** 圆形半径,必须为非负数 */
|
|
1912
|
+
radius: number
|
|
1913
|
+
): void
|
|
1914
|
+
/** 添加三次贝塞尔曲线路径
|
|
1915
|
+
* @supported weapp
|
|
1916
|
+
*/
|
|
1917
|
+
bezierCurveTo(
|
|
1918
|
+
/** 第一个控制点横坐标 */
|
|
1919
|
+
cp1x: number,
|
|
1920
|
+
/** 第一个控制点纵坐标 */
|
|
1921
|
+
cp1y: number,
|
|
1922
|
+
/** 第二个控制点横坐标 */
|
|
1923
|
+
cp2x: number,
|
|
1924
|
+
/** 第二个控制点纵坐标 */
|
|
1925
|
+
cp2y: number,
|
|
1926
|
+
/** 结束点横坐标 */
|
|
1927
|
+
x: number,
|
|
1928
|
+
/** 结束点纵坐标 */
|
|
1929
|
+
y: number
|
|
1930
|
+
): void
|
|
1931
|
+
/** 闭合路径到起点
|
|
1932
|
+
* @supported weapp
|
|
1933
|
+
*/
|
|
1934
|
+
closePath(): void
|
|
1935
|
+
/** 添加椭圆弧路径
|
|
1936
|
+
* @supported weapp
|
|
1937
|
+
*/
|
|
1938
|
+
ellipse(
|
|
1939
|
+
/** 椭圆圆心横坐标 */
|
|
1940
|
+
x: number,
|
|
1941
|
+
/** 椭圆圆心纵坐标 */
|
|
1942
|
+
y: number,
|
|
1943
|
+
/** 椭圆长轴半径,必须为非负数 */
|
|
1944
|
+
radiusX: number,
|
|
1945
|
+
/** 椭圆短轴半径,必须为非负数 */
|
|
1946
|
+
radiusY: number,
|
|
1947
|
+
/** 椭圆旋转角度 */
|
|
1948
|
+
rotation: number,
|
|
1949
|
+
/** 圆弧开始角度 */
|
|
1950
|
+
startAngle: number,
|
|
1951
|
+
/** 圆弧结束角度 */
|
|
1952
|
+
endAngle: number,
|
|
1953
|
+
/** 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle */
|
|
1954
|
+
counterclockwise: boolean
|
|
1955
|
+
): void
|
|
1956
|
+
/** 添加直线路径
|
|
1957
|
+
* @supported weapp
|
|
1958
|
+
*/
|
|
1959
|
+
lineTo(
|
|
1960
|
+
/** 结束点横坐标 */
|
|
1961
|
+
x: number,
|
|
1962
|
+
/** 结束点纵坐标 */
|
|
1963
|
+
y: number
|
|
1964
|
+
): void
|
|
1965
|
+
/** 移动路径开始点
|
|
1966
|
+
* @supported weapp
|
|
1967
|
+
*/
|
|
1968
|
+
moveTo(
|
|
1969
|
+
/** 横坐标 */
|
|
1970
|
+
x: number,
|
|
1971
|
+
/** 纵坐标 */
|
|
1972
|
+
y: number
|
|
1973
|
+
): void
|
|
1974
|
+
/** 添加二次贝塞尔曲线路径
|
|
1975
|
+
* @supported weapp
|
|
1976
|
+
*/
|
|
1977
|
+
quadraticCurveTo(
|
|
1978
|
+
/** 控制点横坐标 */
|
|
1979
|
+
cpx: number,
|
|
1980
|
+
/** 控制点纵坐标 */
|
|
1981
|
+
cpy: number,
|
|
1982
|
+
/** 结束点横坐标 */
|
|
1983
|
+
x: number,
|
|
1984
|
+
/** 结束点纵坐标 */
|
|
1985
|
+
y: number
|
|
1986
|
+
): void
|
|
1987
|
+
/** 添加方形路径
|
|
1988
|
+
* @supported weapp
|
|
1989
|
+
*/
|
|
1990
|
+
rect(
|
|
1991
|
+
/** 开始点横坐标 */
|
|
1992
|
+
x: number,
|
|
1993
|
+
/** 开始点纵坐标 */
|
|
1994
|
+
y: number,
|
|
1995
|
+
/** 方形宽度,正数向右,负数向左 */
|
|
1996
|
+
width: number,
|
|
1997
|
+
/** 方形高度,正数向下,负数向上 */
|
|
1998
|
+
height: number
|
|
1999
|
+
): void
|
|
2000
|
+
}
|
|
1720
2001
|
|
|
1721
2002
|
/** Canvas 绘图上下文。
|
|
1722
2003
|
*
|
|
@@ -1724,14 +2005,37 @@ declare module '../../index' {
|
|
|
1724
2005
|
*
|
|
1725
2006
|
* - 通过 Canvas.getContext('2d') 接口可以获取 CanvasRenderingContext2D 对象,实现了 [HTML Canvas 2D Context](https://www.w3.org/TR/2dcontext/) 定义的属性、方法。
|
|
1726
2007
|
* - 通过 Canvas.getContext('webgl') 或 OffscreenCanvas.getContext('webgl') 接口可以获取 WebGLRenderingContext 对象,实现了 [WebGL 1.0](https://www.khronos.org/registry/webgl/specs/latest/1.0/) 定义的所有属性、方法、常量。
|
|
1727
|
-
*
|
|
2008
|
+
* - CanvasRenderingContext2D 的 drawImage 方法 2.10.0 起支持传入通过 SelectorQuery 获取的 video 对象,2.29.0 起支持传入开启了自定义渲染的 LivePusherContext 对象。
|
|
2009
|
+
* @supported weapp, alipay, tt
|
|
1728
2010
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html
|
|
1729
2011
|
*/
|
|
1730
2012
|
interface RenderingContext {}
|
|
1731
2013
|
|
|
1732
2014
|
interface TaroStatic {
|
|
1733
2015
|
/** 创建离屏 canvas 实例
|
|
1734
|
-
* @supported weapp
|
|
2016
|
+
* @supported weapp, tt
|
|
2017
|
+
* @example
|
|
2018
|
+
* ```tsx
|
|
2019
|
+
* // 创建离屏 2D canvas 实例
|
|
2020
|
+
* const canvas = Taro.createOffscreenCanvas({type: '2d', width: 300, height: 150})
|
|
2021
|
+
* // 获取 context。注意这里必须要与创建时的 type 一致
|
|
2022
|
+
* const context = canvas.getContext('2d')
|
|
2023
|
+
*
|
|
2024
|
+
* // 创建一个图片
|
|
2025
|
+
* const image = canvas.createImage()
|
|
2026
|
+
* // 等待图片加载
|
|
2027
|
+
* await new Promise(resolve => {
|
|
2028
|
+
* image.onload = resolve
|
|
2029
|
+
* image.src = IMAGE_URL // 要加载的图片 url
|
|
2030
|
+
* })
|
|
2031
|
+
*
|
|
2032
|
+
* // 把图片画到离屏 canvas 上
|
|
2033
|
+
* context.clearRect(0, 0, 300, 150)
|
|
2034
|
+
* context.drawImage(image, 0, 0, 300, 150)
|
|
2035
|
+
*
|
|
2036
|
+
* // 获取画完后的数据
|
|
2037
|
+
* const imgData = context.getImageData(0, 0, 300, 150)
|
|
2038
|
+
* ```
|
|
1735
2039
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html
|
|
1736
2040
|
*
|
|
1737
2041
|
* 有两个版本的写法:
|
|
@@ -1744,7 +2048,7 @@ declare module '../../index' {
|
|
|
1744
2048
|
/** 创建 canvas 的绘图上下文 [CanvasContext](/docs/apis/canvas/CanvasContext) 对象
|
|
1745
2049
|
*
|
|
1746
2050
|
* **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`;另外,Web 端需要在 `useReady` 回调中执行它,否则会因为底层 canvas 渲染出来之前而去获取 CanvasContext,导致其底层的 context 为 `undefined`,从而不能正常绘图。
|
|
1747
|
-
* @supported weapp, h5
|
|
2051
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1748
2052
|
* @example
|
|
1749
2053
|
* ```tsx
|
|
1750
2054
|
* import { useReady } from '@tarojs/taro'
|
|
@@ -1798,7 +2102,7 @@ declare module '../../index' {
|
|
|
1798
2102
|
* }
|
|
1799
2103
|
* })
|
|
1800
2104
|
* ```
|
|
1801
|
-
* @supported weapp, h5
|
|
2105
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
1802
2106
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
|
|
1803
2107
|
*/
|
|
1804
2108
|
canvasToTempFilePath(
|
|
@@ -1808,7 +2112,7 @@ declare module '../../index' {
|
|
|
1808
2112
|
): Promise<canvasToTempFilePath.SuccessCallbackResult>
|
|
1809
2113
|
|
|
1810
2114
|
/** 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 `<canvas>` 组件
|
|
1811
|
-
* @supported weapp, h5
|
|
2115
|
+
* @supported weapp, swan, jd, qq, h5, harmony_hybrid
|
|
1812
2116
|
* @example
|
|
1813
2117
|
* ```tsx
|
|
1814
2118
|
* const data = new Uint8ClampedArray([255, 0, 0, 1])
|
|
@@ -1830,7 +2134,7 @@ declare module '../../index' {
|
|
|
1830
2134
|
): Promise<TaroGeneral.CallbackResult>
|
|
1831
2135
|
|
|
1832
2136
|
/** 获取 canvas 区域隐含的像素数据。
|
|
1833
|
-
* @supported weapp, h5
|
|
2137
|
+
* @supported weapp, swan, jd, qq, h5, harmony_hybrid
|
|
1834
2138
|
* @example
|
|
1835
2139
|
* ```tsx
|
|
1836
2140
|
* Taro.canvasGetImageData({
|