@nativescript/canvas 1.1.0-alpha.9 → 2.0.0-alpha.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/Canvas/common.d.ts +1 -5
- package/Canvas/common.js +31 -69
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +4 -4
- package/Canvas/index.android.js +62 -55
- 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 -43
- 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 +188 -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 +90 -107
- 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 +0 -3
- 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 +0 -3
- 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 +0 -3
- 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 -294
- 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/TextDecoder/TextDecoder.android.d.ts +2 -1
- package/TextDecoder/TextDecoder.android.js +19 -38
- package/TextDecoder/TextDecoder.android.js.map +1 -1
- package/TextDecoder/common.d.ts +0 -1
- package/TextDecoder/common.js +0 -3
- package/TextDecoder/common.js.map +1 -1
- package/TextEncoder/TextEncoder.android.d.ts +2 -0
- package/TextEncoder/TextEncoder.android.js +19 -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/index.android.d.ts +10 -13
- package/WebGL/WebGLRenderingContext/index.android.js +449 -952
- package/WebGL/WebGLRenderingContext/index.android.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.ios.js +4 -3
- 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 +8 -7
- package/WebGL2/WebGL2RenderingContext/index.android.js +290 -328
- 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 +4 -4
- package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
- 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 +1 -1
- 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.
|
|
195
|
+
if (color instanceof CanvasGradient || color instanceof CanvasPattern) {
|
|
196
|
+
this.context.fillStyle = color.native;
|
|
409
197
|
}
|
|
410
|
-
else
|
|
411
|
-
this.context.
|
|
412
|
-
}
|
|
413
|
-
else if (color instanceof CanvasPattern) {
|
|
414
|
-
this.context.setFillStyle(color.native);
|
|
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.
|
|
220
|
+
if (color instanceof CanvasGradient || color instanceof CanvasPattern) {
|
|
221
|
+
this.context.strokeStyle = color.native;
|
|
448
222
|
}
|
|
449
|
-
else
|
|
450
|
-
this.context.
|
|
451
|
-
}
|
|
452
|
-
else if (color instanceof CanvasPattern) {
|
|
453
|
-
this.context.setStrokeStyle(color.native);
|
|
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,28 @@ 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;
|
|
542
335
|
}
|
|
543
336
|
else if (image instanceof android.graphics.Bitmap) {
|
|
544
|
-
|
|
337
|
+
const ptr = this._getMethod('__getPointer');
|
|
338
|
+
const createPattern = this._getMethod('__createPatternWithNative');
|
|
339
|
+
const pattern = org.nativescript.canvas.NSCCanvasRenderingContext2D.createPattern(long(ptr), image, repetition);
|
|
340
|
+
return new CanvasPattern(createPattern(pattern));
|
|
545
341
|
}
|
|
546
342
|
else if (image instanceof ImageAsset) {
|
|
547
343
|
img = image.native;
|
|
548
344
|
}
|
|
549
345
|
else if (image instanceof Canvas) {
|
|
550
|
-
img = image.
|
|
346
|
+
img = image.native;
|
|
551
347
|
}
|
|
552
348
|
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) {
|
|
349
|
+
if (image._image instanceof android.graphics.Bitmap) {
|
|
557
350
|
img = image._image;
|
|
558
351
|
}
|
|
559
352
|
else if (image._asset instanceof ImageAsset) {
|
|
@@ -564,47 +357,33 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
564
357
|
}
|
|
565
358
|
}
|
|
566
359
|
else if (image && typeof image.tagName === 'string' && image.tagName === 'CANVAS' && image._canvas instanceof Canvas) {
|
|
567
|
-
img = image._canvas.
|
|
360
|
+
img = image._canvas.native;
|
|
568
361
|
}
|
|
569
|
-
else if (image instanceof ImageBitmap
|
|
362
|
+
else if (image instanceof ImageBitmap) {
|
|
570
363
|
img = image.native;
|
|
571
364
|
}
|
|
572
365
|
if (!img) {
|
|
573
366
|
return null;
|
|
574
367
|
}
|
|
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));
|
|
368
|
+
return new CanvasPattern(createPattern(img, repetition));
|
|
591
369
|
}
|
|
592
370
|
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
593
371
|
this.log('createRadialGradient value:', x0, y0, r0, x1, y1, r1);
|
|
594
372
|
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));
|
|
373
|
+
const createRadialGradient = this._getMethod('createRadialGradient');
|
|
374
|
+
return CanvasGradient.fromNative(createRadialGradient(x0, y0, r0, x1, y1, r1));
|
|
601
375
|
}
|
|
602
376
|
drawFocusIfNeeded(...args) { }
|
|
603
377
|
drawImage(...args) {
|
|
378
|
+
var _a;
|
|
604
379
|
this.log('drawImage value:', ...args);
|
|
605
380
|
this._ensureLayoutBeforeDraw();
|
|
381
|
+
const drawImage = this._getMethod('drawImage');
|
|
606
382
|
let image = args[0];
|
|
607
|
-
if (image
|
|
383
|
+
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) {
|
|
384
|
+
image = image.native;
|
|
385
|
+
}
|
|
386
|
+
else if (image instanceof ImageAsset) {
|
|
608
387
|
image = image.native;
|
|
609
388
|
}
|
|
610
389
|
else if (image instanceof ImageSource) {
|
|
@@ -614,7 +393,7 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
614
393
|
image = image;
|
|
615
394
|
}
|
|
616
395
|
else if (image instanceof Canvas) {
|
|
617
|
-
image = image.
|
|
396
|
+
image = image.native;
|
|
618
397
|
}
|
|
619
398
|
else if (image && typeof image.tagName === 'string' && (image.tagName === 'IMG' || image.tagName === 'IMAGE')) {
|
|
620
399
|
if (image._imageSource instanceof ImageSource) {
|
|
@@ -633,110 +412,115 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
633
412
|
else if (image && typeof image.tagName === 'string' && image.tagName === 'CANVAS' && image._canvas instanceof Canvas) {
|
|
634
413
|
image = image._canvas.android;
|
|
635
414
|
}
|
|
636
|
-
else if (image instanceof ImageBitmap
|
|
415
|
+
else if (image instanceof ImageBitmap) {
|
|
637
416
|
image = image.native;
|
|
638
417
|
}
|
|
639
418
|
if (args.length === 3) {
|
|
640
|
-
|
|
419
|
+
drawImage(image, args[1], args[2]);
|
|
641
420
|
}
|
|
642
421
|
else if (args.length === 5) {
|
|
643
|
-
|
|
422
|
+
drawImage(image, args[1], args[2], args[3], args[4]);
|
|
644
423
|
}
|
|
645
424
|
else if (args.length === 9) {
|
|
646
|
-
|
|
425
|
+
drawImage(image, args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
|
|
647
426
|
}
|
|
648
427
|
}
|
|
649
428
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
650
429
|
this.log('ellipse value:', x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
651
430
|
this._ensureLayoutBeforeDraw();
|
|
652
|
-
this.
|
|
431
|
+
const ellipse = this._getMethod('ellipse');
|
|
432
|
+
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
653
433
|
}
|
|
654
434
|
fill(...args) {
|
|
655
435
|
this.log('fill value:', ...args);
|
|
656
436
|
this._ensureLayoutBeforeDraw();
|
|
657
|
-
|
|
658
|
-
this.context.fill();
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
437
|
+
const fill = this._getMethod('fill');
|
|
661
438
|
if (typeof args[0] === 'string') {
|
|
662
|
-
|
|
663
|
-
this.context.fill(rule);
|
|
439
|
+
fill(args[0]);
|
|
664
440
|
}
|
|
665
441
|
else if (args[0] instanceof Path2D && typeof args[1] === 'string') {
|
|
666
|
-
|
|
667
|
-
this.context.fill(args[0].native, rule);
|
|
442
|
+
fill(args[0].native, args[1]);
|
|
668
443
|
}
|
|
669
444
|
else if (args[0] instanceof Path2D) {
|
|
670
|
-
|
|
445
|
+
fill(args[0].native);
|
|
671
446
|
}
|
|
672
447
|
else {
|
|
673
|
-
|
|
448
|
+
fill();
|
|
674
449
|
}
|
|
675
450
|
}
|
|
676
451
|
fillRect(x, y, width, height) {
|
|
677
452
|
this.log('fillRect value:', x, y, width, height);
|
|
678
453
|
this._ensureLayoutBeforeDraw();
|
|
679
|
-
this.
|
|
454
|
+
const fillRect = this._getMethod('fillRect');
|
|
455
|
+
fillRect(x, y, width, height);
|
|
680
456
|
}
|
|
681
457
|
fillText(text, x, y, maxWidth) {
|
|
682
458
|
this.log('fillText value:', text, x, y, maxWidth);
|
|
683
459
|
this._ensureLayoutBeforeDraw();
|
|
460
|
+
const fillText = this._getMethod('fillText');
|
|
684
461
|
if (typeof maxWidth === 'number') {
|
|
685
|
-
|
|
462
|
+
fillText(text + '', x, y, maxWidth);
|
|
686
463
|
}
|
|
687
464
|
else {
|
|
688
|
-
|
|
465
|
+
fillText(text + '', x, y);
|
|
689
466
|
}
|
|
690
467
|
}
|
|
691
468
|
getImageData(sx, sy, sw, sh) {
|
|
692
469
|
this.log('getImageData value:', sx, sy, sw, sh);
|
|
693
470
|
this._ensureLayoutBeforeDraw();
|
|
694
|
-
|
|
471
|
+
const getImageData = this._getMethod('getImageData');
|
|
472
|
+
return ImageData.fromNative(getImageData(sx, sy, sw, sh));
|
|
695
473
|
}
|
|
696
474
|
getLineDash() {
|
|
697
475
|
this.log('getLineDash');
|
|
698
476
|
this._ensureLayoutBeforeDraw();
|
|
699
|
-
|
|
477
|
+
const getLineDash = this._getMethod('getLineDash');
|
|
478
|
+
return getLineDash();
|
|
700
479
|
}
|
|
701
480
|
isPointInPath(...args) {
|
|
702
481
|
this.log('isPointInPath value:', ...args);
|
|
703
482
|
this._ensureLayoutBeforeDraw();
|
|
483
|
+
const isPointInPath = this._getMethod('isPointInPath');
|
|
704
484
|
if (args.length === 2) {
|
|
705
|
-
return
|
|
485
|
+
return isPointInPath(args[0], args[1]);
|
|
706
486
|
}
|
|
707
487
|
else if (args.length === 3) {
|
|
708
|
-
return
|
|
488
|
+
return isPointInPath(args[0], args[1], args[2]);
|
|
709
489
|
}
|
|
710
490
|
else if (args.length === 4 && args[0] instanceof Path2D) {
|
|
711
|
-
return
|
|
491
|
+
return isPointInPath(args[0].native, args[1], args[2], args[3]);
|
|
712
492
|
}
|
|
713
493
|
return false;
|
|
714
494
|
}
|
|
715
495
|
isPointInStroke(...args) {
|
|
716
496
|
this.log('isPointInStroke value:', ...args);
|
|
717
497
|
this._ensureLayoutBeforeDraw();
|
|
498
|
+
const isPointInStroke = this._getMethod('isPointInStroke');
|
|
718
499
|
if (args.length === 2) {
|
|
719
|
-
return
|
|
500
|
+
return isPointInStroke(args[0], args[1]);
|
|
720
501
|
}
|
|
721
502
|
else if (args.length === 3 && args[0] instanceof Path2D) {
|
|
722
|
-
return
|
|
503
|
+
return isPointInStroke(args[0].native, args[1], args[2]);
|
|
723
504
|
}
|
|
724
505
|
return false;
|
|
725
506
|
}
|
|
726
507
|
lineTo(x, y) {
|
|
727
508
|
this.log('lineTo value:', x, y);
|
|
728
509
|
this._ensureLayoutBeforeDraw();
|
|
729
|
-
this.
|
|
510
|
+
const lineTo = this._getMethod('lineTo');
|
|
511
|
+
lineTo(x, y);
|
|
730
512
|
}
|
|
731
513
|
measureText(text) {
|
|
732
514
|
this.log('measureText value:', text);
|
|
733
515
|
this._ensureLayoutBeforeDraw();
|
|
734
|
-
|
|
516
|
+
const measureText = this._getMethod('measureText');
|
|
517
|
+
return new TextMetrics(measureText(text));
|
|
735
518
|
}
|
|
736
519
|
moveTo(x, y) {
|
|
737
520
|
this.log('moveTo value:', x, y);
|
|
738
521
|
this._ensureLayoutBeforeDraw();
|
|
739
|
-
this.
|
|
522
|
+
const moveTo = this._getMethod('moveTo');
|
|
523
|
+
moveTo(x, y);
|
|
740
524
|
}
|
|
741
525
|
putImageData(...args) {
|
|
742
526
|
this.log('putImageData value:', ...args);
|
|
@@ -744,105 +528,110 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
744
528
|
if (!args) {
|
|
745
529
|
return;
|
|
746
530
|
}
|
|
531
|
+
const putImageData = this._getMethod('putImageData');
|
|
747
532
|
let data = args[0];
|
|
748
533
|
if (args.length === 3) {
|
|
749
|
-
|
|
534
|
+
putImageData(data.native, args[1], args[2]);
|
|
750
535
|
}
|
|
751
536
|
else if (args.length === 7) {
|
|
752
|
-
|
|
537
|
+
putImageData(data.native, args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
753
538
|
}
|
|
754
539
|
}
|
|
755
540
|
quadraticCurveTo(cpx, cpy, x, y) {
|
|
756
541
|
this.log('quadraticCurveTo value:', cpx, cpy, x, y);
|
|
757
542
|
this._ensureLayoutBeforeDraw();
|
|
758
|
-
this.
|
|
543
|
+
const quadraticCurveTo = this._getMethod('quadraticCurveTo');
|
|
544
|
+
quadraticCurveTo(cpx, cpy, x, y);
|
|
759
545
|
}
|
|
760
546
|
rect(x, y, width, height) {
|
|
761
547
|
this.log('rect value:', x, y, width, height);
|
|
762
548
|
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
|
-
}
|
|
549
|
+
const rect = this._getMethod('rect');
|
|
550
|
+
rect(x, y, width, height);
|
|
774
551
|
}
|
|
775
552
|
removeHitRegion(id) { }
|
|
776
553
|
resetTransform() {
|
|
777
554
|
this.log('resetTransform value:');
|
|
778
555
|
this._ensureLayoutBeforeDraw();
|
|
779
|
-
this.
|
|
556
|
+
const resetTransform = this._getMethod('resetTransform');
|
|
557
|
+
resetTransform();
|
|
780
558
|
}
|
|
781
559
|
restore() {
|
|
782
560
|
this.log('restore');
|
|
783
561
|
this._ensureLayoutBeforeDraw();
|
|
784
|
-
this.
|
|
562
|
+
const restore = this._getMethod('restore');
|
|
563
|
+
restore();
|
|
785
564
|
}
|
|
786
565
|
rotate(angle) {
|
|
787
566
|
this.log('rotate value:', angle);
|
|
788
567
|
this._ensureLayoutBeforeDraw();
|
|
789
|
-
this.
|
|
568
|
+
const rotate = this._getMethod('rotate');
|
|
569
|
+
rotate(angle);
|
|
790
570
|
}
|
|
791
571
|
save() {
|
|
792
572
|
this.log('save');
|
|
793
573
|
this._ensureLayoutBeforeDraw();
|
|
794
|
-
this.
|
|
574
|
+
const save = this._getMethod('save');
|
|
575
|
+
save();
|
|
795
576
|
}
|
|
796
577
|
scale(x, y) {
|
|
797
578
|
this.log('scale value:', x, y);
|
|
798
579
|
this._ensureLayoutBeforeDraw();
|
|
799
|
-
this.
|
|
580
|
+
const scale = this._getMethod('scale');
|
|
581
|
+
scale(x, y);
|
|
800
582
|
}
|
|
801
583
|
scrollPathIntoView(path) { }
|
|
802
584
|
setLineDash(segments) {
|
|
803
585
|
this.log('setLineDash value:', segments);
|
|
804
586
|
this._ensureLayoutBeforeDraw();
|
|
805
|
-
this.
|
|
587
|
+
const setLineDash = this._getMethod('setLineDash');
|
|
588
|
+
setLineDash(segments);
|
|
806
589
|
}
|
|
807
590
|
setTransform(a, b, c, d, e, f) {
|
|
808
591
|
this.log('setTransform value:', a, b, c, d, e, f);
|
|
809
592
|
this._ensureLayoutBeforeDraw();
|
|
810
|
-
this.
|
|
593
|
+
const setTransform = this._getMethod('setTransform');
|
|
594
|
+
setTransform(a, b, c, d, e, f);
|
|
811
595
|
}
|
|
812
596
|
stroke(path) {
|
|
813
597
|
this.log('stroke value:', path);
|
|
814
598
|
this._ensureLayoutBeforeDraw();
|
|
599
|
+
const stroke = this._getMethod('stroke');
|
|
815
600
|
if (path) {
|
|
816
|
-
|
|
601
|
+
stroke(path.native);
|
|
817
602
|
}
|
|
818
603
|
else {
|
|
819
|
-
|
|
604
|
+
stroke();
|
|
820
605
|
}
|
|
821
606
|
}
|
|
822
607
|
strokeRect(x, y, width, height) {
|
|
823
608
|
this.log('strokeRect value:', x, y, width, height);
|
|
824
609
|
this._ensureLayoutBeforeDraw();
|
|
825
|
-
this.
|
|
610
|
+
const strokeRect = this._getMethod('strokeRect');
|
|
611
|
+
strokeRect(x, y, width, height);
|
|
826
612
|
}
|
|
827
613
|
strokeText(text, x, y, maxWidth) {
|
|
828
614
|
this.log('strokeText value:', text, x, y, maxWidth);
|
|
829
615
|
this._ensureLayoutBeforeDraw();
|
|
616
|
+
const strokeText = this._getMethod('strokeText');
|
|
830
617
|
if (typeof maxWidth === 'number') {
|
|
831
|
-
|
|
618
|
+
strokeText(text + '', x, y, maxWidth);
|
|
832
619
|
}
|
|
833
620
|
else {
|
|
834
|
-
|
|
621
|
+
strokeText(text + '', x, y);
|
|
835
622
|
}
|
|
836
623
|
}
|
|
837
624
|
transform(a, b, c, d, e, f) {
|
|
838
625
|
this.log('transform value:', a, b, c, d, e, f);
|
|
839
626
|
this._ensureLayoutBeforeDraw();
|
|
840
|
-
this.
|
|
627
|
+
const transform = this._getMethod('transform');
|
|
628
|
+
transform(a, b, c, d, e, f);
|
|
841
629
|
}
|
|
842
630
|
translate(x, y) {
|
|
843
631
|
this.log('translate value:', x, y);
|
|
844
632
|
this._ensureLayoutBeforeDraw();
|
|
845
|
-
this.
|
|
633
|
+
const translate = this._getMethod('translate');
|
|
634
|
+
translate(x, y);
|
|
846
635
|
}
|
|
847
636
|
_ensureLayoutBeforeDraw() {
|
|
848
637
|
if (this.canvas) {
|
|
@@ -857,4 +646,9 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
|
857
646
|
}
|
|
858
647
|
}
|
|
859
648
|
CanvasRenderingContext2D.isDebug = false;
|
|
649
|
+
(() => {
|
|
650
|
+
Helpers.initialize();
|
|
651
|
+
//ctor = global.CanvasJSIModule.create2DContext;
|
|
652
|
+
ctor = global.CanvasJSIModule.create2DContextWithPointer;
|
|
653
|
+
})();
|
|
860
654
|
//# sourceMappingURL=index.android.js.map
|