@nativescript/canvas 1.1.0 → 2.0.0-alpha.1
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/Canvas/common.d.ts +1 -5
- package/Canvas/common.js +41 -133
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +4 -4
- package/Canvas/index.android.js +62 -52
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +0 -4
- package/Canvas/index.ios.d.ts +0 -2
- package/Canvas/index.ios.js +24 -42
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.android.d.ts +2 -0
- package/Canvas2D/CanvasGradient/CanvasGradient.android.js +10 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.android.js.map +1 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.android.d.ts +2 -0
- package/Canvas2D/CanvasPattern/CanvasPattern.android.js +10 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.android.js.map +1 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.ios.d.ts +0 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.ios.js +0 -3
- package/Canvas2D/CanvasPattern/CanvasPattern.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/common.d.ts +1 -3
- package/Canvas2D/CanvasRenderingContext2D/common.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.android.d.ts +5 -6
- package/Canvas2D/CanvasRenderingContext2D/index.android.js +212 -394
- package/Canvas2D/CanvasRenderingContext2D/index.android.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -6
- package/Canvas2D/CanvasRenderingContext2D/index.ios.d.ts +0 -3
- package/Canvas2D/CanvasRenderingContext2D/index.ios.js +92 -109
- package/Canvas2D/CanvasRenderingContext2D/index.ios.js.map +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.android.d.ts +24 -0
- package/Canvas2D/DOMMatrix/DOMMatrix.android.js +81 -46
- package/Canvas2D/DOMMatrix/DOMMatrix.android.js.map +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.d.ts +3 -2
- package/Canvas2D/DOMMatrix/common.d.ts +0 -2
- package/Canvas2D/DOMMatrix/common.js +0 -7
- package/Canvas2D/DOMMatrix/common.js.map +1 -1
- package/Canvas2D/ImageData/ImageData.android.d.ts +4 -5
- package/Canvas2D/ImageData/ImageData.android.js +48 -29
- package/Canvas2D/ImageData/ImageData.android.js.map +1 -1
- package/Canvas2D/ImageData/ImageData.d.ts +4 -2
- package/Canvas2D/ImageData/common.d.ts +0 -1
- package/Canvas2D/ImageData/common.js +1 -4
- package/Canvas2D/ImageData/common.js.map +1 -1
- package/Canvas2D/Path2D/Path2D.android.d.ts +3 -2
- package/Canvas2D/Path2D/Path2D.android.js +45 -25
- package/Canvas2D/Path2D/Path2D.android.js.map +1 -1
- package/Canvas2D/Path2D/Path2D.d.ts +0 -4
- package/Canvas2D/Path2D/Path2D.ios.d.ts +0 -2
- package/Canvas2D/Path2D/Path2D.ios.js +1 -9
- package/Canvas2D/Path2D/Path2D.ios.js.map +1 -1
- package/Canvas2D/Path2D/common.d.ts +1 -4
- package/Canvas2D/Path2D/common.js +2 -6
- package/Canvas2D/Path2D/common.js.map +1 -1
- package/Canvas2D/TextMetrics/TextMetrics.android.js +12 -12
- package/Canvas2D/TextMetrics/TextMetrics.android.js.map +1 -1
- package/Canvas2D/TextMetrics/common.d.ts +0 -1
- package/Canvas2D/TextMetrics/common.js +1 -4
- package/Canvas2D/TextMetrics/common.js.map +1 -1
- package/ImageAsset/ImageAsset.android.d.ts +11 -12
- package/ImageAsset/ImageAsset.android.js +92 -127
- package/ImageAsset/ImageAsset.android.js.map +1 -1
- package/ImageAsset/ImageAsset.d.ts +8 -12
- package/ImageAsset/ImageAsset.ios.js +3 -3
- package/ImageAsset/ImageAsset.ios.js.map +1 -1
- package/ImageAsset/common.d.ts +0 -1
- package/ImageAsset/common.js +1 -4
- package/ImageAsset/common.js.map +1 -1
- package/ImageBitmap/common.d.ts +0 -2
- package/ImageBitmap/common.js +0 -7
- package/ImageBitmap/common.js.map +1 -1
- package/ImageBitmap/index.android.d.ts +2 -2
- package/ImageBitmap/index.android.js +55 -292
- package/ImageBitmap/index.android.js.map +1 -1
- package/ImageBitmap/index.ios.d.ts +1 -2
- package/ImageBitmap/index.ios.js +34 -23
- package/ImageBitmap/index.ios.js.map +1 -1
- package/SVG/SVG.js.map +1 -1
- package/TextDecoder/TextDecoder.android.d.ts +2 -1
- package/TextDecoder/TextDecoder.android.js +35 -38
- package/TextDecoder/TextDecoder.android.js.map +1 -1
- package/TextDecoder/common.d.ts +0 -1
- package/TextDecoder/common.js +1 -4
- package/TextDecoder/common.js.map +1 -1
- package/TextEncoder/TextEncoder.android.d.ts +2 -0
- package/TextEncoder/TextEncoder.android.js +35 -5
- package/TextEncoder/TextEncoder.android.js.map +1 -1
- package/TextEncoder/common.d.ts +0 -2
- package/TextEncoder/common.js +0 -7
- package/TextEncoder/common.js.map +1 -1
- package/WebGL/WebGLActiveInfo.d.ts +5 -8
- package/WebGL/WebGLActiveInfo.js +8 -24
- package/WebGL/WebGLActiveInfo.js.map +1 -1
- package/WebGL/WebGLExtensions/index.android.d.ts +9 -0
- package/WebGL/WebGLExtensions/index.android.js +94 -57
- package/WebGL/WebGLExtensions/index.android.js.map +1 -1
- package/WebGL/WebGLProgram.d.ts +1 -0
- package/WebGL/WebGLProgram.js +3 -0
- package/WebGL/WebGLProgram.js.map +1 -1
- package/WebGL/WebGLRenderingContext/common.d.ts +3 -1
- package/WebGL/WebGLRenderingContext/common.js +188 -178
- package/WebGL/WebGLRenderingContext/common.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.android.d.ts +8 -13
- package/WebGL/WebGLRenderingContext/index.android.js +1272 -954
- package/WebGL/WebGLRenderingContext/index.android.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.d.ts +11 -14
- package/WebGL/WebGLRenderingContext/index.ios.js +6 -5
- package/WebGL/WebGLRenderingContext/index.ios.js.map +1 -1
- package/WebGL/WebGLShaderPrecisionFormat.d.ts +5 -4
- package/WebGL/WebGLShaderPrecisionFormat.js +11 -4
- package/WebGL/WebGLShaderPrecisionFormat.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/common.d.ts +1 -1
- package/WebGL2/WebGL2RenderingContext/common.js +199 -199
- package/WebGL2/WebGL2RenderingContext/common.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.android.d.ts +5 -6
- package/WebGL2/WebGL2RenderingContext/index.android.js +276 -318
- package/WebGL2/WebGL2RenderingContext/index.android.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.ios.js +1 -1
- package/WebGL2/WebGL2RenderingContext/index.ios.js.map +1 -1
- package/angular/esm2020/index.mjs +5 -5
- package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
- package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
- package/angular/nativescript-canvas-angular.d.ts +5 -0
- package/angular/package.json +2 -2
- package/helpers.d.ts +5 -0
- package/helpers.js +18 -0
- package/helpers.js.map +1 -0
- package/index.js +6 -0
- package/index.js.map +1 -1
- package/package.json +2 -3
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/android/include.gradle +5 -6
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +33 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -1
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +22 -49
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{arm64-apple-ios.private.swiftinterface → arm64.swiftinterface} +22 -49
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/module.modulemap +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +66 -168
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -1
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +22 -49
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{arm64-apple-ios-simulator.private.swiftinterface → arm64.swiftinterface} +22 -49
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +22 -49
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{x86_64-apple-ios-simulator.private.swiftinterface → x86_64.swiftinterface} +22 -49
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/module.modulemap +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +83 -50
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/utils.d.ts +1 -3
- package/utils.js +20 -7
- package/utils.js.map +1 -1
- package/LICENSE +0 -201
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +0 -1636
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +0 -75693
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +0 -1636
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -75693
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -75693
- package/typings/objc!CanvasNative.d.ts +0 -2036
- package/typings/objc!CanvasNative.js +0 -1
- package/typings/objc!CanvasNative.js.map +0 -1
|
@@ -7,84 +7,24 @@ import { ImageSource } from '@nativescript/core';
|
|
|
7
7
|
import { ImageAsset } from '../../ImageAsset';
|
|
8
8
|
import { CanvasPattern } from '../CanvasPattern';
|
|
9
9
|
import { Canvas } from '../../Canvas';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
EvenOdd: lazy(() => org.nativescript.canvas.TNSFillRule.EvenOdd),
|
|
13
|
-
NonZero: lazy(() => org.nativescript.canvas.TNSFillRule.NonZero),
|
|
14
|
-
};
|
|
15
|
-
const TextDirection = {
|
|
16
|
-
Ltr: lazy(() => org.nativescript.canvas.TNSTextDirection.Ltr),
|
|
17
|
-
Rtl: lazy(() => org.nativescript.canvas.TNSTextDirection.Rtl),
|
|
18
|
-
};
|
|
19
|
-
const ImageSmoothingQuality = {
|
|
20
|
-
Low: lazy(() => org.nativescript.canvas.TNSImageSmoothingQuality.Low),
|
|
21
|
-
Medium: lazy(() => org.nativescript.canvas.TNSImageSmoothingQuality.Medium),
|
|
22
|
-
High: lazy(() => org.nativescript.canvas.TNSImageSmoothingQuality.High),
|
|
23
|
-
};
|
|
24
|
-
const LineJoin = {
|
|
25
|
-
Bevel: lazy(() => org.nativescript.canvas.TNSLineJoin.Bevel),
|
|
26
|
-
Miter: lazy(() => org.nativescript.canvas.TNSLineJoin.Miter),
|
|
27
|
-
Round: lazy(() => org.nativescript.canvas.TNSLineJoin.Round),
|
|
28
|
-
};
|
|
29
|
-
const LineCap = {
|
|
30
|
-
Round: lazy(() => org.nativescript.canvas.TNSLineCap.Round),
|
|
31
|
-
Butt: lazy(() => org.nativescript.canvas.TNSLineCap.Butt),
|
|
32
|
-
Square: lazy(() => org.nativescript.canvas.TNSLineCap.Square),
|
|
33
|
-
};
|
|
34
|
-
const TextAlignment = {
|
|
35
|
-
Start: lazy(() => org.nativescript.canvas.TNSTextAlignment.Start),
|
|
36
|
-
Left: lazy(() => org.nativescript.canvas.TNSTextAlignment.Left),
|
|
37
|
-
Center: lazy(() => org.nativescript.canvas.TNSTextAlignment.Center),
|
|
38
|
-
Right: lazy(() => org.nativescript.canvas.TNSTextAlignment.Right),
|
|
39
|
-
End: lazy(() => org.nativescript.canvas.TNSTextAlignment.End),
|
|
40
|
-
};
|
|
41
|
-
const CompositeOperationType = {
|
|
42
|
-
SourceOver: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.SourceOver),
|
|
43
|
-
SourceIn: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.SourceIn),
|
|
44
|
-
SourceOut: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.SourceOut),
|
|
45
|
-
SourceAtop: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.SourceAtop),
|
|
46
|
-
DestinationOver: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.DestinationOver),
|
|
47
|
-
DestinationIn: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.DestinationIn),
|
|
48
|
-
DestinationOut: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.DestinationOut),
|
|
49
|
-
DestinationAtop: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.DestinationAtop),
|
|
50
|
-
Lighter: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Lighter),
|
|
51
|
-
Copy: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Copy),
|
|
52
|
-
Xor: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Xor),
|
|
53
|
-
Multiply: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Multiply),
|
|
54
|
-
Screen: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Screen),
|
|
55
|
-
Overlay: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Overlay),
|
|
56
|
-
Darken: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Darken),
|
|
57
|
-
Lighten: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Lighten),
|
|
58
|
-
ColorDodge: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.ColorDodge),
|
|
59
|
-
ColorBurn: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.ColorBurn),
|
|
60
|
-
HardLight: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.HardLight),
|
|
61
|
-
SoftLight: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.SoftLight),
|
|
62
|
-
Difference: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Difference),
|
|
63
|
-
Exclusion: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Exclusion),
|
|
64
|
-
Hue: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Hue),
|
|
65
|
-
Saturation: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Saturation),
|
|
66
|
-
Color: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Color),
|
|
67
|
-
Luminosity: lazy(() => org.nativescript.canvas.TNSCompositeOperationType.Luminosity),
|
|
68
|
-
};
|
|
69
|
-
const PatternRepetition = {
|
|
70
|
-
NoRepeat: lazy(() => org.nativescript.canvas.TNSPatternRepetition.NoRepeat),
|
|
71
|
-
Repeat: lazy(() => org.nativescript.canvas.TNSPatternRepetition.Repeat),
|
|
72
|
-
RepeatX: lazy(() => org.nativescript.canvas.TNSPatternRepetition.RepeatX),
|
|
73
|
-
RepeatY: lazy(() => org.nativescript.canvas.TNSPatternRepetition.RepeatY),
|
|
74
|
-
};
|
|
10
|
+
import { Helpers } from '../../helpers';
|
|
11
|
+
let ctor;
|
|
75
12
|
export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
76
|
-
constructor(context) {
|
|
13
|
+
constructor(context, contextOptions) {
|
|
77
14
|
super();
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
15
|
+
this._methodCache = new Map();
|
|
16
|
+
/*const width = context.getDrawingBufferWidth(); // can use getMeasuredWidth / getMeasuredHeight
|
|
17
|
+
const height = context.getDrawingBufferHeight();
|
|
18
|
+
|
|
19
|
+
const ctxPtr = BigInt(context.getNativeContext().toString());
|
|
20
|
+
let direction = 0;
|
|
21
|
+
if (androidx.core.text.TextUtilsCompat.getLayoutDirectionFromLocale(java.util.Locale.getDefault()) === androidx.core.view.ViewCompat.LAYOUT_DIRECTION_RTL) {
|
|
22
|
+
direction = 1;
|
|
23
|
+
}
|
|
24
|
+
this.context = ctor(ctxPtr, width, height, Screen.mainScreen.scale, contextOptions.antialias ? 4 : 0, contextOptions.alpha, contextOptions.fontColor, 1, direction);
|
|
25
|
+
*/
|
|
26
|
+
const ctxPtr = BigInt(context.toString());
|
|
27
|
+
this.context = ctor(ctxPtr);
|
|
88
28
|
}
|
|
89
29
|
get native() {
|
|
90
30
|
return this.context;
|
|
@@ -94,309 +34,157 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
94
34
|
}
|
|
95
35
|
get shadowColor() {
|
|
96
36
|
this.log('shadowColor');
|
|
97
|
-
return this.context.
|
|
37
|
+
return this.context.shadowColor;
|
|
98
38
|
}
|
|
99
39
|
set shadowColor(color) {
|
|
100
40
|
this.log('shadowColor value:', color);
|
|
101
41
|
this._ensureLayoutBeforeDraw();
|
|
102
42
|
if (this.context) {
|
|
103
|
-
this.context.
|
|
43
|
+
this.context.shadowColor = color;
|
|
104
44
|
}
|
|
105
45
|
}
|
|
106
46
|
get font() {
|
|
107
47
|
this.log('get font');
|
|
108
|
-
return this.context.
|
|
48
|
+
return this.context.font;
|
|
109
49
|
}
|
|
110
50
|
set font(value) {
|
|
111
51
|
this.log('set font value:', value);
|
|
112
52
|
if (this.context) {
|
|
113
|
-
this.context.
|
|
53
|
+
this.context.font = value;
|
|
114
54
|
}
|
|
115
55
|
}
|
|
116
56
|
get direction() {
|
|
117
57
|
this.log('direction');
|
|
118
|
-
return this.context.
|
|
58
|
+
return this.context.direction;
|
|
119
59
|
}
|
|
120
60
|
set direction(value) {
|
|
121
61
|
this.log('direction value:', value);
|
|
122
62
|
this._ensureLayoutBeforeDraw();
|
|
123
63
|
if (this.context) {
|
|
124
|
-
this.context.
|
|
64
|
+
this.context.direction = value;
|
|
125
65
|
}
|
|
126
66
|
}
|
|
127
67
|
get globalAlpha() {
|
|
128
68
|
this.log('globalAlpha');
|
|
129
|
-
return this.context.
|
|
69
|
+
return this.context.globalAlpha;
|
|
130
70
|
}
|
|
131
71
|
set globalAlpha(alpha) {
|
|
132
72
|
this.log('globalAlpha value:', alpha);
|
|
133
73
|
this._ensureLayoutBeforeDraw();
|
|
134
74
|
if (this.context) {
|
|
135
|
-
this.context.
|
|
75
|
+
this.context.globalAlpha = alpha;
|
|
136
76
|
}
|
|
137
77
|
}
|
|
138
78
|
get imageSmoothingEnabled() {
|
|
139
79
|
this.log('imageSmoothingEnabled');
|
|
140
|
-
return this.context.
|
|
80
|
+
return this.context.imageSmoothingEnabled;
|
|
141
81
|
}
|
|
142
82
|
set imageSmoothingEnabled(enabled) {
|
|
143
83
|
this.log('imageSmoothingEnabled value:', enabled);
|
|
144
84
|
this._ensureLayoutBeforeDraw();
|
|
145
85
|
if (this.context) {
|
|
146
|
-
this.context.
|
|
86
|
+
this.context.imageSmoothingEnabled = enabled;
|
|
147
87
|
}
|
|
148
88
|
}
|
|
149
89
|
get imageSmoothingQuality() {
|
|
150
90
|
this.log('imageSmoothingQuality');
|
|
151
|
-
return this.context.
|
|
91
|
+
return this.context.imageSmoothingQuality;
|
|
152
92
|
}
|
|
153
93
|
set imageSmoothingQuality(quality) {
|
|
154
94
|
this.log('imageSmoothingQuality value:', quality);
|
|
155
95
|
this._ensureLayoutBeforeDraw();
|
|
156
|
-
|
|
157
|
-
switch (quality) {
|
|
158
|
-
case 'high':
|
|
159
|
-
this.context.setImageSmoothingQuality(ImageSmoothingQuality.High());
|
|
160
|
-
break;
|
|
161
|
-
case 'medium':
|
|
162
|
-
this.context.setImageSmoothingQuality(ImageSmoothingQuality.Medium());
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
this.context.setImageSmoothingQuality(ImageSmoothingQuality.Low());
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
96
|
+
this.context.imageSmoothingQuality = quality;
|
|
169
97
|
}
|
|
170
98
|
get lineDashOffset() {
|
|
171
99
|
this.log('lineDashOffset');
|
|
172
|
-
return this.context.
|
|
100
|
+
return this.context.lineDashOffset;
|
|
173
101
|
}
|
|
174
102
|
set lineDashOffset(offset) {
|
|
175
103
|
this.log('lineDashOffset value:', offset);
|
|
176
104
|
this._ensureLayoutBeforeDraw();
|
|
177
105
|
if (this.context) {
|
|
178
|
-
this.context.
|
|
106
|
+
this.context.lineDashOffset = offset;
|
|
179
107
|
}
|
|
180
108
|
}
|
|
181
109
|
get lineJoin() {
|
|
182
110
|
this.log('lineJoin');
|
|
183
|
-
return this.context.
|
|
111
|
+
return this.context.lineJoin;
|
|
184
112
|
}
|
|
185
113
|
set lineJoin(join) {
|
|
186
114
|
this.log('lineJoin value:', join);
|
|
187
115
|
this._ensureLayoutBeforeDraw();
|
|
188
|
-
|
|
189
|
-
switch (join) {
|
|
190
|
-
case 'bevel':
|
|
191
|
-
this.context.setLineJoin(LineJoin.Bevel());
|
|
192
|
-
break;
|
|
193
|
-
case 'round':
|
|
194
|
-
this.context.setLineJoin(LineJoin.Round());
|
|
195
|
-
break;
|
|
196
|
-
default:
|
|
197
|
-
this.context.setLineJoin(LineJoin.Miter());
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
116
|
+
this.context.lineJoin = join;
|
|
201
117
|
}
|
|
202
118
|
get lineCap() {
|
|
203
119
|
this.log('lineCap');
|
|
204
|
-
return this.context.
|
|
120
|
+
return this.context.lineCap;
|
|
205
121
|
}
|
|
206
122
|
set lineCap(cap) {
|
|
207
123
|
this.log('lineCap value:', cap);
|
|
208
124
|
this._ensureLayoutBeforeDraw();
|
|
209
|
-
|
|
210
|
-
switch (cap) {
|
|
211
|
-
case 'round':
|
|
212
|
-
this.context.setLineCap(LineCap.Round());
|
|
213
|
-
break;
|
|
214
|
-
case 'square':
|
|
215
|
-
this.context.setLineCap(LineCap.Square());
|
|
216
|
-
break;
|
|
217
|
-
default:
|
|
218
|
-
this.context.setLineCap(LineCap.Butt());
|
|
219
|
-
}
|
|
220
|
-
}
|
|
125
|
+
this.context.lineCap = cap;
|
|
221
126
|
}
|
|
222
127
|
get miterLimit() {
|
|
223
128
|
this.log('miterLimit value:');
|
|
224
|
-
return this.context.
|
|
129
|
+
return this.context.miterLimit;
|
|
225
130
|
}
|
|
226
131
|
set miterLimit(limit) {
|
|
227
132
|
this.log('miterLimit value:', limit);
|
|
228
133
|
this._ensureLayoutBeforeDraw();
|
|
229
|
-
|
|
230
|
-
this.context.setMiterLimit(limit);
|
|
231
|
-
}
|
|
134
|
+
this.context.miterLimit = limit;
|
|
232
135
|
}
|
|
233
136
|
get shadowBlur() {
|
|
234
137
|
this.log('shadowBlur');
|
|
235
|
-
return this.context.
|
|
138
|
+
return this.context.shadowBlur;
|
|
236
139
|
}
|
|
237
140
|
set shadowBlur(blur) {
|
|
238
141
|
this.log('shadowBlur value:', blur);
|
|
239
142
|
this._ensureLayoutBeforeDraw();
|
|
240
|
-
|
|
241
|
-
this.context.setShadowBlur(blur);
|
|
242
|
-
}
|
|
143
|
+
this.context.shadowBlur = blur;
|
|
243
144
|
}
|
|
244
145
|
get shadowOffsetX() {
|
|
245
146
|
this.log('shadowOffsetX');
|
|
246
|
-
return this.context.
|
|
147
|
+
return this.context.shadowOffsetX;
|
|
247
148
|
}
|
|
248
149
|
set shadowOffsetX(x) {
|
|
249
150
|
this.log('shadowOffsetX value:', x);
|
|
250
151
|
this._ensureLayoutBeforeDraw();
|
|
251
152
|
if (this.context) {
|
|
252
|
-
this.context.
|
|
153
|
+
this.context.shadowOffsetX = x;
|
|
253
154
|
}
|
|
254
155
|
}
|
|
255
156
|
get shadowOffsetY() {
|
|
256
157
|
this.log('shadowOffsetY');
|
|
257
|
-
return this.context.
|
|
158
|
+
return this.context.shadowOffsetY;
|
|
258
159
|
}
|
|
259
160
|
set shadowOffsetY(y) {
|
|
260
161
|
this.log('shadowOffsetY value:', y);
|
|
261
162
|
this._ensureLayoutBeforeDraw();
|
|
262
163
|
if (this.context) {
|
|
263
|
-
this.context.
|
|
164
|
+
this.context.shadowOffsetY = y;
|
|
264
165
|
}
|
|
265
166
|
}
|
|
266
167
|
get textAlign() {
|
|
267
168
|
this.log('textAlign');
|
|
268
|
-
return this.context.
|
|
169
|
+
return this.context.textAlign;
|
|
269
170
|
}
|
|
270
171
|
set textAlign(alignment) {
|
|
271
172
|
this.log('textAlign value:', alignment);
|
|
272
173
|
this._ensureLayoutBeforeDraw();
|
|
273
|
-
|
|
274
|
-
switch (alignment) {
|
|
275
|
-
case 'start':
|
|
276
|
-
this.context.setTextAlign(TextAlignment.Start());
|
|
277
|
-
break;
|
|
278
|
-
case 'center':
|
|
279
|
-
this.context.setTextAlign(TextAlignment.Center());
|
|
280
|
-
break;
|
|
281
|
-
case 'end':
|
|
282
|
-
this.context.setTextAlign(TextAlignment.End());
|
|
283
|
-
break;
|
|
284
|
-
case 'right':
|
|
285
|
-
this.context.setTextAlign(TextAlignment.Right());
|
|
286
|
-
break;
|
|
287
|
-
default:
|
|
288
|
-
this.context.setTextAlign(TextAlignment.Left());
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
174
|
+
this.context.setTextAlign = alignment;
|
|
292
175
|
}
|
|
293
176
|
get globalCompositeOperation() {
|
|
294
177
|
this.log('globalCompositeOperation');
|
|
295
|
-
return this.context.
|
|
178
|
+
return this.context.globalCompositeOperation;
|
|
296
179
|
}
|
|
297
180
|
set globalCompositeOperation(composite) {
|
|
298
181
|
this.log('globalCompositeOperation value:', composite);
|
|
299
182
|
this._ensureLayoutBeforeDraw();
|
|
300
|
-
|
|
301
|
-
let operation;
|
|
302
|
-
switch (composite.toLowerCase()) {
|
|
303
|
-
case 'source-over':
|
|
304
|
-
operation = CompositeOperationType.SourceOver();
|
|
305
|
-
break;
|
|
306
|
-
case 'source-in':
|
|
307
|
-
operation = CompositeOperationType.SourceIn();
|
|
308
|
-
break;
|
|
309
|
-
case 'source-out':
|
|
310
|
-
operation = CompositeOperationType.SourceOut();
|
|
311
|
-
break;
|
|
312
|
-
case 'source-atop':
|
|
313
|
-
operation = CompositeOperationType.SourceAtop();
|
|
314
|
-
break;
|
|
315
|
-
case 'destination-over':
|
|
316
|
-
operation = CompositeOperationType.DestinationOver();
|
|
317
|
-
break;
|
|
318
|
-
case 'destination-in':
|
|
319
|
-
operation = CompositeOperationType.DestinationIn();
|
|
320
|
-
break;
|
|
321
|
-
case 'destination-out':
|
|
322
|
-
operation = CompositeOperationType.DestinationOut();
|
|
323
|
-
break;
|
|
324
|
-
case 'destination-atop':
|
|
325
|
-
operation = CompositeOperationType.DestinationAtop();
|
|
326
|
-
break;
|
|
327
|
-
case 'lighter':
|
|
328
|
-
operation = CompositeOperationType.Lighter();
|
|
329
|
-
break;
|
|
330
|
-
case 'copy':
|
|
331
|
-
operation = CompositeOperationType.Copy();
|
|
332
|
-
break;
|
|
333
|
-
case 'xor':
|
|
334
|
-
operation = CompositeOperationType.Xor();
|
|
335
|
-
break;
|
|
336
|
-
case 'multiply':
|
|
337
|
-
operation = CompositeOperationType.Multiply();
|
|
338
|
-
break;
|
|
339
|
-
case 'screen':
|
|
340
|
-
operation = CompositeOperationType.Screen();
|
|
341
|
-
break;
|
|
342
|
-
case 'overlay':
|
|
343
|
-
operation = CompositeOperationType.Overlay();
|
|
344
|
-
break;
|
|
345
|
-
case 'darken':
|
|
346
|
-
operation = CompositeOperationType.Darken();
|
|
347
|
-
break;
|
|
348
|
-
case 'lighten':
|
|
349
|
-
operation = CompositeOperationType.Lighten();
|
|
350
|
-
break;
|
|
351
|
-
case 'color-dodge':
|
|
352
|
-
operation = CompositeOperationType.ColorDodge();
|
|
353
|
-
break;
|
|
354
|
-
case 'color-burn':
|
|
355
|
-
operation = CompositeOperationType.ColorBurn();
|
|
356
|
-
break;
|
|
357
|
-
case 'hard-light':
|
|
358
|
-
operation = CompositeOperationType.HardLight();
|
|
359
|
-
break;
|
|
360
|
-
case 'soft-light':
|
|
361
|
-
operation = CompositeOperationType.SoftLight();
|
|
362
|
-
break;
|
|
363
|
-
case 'difference':
|
|
364
|
-
operation = CompositeOperationType.Difference();
|
|
365
|
-
break;
|
|
366
|
-
case 'exclusion':
|
|
367
|
-
operation = CompositeOperationType.Exclusion();
|
|
368
|
-
break;
|
|
369
|
-
case 'hue':
|
|
370
|
-
operation = CompositeOperationType.Hue();
|
|
371
|
-
break;
|
|
372
|
-
case 'saturation':
|
|
373
|
-
operation = CompositeOperationType.Saturation();
|
|
374
|
-
break;
|
|
375
|
-
case 'color':
|
|
376
|
-
operation = CompositeOperationType.Color();
|
|
377
|
-
break;
|
|
378
|
-
case 'luminosity':
|
|
379
|
-
operation = CompositeOperationType.Luminosity();
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
382
|
-
this.context.setGlobalCompositeOperation(operation);
|
|
383
|
-
}
|
|
183
|
+
this.context.globalCompositeOperation = composite;
|
|
384
184
|
}
|
|
385
185
|
get fillStyle() {
|
|
386
186
|
this.log('fillStyle');
|
|
387
|
-
|
|
388
|
-
const style = this.context.getFillStyle();
|
|
389
|
-
switch (style.getStyleType()) {
|
|
390
|
-
case org.nativescript.canvas.TNSColorStyleType.Color:
|
|
391
|
-
const color = style;
|
|
392
|
-
return color.getColor();
|
|
393
|
-
case org.nativescript.canvas.TNSColorStyleType.Gradient:
|
|
394
|
-
return CanvasGradient.fromNative(style);
|
|
395
|
-
case org.nativescript.canvas.TNSColorStyleType.Pattern:
|
|
396
|
-
return new CanvasPattern(style);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return 'black';
|
|
187
|
+
return this.context.fillStyle;
|
|
400
188
|
}
|
|
401
189
|
set fillStyle(color) {
|
|
402
190
|
this.log('fillStyle:', color);
|
|
@@ -404,38 +192,24 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
404
192
|
return;
|
|
405
193
|
}
|
|
406
194
|
this._ensureLayoutBeforeDraw();
|
|
407
|
-
if (
|
|
408
|
-
this.context.
|
|
409
|
-
}
|
|
410
|
-
else if (color instanceof CanvasGradient) {
|
|
411
|
-
this.context.setFillStyle(color.native);
|
|
195
|
+
if (color instanceof CanvasGradient || color instanceof CanvasPattern) {
|
|
196
|
+
this.context.fillStyle = color.native;
|
|
412
197
|
}
|
|
413
|
-
else
|
|
414
|
-
this.context.
|
|
198
|
+
else {
|
|
199
|
+
this.context.fillStyle = color;
|
|
415
200
|
}
|
|
416
201
|
}
|
|
417
202
|
get filter() {
|
|
418
203
|
this.log('get filter');
|
|
419
|
-
return this.context.
|
|
204
|
+
return this.context.filter;
|
|
420
205
|
}
|
|
421
206
|
set filter(value) {
|
|
422
207
|
this.log('set filter', value);
|
|
423
|
-
|
|
424
|
-
this.context.setFilter(value);
|
|
425
|
-
}
|
|
208
|
+
this.context.filter = value;
|
|
426
209
|
}
|
|
427
210
|
get strokeStyle() {
|
|
428
211
|
this.log('strokeStyle');
|
|
429
|
-
|
|
430
|
-
switch (style.getStyleType()) {
|
|
431
|
-
case 0 /* CanvasColorStyleType.Color */:
|
|
432
|
-
const color = style;
|
|
433
|
-
return color.getColor();
|
|
434
|
-
case 1 /* CanvasColorStyleType.Gradient */:
|
|
435
|
-
return CanvasGradient.fromNative(style);
|
|
436
|
-
case 2 /* CanvasColorStyleType.Pattern */:
|
|
437
|
-
return new CanvasPattern(style);
|
|
438
|
-
}
|
|
212
|
+
return this.context.strokeStyle;
|
|
439
213
|
}
|
|
440
214
|
set strokeStyle(color) {
|
|
441
215
|
this.log('strokeStyle:', color);
|
|
@@ -443,92 +217,107 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
443
217
|
return;
|
|
444
218
|
}
|
|
445
219
|
this._ensureLayoutBeforeDraw();
|
|
446
|
-
if (
|
|
447
|
-
this.context.
|
|
448
|
-
}
|
|
449
|
-
else if (color instanceof CanvasGradient) {
|
|
450
|
-
this.context.setStrokeStyle(color.native);
|
|
220
|
+
if (color instanceof CanvasGradient || color instanceof CanvasPattern) {
|
|
221
|
+
this.context.strokeStyle = color.native;
|
|
451
222
|
}
|
|
452
|
-
else
|
|
453
|
-
this.context.
|
|
223
|
+
else {
|
|
224
|
+
this.context.strokeStyle = color;
|
|
454
225
|
}
|
|
455
226
|
}
|
|
456
227
|
get lineWidth() {
|
|
457
228
|
this.log('lineWidth');
|
|
458
|
-
return this.context.
|
|
229
|
+
return this.context.lineWidth;
|
|
459
230
|
}
|
|
460
231
|
set lineWidth(width) {
|
|
461
232
|
this.log('lineWidth value:', width);
|
|
462
233
|
this._ensureLayoutBeforeDraw();
|
|
463
|
-
|
|
464
|
-
|
|
234
|
+
this.context.lineWidth = width;
|
|
235
|
+
}
|
|
236
|
+
_getMethod(name) {
|
|
237
|
+
const cached = this._methodCache.get(name);
|
|
238
|
+
if (cached === undefined) {
|
|
239
|
+
const ret = this.context[name];
|
|
240
|
+
this._methodCache.set(name, ret);
|
|
241
|
+
return ret;
|
|
465
242
|
}
|
|
243
|
+
return cached;
|
|
244
|
+
}
|
|
245
|
+
__toDataURL() {
|
|
246
|
+
const __toDataURL = this._getMethod('__toDataURL');
|
|
247
|
+
return __toDataURL(arguments[0], arguments[1]);
|
|
466
248
|
}
|
|
467
249
|
addHitRegion(region) { }
|
|
468
250
|
arc(x, y, radius, startAngle, endAngle, anticlockwise = false) {
|
|
469
251
|
this.log('arc value:', x, y, radius, startAngle, endAngle, anticlockwise);
|
|
470
252
|
this._ensureLayoutBeforeDraw();
|
|
471
|
-
this.
|
|
253
|
+
const arc = this._getMethod('arc');
|
|
254
|
+
arc(x, y, radius, startAngle, endAngle, anticlockwise);
|
|
472
255
|
}
|
|
473
256
|
arcTo(x1, y1, x2, y2, radius) {
|
|
474
257
|
this.log('arcTo value:', x1, y1, x2, y2, radius);
|
|
475
258
|
this._ensureLayoutBeforeDraw();
|
|
476
|
-
this.
|
|
259
|
+
const arcTo = this._getMethod('arcTo');
|
|
260
|
+
arcTo(x1, y1, x2, y2, radius);
|
|
477
261
|
}
|
|
478
262
|
beginPath() {
|
|
479
263
|
this.log('beginPath');
|
|
480
264
|
this._ensureLayoutBeforeDraw();
|
|
481
|
-
this.
|
|
265
|
+
const beginPath = this._getMethod('beginPath');
|
|
266
|
+
beginPath();
|
|
482
267
|
}
|
|
483
268
|
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
484
269
|
this.log('bezierCurveTo value:', cp1x, cp1y, cp2x, cp2y, x, y);
|
|
485
270
|
this._ensureLayoutBeforeDraw();
|
|
486
|
-
this.
|
|
271
|
+
const bezierCurveTo = this._getMethod('bezierCurveTo');
|
|
272
|
+
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
487
273
|
}
|
|
488
274
|
clearHitRegions() { }
|
|
489
275
|
clearRect(x, y, width, height) {
|
|
490
276
|
this.log('clearRect value:', x, y, width, height);
|
|
491
277
|
this._ensureLayoutBeforeDraw();
|
|
492
|
-
this.
|
|
278
|
+
const clearRect = this._getMethod('clearRect');
|
|
279
|
+
clearRect(x, y, width, height);
|
|
493
280
|
}
|
|
494
281
|
clip(...args) {
|
|
495
282
|
this.log('clip value:', ...args);
|
|
496
283
|
this._ensureLayoutBeforeDraw();
|
|
284
|
+
const clip = this._getMethod('clip');
|
|
497
285
|
if (typeof args[0] === 'string') {
|
|
498
|
-
|
|
499
|
-
this.context.clip(rule);
|
|
286
|
+
clip(args[0]);
|
|
500
287
|
}
|
|
501
288
|
else if (args[0] instanceof Path2D && typeof args[1] === 'string') {
|
|
502
|
-
|
|
503
|
-
this.context.clip(args[0].native, rule);
|
|
289
|
+
clip(args[0].native, args[1]);
|
|
504
290
|
}
|
|
505
291
|
else if (args[0] instanceof Path2D) {
|
|
506
|
-
|
|
292
|
+
clip(args[0].native);
|
|
507
293
|
}
|
|
508
294
|
else {
|
|
509
|
-
|
|
295
|
+
clip();
|
|
510
296
|
}
|
|
511
297
|
}
|
|
512
298
|
closePath() {
|
|
513
299
|
this.log('closePath');
|
|
514
300
|
this._ensureLayoutBeforeDraw();
|
|
515
|
-
this.
|
|
301
|
+
const closePath = this._getMethod('closePath');
|
|
302
|
+
closePath();
|
|
516
303
|
}
|
|
517
304
|
createImageData(width, height) {
|
|
518
305
|
this.log('createImageData value:', arguments);
|
|
519
306
|
if (width instanceof ImageData) {
|
|
520
|
-
return ImageData
|
|
307
|
+
return new ImageData(width.width, width.height);
|
|
521
308
|
}
|
|
522
309
|
else {
|
|
523
|
-
return ImageData
|
|
310
|
+
return new ImageData(width, height);
|
|
524
311
|
}
|
|
525
312
|
}
|
|
526
313
|
createLinearGradient(x0, y0, x1, y1) {
|
|
527
314
|
this.log('createLinearGradient value:', x0, y0, x1, y1);
|
|
528
315
|
this._ensureLayoutBeforeDraw();
|
|
529
|
-
|
|
316
|
+
const createLinearGradient = this._getMethod('createLinearGradient');
|
|
317
|
+
return CanvasGradient.fromNative(createLinearGradient(x0, y0, x1, y1));
|
|
530
318
|
}
|
|
531
319
|
createPattern(image, repetition) {
|
|
320
|
+
var _a;
|
|
532
321
|
this.log('createPattern value:', image, repetition);
|
|
533
322
|
this._ensureLayoutBeforeDraw();
|
|
534
323
|
if (repetition === undefined || typeof repetition !== 'string') {
|
|
@@ -536,24 +325,32 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
536
325
|
e.name = 'SyntaxError';
|
|
537
326
|
throw e;
|
|
538
327
|
}
|
|
328
|
+
const createPattern = this._getMethod('createPattern');
|
|
539
329
|
let img;
|
|
540
|
-
if (image
|
|
330
|
+
if ((image === null || image === void 0 ? void 0 : image._type) === '2d' || ((_a = image === null || image === void 0 ? void 0 : image._type) === null || _a === void 0 ? void 0 : _a.indexOf('webgl')) > -1) {
|
|
331
|
+
img = image.native;
|
|
332
|
+
}
|
|
333
|
+
else if (image instanceof ImageSource) {
|
|
541
334
|
img = image.android;
|
|
335
|
+
const ptr = this._getMethod('__getPointer');
|
|
336
|
+
const createPattern = this._getMethod('__createPatternWithNative');
|
|
337
|
+
const pattern = org.nativescript.canvas.NSCCanvasRenderingContext2D.createPattern(long(ptr), img, repetition);
|
|
338
|
+
return new CanvasPattern(createPattern(pattern));
|
|
542
339
|
}
|
|
543
340
|
else if (image instanceof android.graphics.Bitmap) {
|
|
544
|
-
|
|
341
|
+
const ptr = this._getMethod('__getPointer');
|
|
342
|
+
const createPattern = this._getMethod('__createPatternWithNative');
|
|
343
|
+
const pattern = org.nativescript.canvas.NSCCanvasRenderingContext2D.createPattern(long(ptr), image, repetition);
|
|
344
|
+
return new CanvasPattern(createPattern(pattern));
|
|
545
345
|
}
|
|
546
346
|
else if (image instanceof ImageAsset) {
|
|
547
347
|
img = image.native;
|
|
548
348
|
}
|
|
549
349
|
else if (image instanceof Canvas) {
|
|
550
|
-
img = image.
|
|
350
|
+
img = image.native;
|
|
551
351
|
}
|
|
552
352
|
else if (image && typeof image.tagName === 'string' && (image.tagName === 'IMG' || image.tagName === 'IMAGE')) {
|
|
553
|
-
if (image.
|
|
554
|
-
img = image._imageSource.android;
|
|
555
|
-
}
|
|
556
|
-
else if (image._image instanceof android.graphics.Bitmap) {
|
|
353
|
+
if (image._image instanceof android.graphics.Bitmap) {
|
|
557
354
|
img = image._image;
|
|
558
355
|
}
|
|
559
356
|
else if (image._asset instanceof ImageAsset) {
|
|
@@ -561,60 +358,66 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
561
358
|
}
|
|
562
359
|
else if (typeof image.src === 'string') {
|
|
563
360
|
img = ImageSource.fromFileSync(image.src).android;
|
|
361
|
+
const ptr = this._getMethod('__getPointer');
|
|
362
|
+
const createPattern = this._getMethod('__createPatternWithNative');
|
|
363
|
+
const pattern = org.nativescript.canvas.NSCCanvasRenderingContext2D.createPattern(long(ptr), img, repetition);
|
|
364
|
+
return new CanvasPattern(createPattern(pattern));
|
|
564
365
|
}
|
|
565
366
|
}
|
|
566
367
|
else if (image && typeof image.tagName === 'string' && image.tagName === 'CANVAS' && image._canvas instanceof Canvas) {
|
|
567
|
-
img = image._canvas.
|
|
368
|
+
img = image._canvas.native;
|
|
568
369
|
}
|
|
569
|
-
else if (image instanceof ImageBitmap
|
|
370
|
+
else if (image instanceof ImageBitmap) {
|
|
570
371
|
img = image.native;
|
|
571
372
|
}
|
|
572
373
|
if (!img) {
|
|
573
374
|
return null;
|
|
574
375
|
}
|
|
575
|
-
|
|
576
|
-
switch (repetition) {
|
|
577
|
-
case 'no-repeat':
|
|
578
|
-
rep = PatternRepetition.NoRepeat();
|
|
579
|
-
break;
|
|
580
|
-
case 'repeat-x':
|
|
581
|
-
rep = PatternRepetition.RepeatX();
|
|
582
|
-
break;
|
|
583
|
-
case 'repeat-y':
|
|
584
|
-
rep = PatternRepetition.RepeatY();
|
|
585
|
-
break;
|
|
586
|
-
default:
|
|
587
|
-
rep = PatternRepetition.Repeat();
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
return new CanvasPattern(this.context.createPattern(img, rep));
|
|
376
|
+
return new CanvasPattern(createPattern(img, repetition));
|
|
591
377
|
}
|
|
592
378
|
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
593
379
|
this.log('createRadialGradient value:', x0, y0, r0, x1, y1, r1);
|
|
594
380
|
this._ensureLayoutBeforeDraw();
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
createConicGradient(startAngle, x, y) {
|
|
598
|
-
this.log('createConicGradient value:', startAngle, x, y);
|
|
599
|
-
this._ensureLayoutBeforeDraw();
|
|
600
|
-
return CanvasGradient.fromNative(this.context.createConicGradient(startAngle, x, y));
|
|
381
|
+
const createRadialGradient = this._getMethod('createRadialGradient');
|
|
382
|
+
return CanvasGradient.fromNative(createRadialGradient(x0, y0, r0, x1, y1, r1));
|
|
601
383
|
}
|
|
602
384
|
drawFocusIfNeeded(...args) { }
|
|
603
385
|
drawImage(...args) {
|
|
386
|
+
var _a;
|
|
604
387
|
this.log('drawImage value:', ...args);
|
|
605
388
|
this._ensureLayoutBeforeDraw();
|
|
389
|
+
const drawImage = this._getMethod('drawImage');
|
|
606
390
|
let image = args[0];
|
|
607
|
-
if (image
|
|
391
|
+
if ((image === null || image === void 0 ? void 0 : image._type) === '2d' || ((_a = image === null || image === void 0 ? void 0 : image._type) === null || _a === void 0 ? void 0 : _a.indexOf('webgl')) > -1) {
|
|
392
|
+
image = image.native;
|
|
393
|
+
}
|
|
394
|
+
else if (image instanceof ImageAsset) {
|
|
608
395
|
image = image.native;
|
|
609
396
|
}
|
|
610
397
|
else if (image instanceof ImageSource) {
|
|
611
398
|
image = image.android;
|
|
399
|
+
const ptr = this._getMethod('__getPointer');
|
|
400
|
+
const makeDirty = this._getMethod('__makeDirty');
|
|
401
|
+
let dirty = false;
|
|
402
|
+
if (args.length === 3) {
|
|
403
|
+
dirty = org.nativescript.canvas.NSCCanvasRenderingContext2D.drawImage(long(ptr), image, args[1], args[2]);
|
|
404
|
+
}
|
|
405
|
+
else if (args.length === 5) {
|
|
406
|
+
dirty = org.nativescript.canvas.NSCCanvasRenderingContext2D.drawImage(long(ptr), image, args[1], args[2], args[3], args[4]);
|
|
407
|
+
}
|
|
408
|
+
else if (args.length === 9) {
|
|
409
|
+
dirty = org.nativescript.canvas.NSCCanvasRenderingContext2D.drawImage(long(ptr), image, args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
|
|
410
|
+
}
|
|
411
|
+
if (dirty) {
|
|
412
|
+
makeDirty();
|
|
413
|
+
}
|
|
414
|
+
return;
|
|
612
415
|
}
|
|
613
416
|
else if (image instanceof android.graphics.Bitmap) {
|
|
614
417
|
image = image;
|
|
615
418
|
}
|
|
616
419
|
else if (image instanceof Canvas) {
|
|
617
|
-
image = image.
|
|
420
|
+
image = image.native;
|
|
618
421
|
}
|
|
619
422
|
else if (image && typeof image.tagName === 'string' && (image.tagName === 'IMG' || image.tagName === 'IMAGE')) {
|
|
620
423
|
if (image._imageSource instanceof ImageSource) {
|
|
@@ -633,110 +436,115 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
633
436
|
else if (image && typeof image.tagName === 'string' && image.tagName === 'CANVAS' && image._canvas instanceof Canvas) {
|
|
634
437
|
image = image._canvas.android;
|
|
635
438
|
}
|
|
636
|
-
else if (image instanceof ImageBitmap
|
|
439
|
+
else if (image instanceof ImageBitmap) {
|
|
637
440
|
image = image.native;
|
|
638
441
|
}
|
|
639
442
|
if (args.length === 3) {
|
|
640
|
-
|
|
443
|
+
drawImage(image, args[1], args[2]);
|
|
641
444
|
}
|
|
642
445
|
else if (args.length === 5) {
|
|
643
|
-
|
|
446
|
+
drawImage(image, args[1], args[2], args[3], args[4]);
|
|
644
447
|
}
|
|
645
448
|
else if (args.length === 9) {
|
|
646
|
-
|
|
449
|
+
drawImage(image, args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
|
|
647
450
|
}
|
|
648
451
|
}
|
|
649
452
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
650
453
|
this.log('ellipse value:', x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
651
454
|
this._ensureLayoutBeforeDraw();
|
|
652
|
-
this.
|
|
455
|
+
const ellipse = this._getMethod('ellipse');
|
|
456
|
+
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
653
457
|
}
|
|
654
458
|
fill(...args) {
|
|
655
459
|
this.log('fill value:', ...args);
|
|
656
460
|
this._ensureLayoutBeforeDraw();
|
|
657
|
-
|
|
658
|
-
this.context.fill();
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
461
|
+
const fill = this._getMethod('fill');
|
|
661
462
|
if (typeof args[0] === 'string') {
|
|
662
|
-
|
|
663
|
-
this.context.fill(rule);
|
|
463
|
+
fill(args[0]);
|
|
664
464
|
}
|
|
665
465
|
else if (args[0] instanceof Path2D && typeof args[1] === 'string') {
|
|
666
|
-
|
|
667
|
-
this.context.fill(args[0].native, rule);
|
|
466
|
+
fill(args[0].native, args[1]);
|
|
668
467
|
}
|
|
669
468
|
else if (args[0] instanceof Path2D) {
|
|
670
|
-
|
|
469
|
+
fill(args[0].native);
|
|
671
470
|
}
|
|
672
471
|
else {
|
|
673
|
-
|
|
472
|
+
fill();
|
|
674
473
|
}
|
|
675
474
|
}
|
|
676
475
|
fillRect(x, y, width, height) {
|
|
677
476
|
this.log('fillRect value:', x, y, width, height);
|
|
678
477
|
this._ensureLayoutBeforeDraw();
|
|
679
|
-
this.
|
|
478
|
+
const fillRect = this._getMethod('fillRect');
|
|
479
|
+
fillRect(x, y, width, height);
|
|
680
480
|
}
|
|
681
481
|
fillText(text, x, y, maxWidth) {
|
|
682
482
|
this.log('fillText value:', text, x, y, maxWidth);
|
|
683
483
|
this._ensureLayoutBeforeDraw();
|
|
484
|
+
const fillText = this._getMethod('fillText');
|
|
684
485
|
if (typeof maxWidth === 'number') {
|
|
685
|
-
|
|
486
|
+
fillText(text + '', x, y, maxWidth);
|
|
686
487
|
}
|
|
687
488
|
else {
|
|
688
|
-
|
|
489
|
+
fillText(text + '', x, y);
|
|
689
490
|
}
|
|
690
491
|
}
|
|
691
492
|
getImageData(sx, sy, sw, sh) {
|
|
692
493
|
this.log('getImageData value:', sx, sy, sw, sh);
|
|
693
494
|
this._ensureLayoutBeforeDraw();
|
|
694
|
-
|
|
495
|
+
const getImageData = this._getMethod('getImageData');
|
|
496
|
+
return ImageData.fromNative(getImageData(sx, sy, sw, sh));
|
|
695
497
|
}
|
|
696
498
|
getLineDash() {
|
|
697
499
|
this.log('getLineDash');
|
|
698
500
|
this._ensureLayoutBeforeDraw();
|
|
699
|
-
|
|
501
|
+
const getLineDash = this._getMethod('getLineDash');
|
|
502
|
+
return getLineDash();
|
|
700
503
|
}
|
|
701
504
|
isPointInPath(...args) {
|
|
702
505
|
this.log('isPointInPath value:', ...args);
|
|
703
506
|
this._ensureLayoutBeforeDraw();
|
|
507
|
+
const isPointInPath = this._getMethod('isPointInPath');
|
|
704
508
|
if (args.length === 2) {
|
|
705
|
-
return
|
|
509
|
+
return isPointInPath(args[0], args[1]);
|
|
706
510
|
}
|
|
707
511
|
else if (args.length === 3) {
|
|
708
|
-
return
|
|
512
|
+
return isPointInPath(args[0], args[1], args[2]);
|
|
709
513
|
}
|
|
710
514
|
else if (args.length === 4 && args[0] instanceof Path2D) {
|
|
711
|
-
return
|
|
515
|
+
return isPointInPath(args[0].native, args[1], args[2], args[3]);
|
|
712
516
|
}
|
|
713
517
|
return false;
|
|
714
518
|
}
|
|
715
519
|
isPointInStroke(...args) {
|
|
716
520
|
this.log('isPointInStroke value:', ...args);
|
|
717
521
|
this._ensureLayoutBeforeDraw();
|
|
522
|
+
const isPointInStroke = this._getMethod('isPointInStroke');
|
|
718
523
|
if (args.length === 2) {
|
|
719
|
-
return
|
|
524
|
+
return isPointInStroke(args[0], args[1]);
|
|
720
525
|
}
|
|
721
526
|
else if (args.length === 3 && args[0] instanceof Path2D) {
|
|
722
|
-
return
|
|
527
|
+
return isPointInStroke(args[0].native, args[1], args[2]);
|
|
723
528
|
}
|
|
724
529
|
return false;
|
|
725
530
|
}
|
|
726
531
|
lineTo(x, y) {
|
|
727
532
|
this.log('lineTo value:', x, y);
|
|
728
533
|
this._ensureLayoutBeforeDraw();
|
|
729
|
-
this.
|
|
534
|
+
const lineTo = this._getMethod('lineTo');
|
|
535
|
+
lineTo(x, y);
|
|
730
536
|
}
|
|
731
537
|
measureText(text) {
|
|
732
538
|
this.log('measureText value:', text);
|
|
733
539
|
this._ensureLayoutBeforeDraw();
|
|
734
|
-
|
|
540
|
+
const measureText = this._getMethod('measureText');
|
|
541
|
+
return new TextMetrics(measureText(text));
|
|
735
542
|
}
|
|
736
543
|
moveTo(x, y) {
|
|
737
544
|
this.log('moveTo value:', x, y);
|
|
738
545
|
this._ensureLayoutBeforeDraw();
|
|
739
|
-
this.
|
|
546
|
+
const moveTo = this._getMethod('moveTo');
|
|
547
|
+
moveTo(x, y);
|
|
740
548
|
}
|
|
741
549
|
putImageData(...args) {
|
|
742
550
|
this.log('putImageData value:', ...args);
|
|
@@ -744,105 +552,110 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
744
552
|
if (!args) {
|
|
745
553
|
return;
|
|
746
554
|
}
|
|
555
|
+
const putImageData = this._getMethod('putImageData');
|
|
747
556
|
let data = args[0];
|
|
748
557
|
if (args.length === 3) {
|
|
749
|
-
|
|
558
|
+
putImageData(data.native, args[1], args[2]);
|
|
750
559
|
}
|
|
751
560
|
else if (args.length === 7) {
|
|
752
|
-
|
|
561
|
+
putImageData(data.native, args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
753
562
|
}
|
|
754
563
|
}
|
|
755
564
|
quadraticCurveTo(cpx, cpy, x, y) {
|
|
756
565
|
this.log('quadraticCurveTo value:', cpx, cpy, x, y);
|
|
757
566
|
this._ensureLayoutBeforeDraw();
|
|
758
|
-
this.
|
|
567
|
+
const quadraticCurveTo = this._getMethod('quadraticCurveTo');
|
|
568
|
+
quadraticCurveTo(cpx, cpy, x, y);
|
|
759
569
|
}
|
|
760
570
|
rect(x, y, width, height) {
|
|
761
571
|
this.log('rect value:', x, y, width, height);
|
|
762
572
|
this._ensureLayoutBeforeDraw();
|
|
763
|
-
this.
|
|
764
|
-
|
|
765
|
-
roundRect(x, y, width, height, radii) {
|
|
766
|
-
this.log('roundRect value:', x, y, width, height, radii);
|
|
767
|
-
this._ensureLayoutBeforeDraw();
|
|
768
|
-
if (Array.isArray(radii)) {
|
|
769
|
-
this.context.roundRect(x, y, width, height, radii);
|
|
770
|
-
}
|
|
771
|
-
else if (typeof radii === 'number') {
|
|
772
|
-
this.context.roundRect(x, y, width, height, radii);
|
|
773
|
-
}
|
|
573
|
+
const rect = this._getMethod('rect');
|
|
574
|
+
rect(x, y, width, height);
|
|
774
575
|
}
|
|
775
576
|
removeHitRegion(id) { }
|
|
776
577
|
resetTransform() {
|
|
777
578
|
this.log('resetTransform value:');
|
|
778
579
|
this._ensureLayoutBeforeDraw();
|
|
779
|
-
this.
|
|
580
|
+
const resetTransform = this._getMethod('resetTransform');
|
|
581
|
+
resetTransform();
|
|
780
582
|
}
|
|
781
583
|
restore() {
|
|
782
584
|
this.log('restore');
|
|
783
585
|
this._ensureLayoutBeforeDraw();
|
|
784
|
-
this.
|
|
586
|
+
const restore = this._getMethod('restore');
|
|
587
|
+
restore();
|
|
785
588
|
}
|
|
786
589
|
rotate(angle) {
|
|
787
590
|
this.log('rotate value:', angle);
|
|
788
591
|
this._ensureLayoutBeforeDraw();
|
|
789
|
-
this.
|
|
592
|
+
const rotate = this._getMethod('rotate');
|
|
593
|
+
rotate(angle);
|
|
790
594
|
}
|
|
791
595
|
save() {
|
|
792
596
|
this.log('save');
|
|
793
597
|
this._ensureLayoutBeforeDraw();
|
|
794
|
-
this.
|
|
598
|
+
const save = this._getMethod('save');
|
|
599
|
+
save();
|
|
795
600
|
}
|
|
796
601
|
scale(x, y) {
|
|
797
602
|
this.log('scale value:', x, y);
|
|
798
603
|
this._ensureLayoutBeforeDraw();
|
|
799
|
-
this.
|
|
604
|
+
const scale = this._getMethod('scale');
|
|
605
|
+
scale(x, y);
|
|
800
606
|
}
|
|
801
607
|
scrollPathIntoView(path) { }
|
|
802
608
|
setLineDash(segments) {
|
|
803
609
|
this.log('setLineDash value:', segments);
|
|
804
610
|
this._ensureLayoutBeforeDraw();
|
|
805
|
-
this.
|
|
611
|
+
const setLineDash = this._getMethod('setLineDash');
|
|
612
|
+
setLineDash(segments);
|
|
806
613
|
}
|
|
807
614
|
setTransform(a, b, c, d, e, f) {
|
|
808
615
|
this.log('setTransform value:', a, b, c, d, e, f);
|
|
809
616
|
this._ensureLayoutBeforeDraw();
|
|
810
|
-
this.
|
|
617
|
+
const setTransform = this._getMethod('setTransform');
|
|
618
|
+
setTransform(a, b, c, d, e, f);
|
|
811
619
|
}
|
|
812
620
|
stroke(path) {
|
|
813
621
|
this.log('stroke value:', path);
|
|
814
622
|
this._ensureLayoutBeforeDraw();
|
|
623
|
+
const stroke = this._getMethod('stroke');
|
|
815
624
|
if (path) {
|
|
816
|
-
|
|
625
|
+
stroke(path.native);
|
|
817
626
|
}
|
|
818
627
|
else {
|
|
819
|
-
|
|
628
|
+
stroke();
|
|
820
629
|
}
|
|
821
630
|
}
|
|
822
631
|
strokeRect(x, y, width, height) {
|
|
823
632
|
this.log('strokeRect value:', x, y, width, height);
|
|
824
633
|
this._ensureLayoutBeforeDraw();
|
|
825
|
-
this.
|
|
634
|
+
const strokeRect = this._getMethod('strokeRect');
|
|
635
|
+
strokeRect(x, y, width, height);
|
|
826
636
|
}
|
|
827
637
|
strokeText(text, x, y, maxWidth) {
|
|
828
638
|
this.log('strokeText value:', text, x, y, maxWidth);
|
|
829
639
|
this._ensureLayoutBeforeDraw();
|
|
640
|
+
const strokeText = this._getMethod('strokeText');
|
|
830
641
|
if (typeof maxWidth === 'number') {
|
|
831
|
-
|
|
642
|
+
strokeText(text + '', x, y, maxWidth);
|
|
832
643
|
}
|
|
833
644
|
else {
|
|
834
|
-
|
|
645
|
+
strokeText(text + '', x, y);
|
|
835
646
|
}
|
|
836
647
|
}
|
|
837
648
|
transform(a, b, c, d, e, f) {
|
|
838
649
|
this.log('transform value:', a, b, c, d, e, f);
|
|
839
650
|
this._ensureLayoutBeforeDraw();
|
|
840
|
-
this.
|
|
651
|
+
const transform = this._getMethod('transform');
|
|
652
|
+
transform(a, b, c, d, e, f);
|
|
841
653
|
}
|
|
842
654
|
translate(x, y) {
|
|
843
655
|
this.log('translate value:', x, y);
|
|
844
656
|
this._ensureLayoutBeforeDraw();
|
|
845
|
-
this.
|
|
657
|
+
const translate = this._getMethod('translate');
|
|
658
|
+
translate(x, y);
|
|
846
659
|
}
|
|
847
660
|
_ensureLayoutBeforeDraw() {
|
|
848
661
|
if (this.canvas) {
|
|
@@ -857,4 +670,9 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
857
670
|
}
|
|
858
671
|
}
|
|
859
672
|
CanvasRenderingContext2D.isDebug = false;
|
|
673
|
+
(() => {
|
|
674
|
+
Helpers.initialize();
|
|
675
|
+
//ctor = global.CanvasJSIModule.create2DContext;
|
|
676
|
+
ctor = global.CanvasJSIModule.create2DContextWithPointer;
|
|
677
|
+
})();
|
|
860
678
|
//# sourceMappingURL=index.android.js.map
|