@tarojs/taro 3.6.22-alpha.5 → 3.6.22-nightly.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro",
|
|
3
|
-
"version": "3.6.22-
|
|
3
|
+
"version": "3.6.22-nightly.2",
|
|
4
4
|
"description": "Taro framework",
|
|
5
5
|
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -21,11 +21,15 @@
|
|
|
21
21
|
"author": "O2Team",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tarojs/
|
|
25
|
-
"@tarojs/api": "3.6.22-alpha.5"
|
|
24
|
+
"@tarojs/api": "3.6.22-nightly.2"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@tarojs/helper": "3.6.22-
|
|
27
|
+
"@tarojs/helper": "3.6.22-nightly.2",
|
|
28
|
+
"@tarojs/runtime": "3.6.22-nightly.2"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@tarojs/helper": "~3.6.22-nightly.2",
|
|
32
|
+
"@tarojs/runtime": "~3.6.22-nightly.2"
|
|
29
33
|
},
|
|
30
34
|
"peerDependenciesMeta": {
|
|
31
35
|
"@types/react": {
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
550
602
|
* @h5 第二次调用 draw 前需要等待上一次 draw 调用结束后再调用,否则新的一次 draw 调用栈不会清空而导致结果异常。
|
|
551
603
|
* @example
|
|
552
604
|
* 第二次 draw() reserve 为 true。所以保留了上一次的绘制结果,在上下文设置的 fillStyle 'red' 也变成了默认的 'black'。
|
|
@@ -579,6 +631,10 @@ 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
640
|
* @supported weapp, h5
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
743
799
|
* @example
|
|
744
800
|
* ```tsx
|
|
745
801
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -761,7 +817,7 @@ 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
|
|
765
821
|
* @example
|
|
766
822
|
* ```tsx
|
|
767
823
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -779,8 +835,8 @@ declare module '../../index' {
|
|
|
779
835
|
/** 目标位置的 y 坐标 */
|
|
780
836
|
y: number,
|
|
781
837
|
): void
|
|
782
|
-
/**
|
|
783
|
-
* @supported weapp, h5
|
|
838
|
+
/** 测量文本尺寸信息。目前仅返回文本宽度(width)。同步接口。
|
|
839
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
784
840
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.measureText.html
|
|
785
841
|
*/
|
|
786
842
|
measureText(
|
|
@@ -788,7 +844,7 @@ declare module '../../index' {
|
|
|
788
844
|
text: string,
|
|
789
845
|
): TextMetrics
|
|
790
846
|
/** 把路径移动到画布中的指定点,不创建线条。用 `stroke` 方法来画线条
|
|
791
|
-
* @supported weapp, h5
|
|
847
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
792
848
|
* @example
|
|
793
849
|
* ```tsx
|
|
794
850
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -814,7 +870,7 @@ declare module '../../index' {
|
|
|
814
870
|
* - 红色:起始点(20, 20)
|
|
815
871
|
* - 蓝色:控制点(20, 100)
|
|
816
872
|
* - 绿色:终止点(200, 20)
|
|
817
|
-
* @supported weapp, h5
|
|
873
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
818
874
|
* @example
|
|
819
875
|
* ```tsx
|
|
820
876
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -861,7 +917,7 @@ declare module '../../index' {
|
|
|
861
917
|
y: number,
|
|
862
918
|
): void
|
|
863
919
|
/** 创建一个矩形路径。需要用 [`fill`](/docs/apis/canvas/CanvasContext#fill) 或者 [`stroke`](/docs/apis/canvas/CanvasContext#stroke) 方法将矩形真正的画到 `canvas` 中
|
|
864
|
-
* @supported weapp, h5
|
|
920
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
865
921
|
* @example
|
|
866
922
|
* ```tsx
|
|
867
923
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -888,7 +944,7 @@ declare module '../../index' {
|
|
|
888
944
|
*/
|
|
889
945
|
reset(): void
|
|
890
946
|
/** 恢复之前保存的绘图上下文
|
|
891
|
-
* @supported weapp, h5
|
|
947
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
892
948
|
* @example
|
|
893
949
|
* ```tsx
|
|
894
950
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -905,7 +961,7 @@ declare module '../../index' {
|
|
|
905
961
|
*/
|
|
906
962
|
restore(): void
|
|
907
963
|
/** 以原点为中心顺时针旋转当前坐标轴。多次调用旋转的角度会叠加。原点可以用 `translate` 方法修改。
|
|
908
|
-
* @supported weapp, h5
|
|
964
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
909
965
|
* @example
|
|
910
966
|
* ```tsx
|
|
911
967
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -923,7 +979,7 @@ declare module '../../index' {
|
|
|
923
979
|
rotate: number,
|
|
924
980
|
): void
|
|
925
981
|
/** 保存绘图上下文。
|
|
926
|
-
* @supported weapp, h5
|
|
982
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
927
983
|
* @example
|
|
928
984
|
* ```tsx
|
|
929
985
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -940,7 +996,7 @@ declare module '../../index' {
|
|
|
940
996
|
*/
|
|
941
997
|
save(): void
|
|
942
998
|
/** 在调用后,之后创建的路径其横纵坐标会被缩放。多次调用倍数会相乘。
|
|
943
|
-
* @supported weapp, h5
|
|
999
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
944
1000
|
* @example
|
|
945
1001
|
* ```tsx
|
|
946
1002
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -960,7 +1016,7 @@ declare module '../../index' {
|
|
|
960
1016
|
scaleHeight: number,
|
|
961
1017
|
): void
|
|
962
1018
|
/** 设置填充色。
|
|
963
|
-
* @supported weapp, h5
|
|
1019
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
964
1020
|
* @example
|
|
965
1021
|
* ```tsx
|
|
966
1022
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -975,7 +1031,7 @@ declare module '../../index' {
|
|
|
975
1031
|
color: string | CanvasGradient,
|
|
976
1032
|
): void
|
|
977
1033
|
/** 设置字体的字号
|
|
978
|
-
* @supported weapp, h5
|
|
1034
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
979
1035
|
* @example
|
|
980
1036
|
* ```tsx
|
|
981
1037
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -996,7 +1052,7 @@ declare module '../../index' {
|
|
|
996
1052
|
fontSize: number,
|
|
997
1053
|
): void
|
|
998
1054
|
/** 设置全局画笔透明度。
|
|
999
|
-
* @supported weapp, h5
|
|
1055
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1000
1056
|
* @example
|
|
1001
1057
|
* ```tsx
|
|
1002
1058
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1016,7 +1072,7 @@ declare module '../../index' {
|
|
|
1016
1072
|
alpha: number,
|
|
1017
1073
|
): void
|
|
1018
1074
|
/** 设置线条的端点样式
|
|
1019
|
-
* @supported weapp, h5
|
|
1075
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1020
1076
|
* @example
|
|
1021
1077
|
* ```tsx
|
|
1022
1078
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1051,7 +1107,7 @@ declare module '../../index' {
|
|
|
1051
1107
|
lineCap: keyof CanvasContext.LineCap,
|
|
1052
1108
|
): void
|
|
1053
1109
|
/** 设置虚线样式。
|
|
1054
|
-
* @supported weapp, h5
|
|
1110
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1055
1111
|
* @example
|
|
1056
1112
|
* ```tsx
|
|
1057
1113
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1071,7 +1127,7 @@ declare module '../../index' {
|
|
|
1071
1127
|
offset: number,
|
|
1072
1128
|
): void
|
|
1073
1129
|
/** 设置线条的交点样式
|
|
1074
|
-
* @supported weapp, h5
|
|
1130
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1075
1131
|
* @example
|
|
1076
1132
|
* ```tsx
|
|
1077
1133
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1110,7 +1166,7 @@ declare module '../../index' {
|
|
|
1110
1166
|
lineJoin: keyof CanvasContext.LineJoin,
|
|
1111
1167
|
): void
|
|
1112
1168
|
/** 设置线条的宽度
|
|
1113
|
-
* @supported weapp, h5
|
|
1169
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1114
1170
|
* @example
|
|
1115
1171
|
* ```tsx
|
|
1116
1172
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1142,7 +1198,7 @@ declare module '../../index' {
|
|
|
1142
1198
|
lineWidth: number,
|
|
1143
1199
|
): void
|
|
1144
1200
|
/** 设置最大斜接长度。斜接长度指的是在两条线交汇处内角和外角之间的距离。当 [CanvasContext.setLineJoin()](/docs/apis/canvas/CanvasContext#setlinejoin) 为 miter 时才有效。超过最大倾斜长度的,连接处将以 lineJoin 为 bevel 来显示。
|
|
1145
|
-
* @supported weapp, h5
|
|
1201
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1146
1202
|
* @example
|
|
1147
1203
|
* ```tsx
|
|
1148
1204
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1187,7 +1243,7 @@ declare module '../../index' {
|
|
|
1187
1243
|
miterLimit: number,
|
|
1188
1244
|
): void
|
|
1189
1245
|
/** 设定阴影样式。
|
|
1190
|
-
* @supported weapp, h5
|
|
1246
|
+
* @supported weapp, alipay, swan, jd, qq, h5
|
|
1191
1247
|
* @example
|
|
1192
1248
|
* ```tsx
|
|
1193
1249
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1209,7 +1265,7 @@ declare module '../../index' {
|
|
|
1209
1265
|
color: string,
|
|
1210
1266
|
): void
|
|
1211
1267
|
/** 设置描边颜色。
|
|
1212
|
-
* @supported weapp, h5
|
|
1268
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1213
1269
|
* @example
|
|
1214
1270
|
* ```tsx
|
|
1215
1271
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1224,7 +1280,7 @@ declare module '../../index' {
|
|
|
1224
1280
|
color: string | CanvasGradient,
|
|
1225
1281
|
): void
|
|
1226
1282
|
/** 设置文字的对齐
|
|
1227
|
-
* @supported weapp, h5
|
|
1283
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1228
1284
|
* @example
|
|
1229
1285
|
* ```tsx
|
|
1230
1286
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1250,7 +1306,7 @@ declare module '../../index' {
|
|
|
1250
1306
|
align: keyof CanvasContext.Align,
|
|
1251
1307
|
): void
|
|
1252
1308
|
/** 设置文字的竖直对齐
|
|
1253
|
-
* @supported weapp, h5
|
|
1309
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1254
1310
|
* @example
|
|
1255
1311
|
* ```tsx
|
|
1256
1312
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1279,10 +1335,46 @@ declare module '../../index' {
|
|
|
1279
1335
|
textBaseline: keyof CanvasContext.TextBaseline,
|
|
1280
1336
|
): void
|
|
1281
1337
|
/** 使用矩阵重新设置(覆盖)当前变换的方法
|
|
1282
|
-
* @supported weapp, h5
|
|
1338
|
+
* @supported weapp, swan, jd, tt, h5
|
|
1283
1339
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTransform.html
|
|
1284
1340
|
*/
|
|
1285
1341
|
setTransform(
|
|
1342
|
+
/** 水平缩放 */
|
|
1343
|
+
scaleX: number,
|
|
1344
|
+
/** 水平倾斜 */
|
|
1345
|
+
skewX: number,
|
|
1346
|
+
/** 垂直倾斜 */
|
|
1347
|
+
skewY: number,
|
|
1348
|
+
/** 垂直缩放 */
|
|
1349
|
+
scaleY: number,
|
|
1350
|
+
/** 水平移动 */
|
|
1351
|
+
translateX: number,
|
|
1352
|
+
/** 垂直移动 */
|
|
1353
|
+
translateY: number,
|
|
1354
|
+
): void
|
|
1355
|
+
/** 使用矩阵重新设置(覆盖)当前变换的方法
|
|
1356
|
+
* @supported alipay
|
|
1357
|
+
* @see https://opendocs.alipay.com/mini/api/wt6glg?pathHash=1d428fc1
|
|
1358
|
+
*/
|
|
1359
|
+
setTransform(
|
|
1360
|
+
/** 水平缩放 */
|
|
1361
|
+
scaleX: number,
|
|
1362
|
+
/** 垂直倾斜 */
|
|
1363
|
+
skewY: number,
|
|
1364
|
+
/** 水平倾斜 */
|
|
1365
|
+
skewX: number,
|
|
1366
|
+
/** 垂直缩放 */
|
|
1367
|
+
scaleY: number,
|
|
1368
|
+
/** 水平移动 */
|
|
1369
|
+
translateX: number,
|
|
1370
|
+
/** 垂直移动 */
|
|
1371
|
+
translateY: number,
|
|
1372
|
+
): void
|
|
1373
|
+
/** 使用矩阵重新设置(覆盖)当前变换的方法
|
|
1374
|
+
* @supported qq
|
|
1375
|
+
* @see https://q.qq.com/wiki/develop/miniprogram/API/canvas/canvasContext.html#settransform
|
|
1376
|
+
*/
|
|
1377
|
+
setTransform(
|
|
1286
1378
|
/** 水平缩放 */
|
|
1287
1379
|
scaleX: number,
|
|
1288
1380
|
/** 垂直缩放 */
|
|
@@ -1297,7 +1389,7 @@ declare module '../../index' {
|
|
|
1297
1389
|
translateY: number,
|
|
1298
1390
|
): void
|
|
1299
1391
|
/** 画出当前路径的边框。默认颜色色为黑色。
|
|
1300
|
-
* @supported weapp, h5
|
|
1392
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1301
1393
|
* @example
|
|
1302
1394
|
* ```tsx
|
|
1303
1395
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1332,7 +1424,7 @@ declare module '../../index' {
|
|
|
1332
1424
|
*/
|
|
1333
1425
|
stroke(): void
|
|
1334
1426
|
/** 画一个矩形(非填充)。 用 [`setStrokeStyle`](/docs/apis/canvas/CanvasContext#setstrokestyle) 设置矩形线条的颜色,如果没设置默认是黑色。
|
|
1335
|
-
* @supported weapp, h5
|
|
1427
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1336
1428
|
* @example
|
|
1337
1429
|
* ```tsx
|
|
1338
1430
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1353,7 +1445,7 @@ declare module '../../index' {
|
|
|
1353
1445
|
height: number,
|
|
1354
1446
|
): void
|
|
1355
1447
|
/** 给定的 (x, y) 位置绘制文本描边的方法
|
|
1356
|
-
* @supported weapp, h5
|
|
1448
|
+
* @supported weapp, alipay, swan, jd, qq, h5
|
|
1357
1449
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeText.html
|
|
1358
1450
|
*/
|
|
1359
1451
|
strokeText(
|
|
@@ -1367,9 +1459,45 @@ declare module '../../index' {
|
|
|
1367
1459
|
maxWidth?: number,
|
|
1368
1460
|
): void
|
|
1369
1461
|
/** 使用矩阵多次叠加当前变换的方法
|
|
1370
|
-
* @supported weapp, h5
|
|
1462
|
+
* @supported weapp, jd, tt, h5
|
|
1371
1463
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.transform.html
|
|
1372
1464
|
*/
|
|
1465
|
+
transform(
|
|
1466
|
+
/** 水平缩放 */
|
|
1467
|
+
scaleX: number,
|
|
1468
|
+
/** 水平倾斜 */
|
|
1469
|
+
skewX: number,
|
|
1470
|
+
/** 垂直倾斜 */
|
|
1471
|
+
skewY: number,
|
|
1472
|
+
/** 垂直缩放 */
|
|
1473
|
+
scaleY: number,
|
|
1474
|
+
/** 水平移动 */
|
|
1475
|
+
translateX: number,
|
|
1476
|
+
/** 垂直移动 */
|
|
1477
|
+
translateY: number,
|
|
1478
|
+
): void
|
|
1479
|
+
/** 使用矩阵叠加当前变换。矩阵由方法的参数进行描述,可以缩放、旋转、移动和倾斜上下文
|
|
1480
|
+
* @supported alipay
|
|
1481
|
+
* @see https://opendocs.alipay.com/mini/api/fv97do?pathHash=42ccd479
|
|
1482
|
+
*/
|
|
1483
|
+
transform(
|
|
1484
|
+
/** 水平缩放 */
|
|
1485
|
+
scaleX: number,
|
|
1486
|
+
/** 垂直倾斜 */
|
|
1487
|
+
skewY: number,
|
|
1488
|
+
/** 水平倾斜 */
|
|
1489
|
+
skewX: number,
|
|
1490
|
+
/** 垂直缩放 */
|
|
1491
|
+
scaleY: number,
|
|
1492
|
+
/** 水平移动 */
|
|
1493
|
+
translateX: number,
|
|
1494
|
+
/** 垂直移动 */
|
|
1495
|
+
translateY: number,
|
|
1496
|
+
): void
|
|
1497
|
+
/** 使用矩阵多次叠加当前变换的方法
|
|
1498
|
+
* @supported qq
|
|
1499
|
+
* @see https://q.qq.com/wiki/develop/miniprogram/API/canvas/canvasContext.html#transform
|
|
1500
|
+
*/
|
|
1373
1501
|
transform(
|
|
1374
1502
|
/** 水平缩放 */
|
|
1375
1503
|
scaleX: number,
|
|
@@ -1385,7 +1513,7 @@ declare module '../../index' {
|
|
|
1385
1513
|
translateY: number,
|
|
1386
1514
|
): void
|
|
1387
1515
|
/** 对当前坐标系的原点 (0, 0) 进行变换。默认的坐标系原点为页面左上角。
|
|
1388
|
-
* @supported weapp, h5
|
|
1516
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1389
1517
|
* @example
|
|
1390
1518
|
* ```tsx
|
|
1391
1519
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1447,13 +1575,34 @@ declare module '../../index' {
|
|
|
1447
1575
|
}
|
|
1448
1576
|
/** 参数 textBaseline 可选值 */
|
|
1449
1577
|
interface TextBaseline {
|
|
1450
|
-
/** 顶部对齐
|
|
1578
|
+
/** 顶部对齐
|
|
1579
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1580
|
+
*/
|
|
1451
1581
|
top
|
|
1452
|
-
/** 底部对齐
|
|
1582
|
+
/** 底部对齐
|
|
1583
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1584
|
+
*/
|
|
1453
1585
|
bottom
|
|
1454
|
-
/** 居中对齐
|
|
1586
|
+
/** 居中对齐
|
|
1587
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1588
|
+
*/
|
|
1455
1589
|
middle
|
|
1590
|
+
/**
|
|
1591
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1592
|
+
*/
|
|
1456
1593
|
normal
|
|
1594
|
+
/** 文本基线为悬挂基线。
|
|
1595
|
+
* @supported alipay, tt, h5
|
|
1596
|
+
*/
|
|
1597
|
+
hanging
|
|
1598
|
+
/** 文本基线是标准的字母基线
|
|
1599
|
+
* @supported alipay, tt, h5
|
|
1600
|
+
*/
|
|
1601
|
+
alphabetic
|
|
1602
|
+
/** 文字基线是表意字基线。如果字符本身超出了alphabetic 基线,那么ideograhpic基线位置在字符本身的底部。
|
|
1603
|
+
* @supported alipay, tt, h5
|
|
1604
|
+
*/
|
|
1605
|
+
ideographic
|
|
1457
1606
|
}
|
|
1458
1607
|
}
|
|
1459
1608
|
|
|
@@ -1463,7 +1612,7 @@ declare module '../../index' {
|
|
|
1463
1612
|
*/
|
|
1464
1613
|
interface CanvasGradient {
|
|
1465
1614
|
/** 添加颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染
|
|
1466
|
-
* @supported weapp
|
|
1615
|
+
* @supported weapp, alipay, swan, jd, qq, tt
|
|
1467
1616
|
* @example
|
|
1468
1617
|
* ```tsx
|
|
1469
1618
|
* const ctx = Taro.createCanvasContext('myCanvas')
|
|
@@ -1670,6 +1819,7 @@ declare module '../../index' {
|
|
|
1670
1819
|
/** origin: 发送完整的referrer; no-referrer: 不发送。
|
|
1671
1820
|
*
|
|
1672
1821
|
* 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本
|
|
1822
|
+
* @supported weapp
|
|
1673
1823
|
*/
|
|
1674
1824
|
referrerPolicy: string
|
|
1675
1825
|
/** 图片加载发生错误后触发的回调函数 */
|
|
@@ -1696,6 +1846,10 @@ declare module '../../index' {
|
|
|
1696
1846
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.html
|
|
1697
1847
|
*/
|
|
1698
1848
|
interface OffscreenCanvas {
|
|
1849
|
+
/** 画布宽度 */
|
|
1850
|
+
width: number
|
|
1851
|
+
/** 画布高度 */
|
|
1852
|
+
height: number
|
|
1699
1853
|
/** 创建一个图片对象。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法
|
|
1700
1854
|
*
|
|
1701
1855
|
* > 注意不允许混用 webgl 和 2d 画布创建的图片对象,使用时请注意尽量使用 canvas 自身的 createImage 创建图片对象。
|
|
@@ -1706,17 +1860,143 @@ declare module '../../index' {
|
|
|
1706
1860
|
/** 该方法返回 OffscreenCanvas 的绘图上下文
|
|
1707
1861
|
*
|
|
1708
1862
|
* > 当前仅支持获取 WebGL 绘图上下文
|
|
1709
|
-
* @supported weapp
|
|
1863
|
+
* @supported weapp, tt
|
|
1710
1864
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.getContext.html
|
|
1711
1865
|
*/
|
|
1712
|
-
getContext(contextType:
|
|
1866
|
+
getContext(contextType: 'webgl' | '2d'): RenderingContext
|
|
1713
1867
|
}
|
|
1714
1868
|
|
|
1715
1869
|
/** Canvas 2D API 的接口 Path2D 用来声明路径,此路径稍后会被CanvasRenderingContext2D 对象使用。CanvasRenderingContext2D 接口的 路径方法 也存在于 Path2D 这个接口中,允许你在 canvas 中根据需要创建可以保留并重用的路径。
|
|
1716
1870
|
* @supported weapp
|
|
1717
1871
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html
|
|
1718
1872
|
*/
|
|
1719
|
-
interface Path2D {
|
|
1873
|
+
interface Path2D {
|
|
1874
|
+
/** 添加路径到当前路径。
|
|
1875
|
+
* @supported weapp
|
|
1876
|
+
*/
|
|
1877
|
+
addPath(
|
|
1878
|
+
/** 添加的 Path2D 路径 */
|
|
1879
|
+
path: Path2D
|
|
1880
|
+
): void
|
|
1881
|
+
/** 添加一段圆弧路径
|
|
1882
|
+
* @supported weapp
|
|
1883
|
+
*/
|
|
1884
|
+
arc(
|
|
1885
|
+
/** 圆心横坐标 */
|
|
1886
|
+
x: number,
|
|
1887
|
+
/** 圆心纵坐标 */
|
|
1888
|
+
y: number,
|
|
1889
|
+
/** 圆形半径,必须为正数 */
|
|
1890
|
+
radius: number,
|
|
1891
|
+
/** 圆弧开始角度 */
|
|
1892
|
+
startAngle: number,
|
|
1893
|
+
/** 圆弧结束角度 */
|
|
1894
|
+
endAngle: number,
|
|
1895
|
+
/** 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle */
|
|
1896
|
+
counterclockwise: boolean
|
|
1897
|
+
): void
|
|
1898
|
+
/** 通过给定控制点添加一段圆弧路径
|
|
1899
|
+
* @supported weapp
|
|
1900
|
+
*/
|
|
1901
|
+
arcTo(
|
|
1902
|
+
/** 第一个控制点横坐标 */
|
|
1903
|
+
x1: number,
|
|
1904
|
+
/** 第一个控制点纵坐标 */
|
|
1905
|
+
y1: number,
|
|
1906
|
+
/** 第二个控制点横坐标 */
|
|
1907
|
+
x2: number,
|
|
1908
|
+
/** 第二个控制点纵坐标 */
|
|
1909
|
+
y2: number,
|
|
1910
|
+
/** 圆形半径,必须为非负数 */
|
|
1911
|
+
radius: number
|
|
1912
|
+
): void
|
|
1913
|
+
/** 添加三次贝塞尔曲线路径
|
|
1914
|
+
* @supported weapp
|
|
1915
|
+
*/
|
|
1916
|
+
bezierCurveTo(
|
|
1917
|
+
/** 第一个控制点横坐标 */
|
|
1918
|
+
cp1x: number,
|
|
1919
|
+
/** 第一个控制点纵坐标 */
|
|
1920
|
+
cp1y: number,
|
|
1921
|
+
/** 第二个控制点横坐标 */
|
|
1922
|
+
cp2x: number,
|
|
1923
|
+
/** 第二个控制点纵坐标 */
|
|
1924
|
+
cp2y: number,
|
|
1925
|
+
/** 结束点横坐标 */
|
|
1926
|
+
x: number,
|
|
1927
|
+
/** 结束点纵坐标 */
|
|
1928
|
+
y: number
|
|
1929
|
+
): void
|
|
1930
|
+
/** 闭合路径到起点
|
|
1931
|
+
* @supported weapp
|
|
1932
|
+
*/
|
|
1933
|
+
closePath(): void
|
|
1934
|
+
/** 添加椭圆弧路径
|
|
1935
|
+
* @supported weapp
|
|
1936
|
+
*/
|
|
1937
|
+
ellipse(
|
|
1938
|
+
/** 椭圆圆心横坐标 */
|
|
1939
|
+
x: number,
|
|
1940
|
+
/** 椭圆圆心纵坐标 */
|
|
1941
|
+
y: number,
|
|
1942
|
+
/** 椭圆长轴半径,必须为非负数 */
|
|
1943
|
+
radiusX: number,
|
|
1944
|
+
/** 椭圆短轴半径,必须为非负数 */
|
|
1945
|
+
radiusY: number,
|
|
1946
|
+
/** 椭圆旋转角度 */
|
|
1947
|
+
rotation: number,
|
|
1948
|
+
/** 圆弧开始角度 */
|
|
1949
|
+
startAngle: number,
|
|
1950
|
+
/** 圆弧结束角度 */
|
|
1951
|
+
endAngle: number,
|
|
1952
|
+
/** 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle */
|
|
1953
|
+
counterclockwise: boolean
|
|
1954
|
+
): void
|
|
1955
|
+
/** 添加直线路径
|
|
1956
|
+
* @supported weapp
|
|
1957
|
+
*/
|
|
1958
|
+
lineTo(
|
|
1959
|
+
/** 结束点横坐标 */
|
|
1960
|
+
x: number,
|
|
1961
|
+
/** 结束点纵坐标 */
|
|
1962
|
+
y: number
|
|
1963
|
+
): void
|
|
1964
|
+
/** 移动路径开始点
|
|
1965
|
+
* @supported weapp
|
|
1966
|
+
*/
|
|
1967
|
+
moveTo(
|
|
1968
|
+
/** 横坐标 */
|
|
1969
|
+
x: number,
|
|
1970
|
+
/** 纵坐标 */
|
|
1971
|
+
y: number
|
|
1972
|
+
): void
|
|
1973
|
+
/** 添加二次贝塞尔曲线路径
|
|
1974
|
+
* @supported weapp
|
|
1975
|
+
*/
|
|
1976
|
+
quadraticCurveTo(
|
|
1977
|
+
/** 控制点横坐标 */
|
|
1978
|
+
cpx: number,
|
|
1979
|
+
/** 控制点纵坐标 */
|
|
1980
|
+
cpy: number,
|
|
1981
|
+
/** 结束点横坐标 */
|
|
1982
|
+
x: number,
|
|
1983
|
+
/** 结束点纵坐标 */
|
|
1984
|
+
y: number
|
|
1985
|
+
): void
|
|
1986
|
+
/** 添加方形路径
|
|
1987
|
+
* @supported weapp
|
|
1988
|
+
*/
|
|
1989
|
+
rect(
|
|
1990
|
+
/** 开始点横坐标 */
|
|
1991
|
+
x: number,
|
|
1992
|
+
/** 开始点纵坐标 */
|
|
1993
|
+
y: number,
|
|
1994
|
+
/** 方形宽度,正数向右,负数向左 */
|
|
1995
|
+
width: number,
|
|
1996
|
+
/** 方形高度,正数向下,负数向上 */
|
|
1997
|
+
height: number
|
|
1998
|
+
): void
|
|
1999
|
+
}
|
|
1720
2000
|
|
|
1721
2001
|
/** Canvas 绘图上下文。
|
|
1722
2002
|
*
|
|
@@ -1724,14 +2004,37 @@ declare module '../../index' {
|
|
|
1724
2004
|
*
|
|
1725
2005
|
* - 通过 Canvas.getContext('2d') 接口可以获取 CanvasRenderingContext2D 对象,实现了 [HTML Canvas 2D Context](https://www.w3.org/TR/2dcontext/) 定义的属性、方法。
|
|
1726
2006
|
* - 通过 Canvas.getContext('webgl') 或 OffscreenCanvas.getContext('webgl') 接口可以获取 WebGLRenderingContext 对象,实现了 [WebGL 1.0](https://www.khronos.org/registry/webgl/specs/latest/1.0/) 定义的所有属性、方法、常量。
|
|
1727
|
-
*
|
|
2007
|
+
* - CanvasRenderingContext2D 的 drawImage 方法 2.10.0 起支持传入通过 SelectorQuery 获取的 video 对象,2.29.0 起支持传入开启了自定义渲染的 LivePusherContext 对象。
|
|
2008
|
+
* @supported weapp, alipay, tt
|
|
1728
2009
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html
|
|
1729
2010
|
*/
|
|
1730
2011
|
interface RenderingContext {}
|
|
1731
2012
|
|
|
1732
2013
|
interface TaroStatic {
|
|
1733
2014
|
/** 创建离屏 canvas 实例
|
|
1734
|
-
* @supported weapp
|
|
2015
|
+
* @supported weapp, tt
|
|
2016
|
+
* @example
|
|
2017
|
+
* ```tsx
|
|
2018
|
+
* // 创建离屏 2D canvas 实例
|
|
2019
|
+
* const canvas = Taro.createOffscreenCanvas({type: '2d', width: 300, height: 150})
|
|
2020
|
+
* // 获取 context。注意这里必须要与创建时的 type 一致
|
|
2021
|
+
* const context = canvas.getContext('2d')
|
|
2022
|
+
*
|
|
2023
|
+
* // 创建一个图片
|
|
2024
|
+
* const image = canvas.createImage()
|
|
2025
|
+
* // 等待图片加载
|
|
2026
|
+
* await new Promise(resolve => {
|
|
2027
|
+
* image.onload = resolve
|
|
2028
|
+
* image.src = IMAGE_URL // 要加载的图片 url
|
|
2029
|
+
* })
|
|
2030
|
+
*
|
|
2031
|
+
* // 把图片画到离屏 canvas 上
|
|
2032
|
+
* context.clearRect(0, 0, 300, 150)
|
|
2033
|
+
* context.drawImage(image, 0, 0, 300, 150)
|
|
2034
|
+
*
|
|
2035
|
+
* // 获取画完后的数据
|
|
2036
|
+
* const imgData = context.getImageData(0, 0, 300, 150)
|
|
2037
|
+
* ```
|
|
1735
2038
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html
|
|
1736
2039
|
*
|
|
1737
2040
|
* 有两个版本的写法:
|
|
@@ -1744,7 +2047,7 @@ declare module '../../index' {
|
|
|
1744
2047
|
/** 创建 canvas 的绘图上下文 [CanvasContext](/docs/apis/canvas/CanvasContext) 对象
|
|
1745
2048
|
*
|
|
1746
2049
|
* **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`;另外,Web 端需要在 `useReady` 回调中执行它,否则会因为底层 canvas 渲染出来之前而去获取 CanvasContext,导致其底层的 context 为 `undefined`,从而不能正常绘图。
|
|
1747
|
-
* @supported weapp, h5
|
|
2050
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1748
2051
|
* @example
|
|
1749
2052
|
* ```tsx
|
|
1750
2053
|
* import { useReady } from '@tarojs/taro'
|
|
@@ -1798,7 +2101,7 @@ declare module '../../index' {
|
|
|
1798
2101
|
* }
|
|
1799
2102
|
* })
|
|
1800
2103
|
* ```
|
|
1801
|
-
* @supported weapp, h5
|
|
2104
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
1802
2105
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
|
|
1803
2106
|
*/
|
|
1804
2107
|
canvasToTempFilePath(
|
|
@@ -1808,7 +2111,7 @@ declare module '../../index' {
|
|
|
1808
2111
|
): Promise<canvasToTempFilePath.SuccessCallbackResult>
|
|
1809
2112
|
|
|
1810
2113
|
/** 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 `<canvas>` 组件
|
|
1811
|
-
* @supported weapp, h5
|
|
2114
|
+
* @supported weapp, swan, jd, qq, h5
|
|
1812
2115
|
* @example
|
|
1813
2116
|
* ```tsx
|
|
1814
2117
|
* const data = new Uint8ClampedArray([255, 0, 0, 1])
|
|
@@ -1830,7 +2133,7 @@ declare module '../../index' {
|
|
|
1830
2133
|
): Promise<TaroGeneral.CallbackResult>
|
|
1831
2134
|
|
|
1832
2135
|
/** 获取 canvas 区域隐含的像素数据。
|
|
1833
|
-
* @supported weapp, h5
|
|
2136
|
+
* @supported weapp, swan, jd, qq, h5
|
|
1834
2137
|
* @example
|
|
1835
2138
|
* ```tsx
|
|
1836
2139
|
* Taro.canvasGetImageData({
|