@nativescript/canvas 0.9.22-v6 → 1.0.0-alpha.10
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 +17 -24
- package/Canvas/common.js +207 -182
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +8 -6
- package/Canvas/index.android.js +155 -156
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.d.ts +10 -7
- package/Canvas/index.ios.js +141 -153
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.android.d.ts +2 -2
- package/Canvas2D/CanvasGradient/CanvasGradient.android.js +13 -23
- package/Canvas2D/CanvasGradient/CanvasGradient.android.js.map +1 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.d.ts +1 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.ios.d.ts +1 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.ios.js +13 -23
- package/Canvas2D/CanvasGradient/CanvasGradient.ios.js.map +1 -1
- package/Canvas2D/CanvasGradient/common.d.ts +1 -1
- package/Canvas2D/CanvasGradient/common.js +2 -8
- package/Canvas2D/CanvasGradient/common.js.map +1 -1
- package/Canvas2D/CanvasGradient/index.js +2 -7
- package/Canvas2D/CanvasGradient/index.js.map +1 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.android.js +8 -14
- package/Canvas2D/CanvasPattern/CanvasPattern.android.js.map +1 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.ios.js +7 -12
- package/Canvas2D/CanvasPattern/CanvasPattern.ios.js.map +1 -1
- package/Canvas2D/CanvasPattern/common.d.ts +1 -1
- package/Canvas2D/CanvasPattern/common.js +6 -14
- package/Canvas2D/CanvasPattern/common.js.map +1 -1
- package/Canvas2D/CanvasPattern/index.js +2 -7
- package/Canvas2D/CanvasPattern/index.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/common.d.ts +21 -21
- package/Canvas2D/CanvasRenderingContext2D/common.js +9 -21
- package/Canvas2D/CanvasRenderingContext2D/common.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.android.d.ts +40 -21
- package/Canvas2D/CanvasRenderingContext2D/index.android.js +602 -638
- package/Canvas2D/CanvasRenderingContext2D/index.android.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.ios.d.ts +40 -21
- package/Canvas2D/CanvasRenderingContext2D/index.ios.js +621 -737
- package/Canvas2D/CanvasRenderingContext2D/index.ios.js.map +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.android.d.ts +44 -22
- package/Canvas2D/DOMMatrix/DOMMatrix.android.js +141 -231
- package/Canvas2D/DOMMatrix/DOMMatrix.android.js.map +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.d.ts +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.ios.d.ts +44 -22
- package/Canvas2D/DOMMatrix/DOMMatrix.ios.js +141 -225
- package/Canvas2D/DOMMatrix/DOMMatrix.ios.js.map +1 -1
- package/Canvas2D/DOMMatrix/common.d.ts +23 -7
- package/Canvas2D/DOMMatrix/common.js +6 -14
- package/Canvas2D/DOMMatrix/common.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.js +2 -7
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/ImageData/ImageData.android.d.ts +4 -0
- package/Canvas2D/ImageData/ImageData.android.js +41 -16
- package/Canvas2D/ImageData/ImageData.android.js.map +1 -1
- package/Canvas2D/ImageData/ImageData.ios.d.ts +4 -0
- package/Canvas2D/ImageData/ImageData.ios.js +41 -16
- package/Canvas2D/ImageData/ImageData.ios.js.map +1 -1
- package/Canvas2D/ImageData/common.d.ts +5 -5
- package/Canvas2D/ImageData/common.js +6 -17
- package/Canvas2D/ImageData/common.js.map +1 -1
- package/Canvas2D/ImageData/index.js +2 -7
- package/Canvas2D/ImageData/index.js.map +1 -1
- package/Canvas2D/Path2D/Path2D.android.js +26 -35
- package/Canvas2D/Path2D/Path2D.android.js.map +1 -1
- package/Canvas2D/Path2D/Path2D.ios.js +26 -35
- package/Canvas2D/Path2D/Path2D.ios.js.map +1 -1
- package/Canvas2D/Path2D/common.d.ts +1 -1
- package/Canvas2D/Path2D/common.js +6 -14
- package/Canvas2D/Path2D/common.js.map +1 -1
- package/Canvas2D/Path2D/index.js +2 -7
- package/Canvas2D/Path2D/index.js.map +1 -1
- package/Canvas2D/TextMetrics/TextMetrics.android.d.ts +13 -14
- package/Canvas2D/TextMetrics/TextMetrics.android.js +41 -94
- package/Canvas2D/TextMetrics/TextMetrics.android.js.map +1 -1
- package/Canvas2D/TextMetrics/TextMetrics.d.ts +1 -12
- package/Canvas2D/TextMetrics/TextMetrics.ios.d.ts +12 -12
- package/Canvas2D/TextMetrics/TextMetrics.ios.js +41 -94
- package/Canvas2D/TextMetrics/TextMetrics.ios.js.map +1 -1
- package/Canvas2D/TextMetrics/common.d.ts +14 -2
- package/Canvas2D/TextMetrics/common.js +6 -14
- package/Canvas2D/TextMetrics/common.js.map +1 -1
- package/Canvas2D/TextMetrics/index.js +2 -7
- package/Canvas2D/TextMetrics/index.js.map +1 -1
- package/Canvas2D/index.js +6 -11
- package/Canvas2D/index.js.map +1 -1
- package/ImageAsset/ImageAsset.android.d.ts +4 -4
- package/ImageAsset/ImageAsset.android.js +79 -101
- package/ImageAsset/ImageAsset.android.js.map +1 -1
- package/ImageAsset/ImageAsset.d.ts +1 -1
- package/ImageAsset/ImageAsset.ios.d.ts +5 -4
- package/ImageAsset/ImageAsset.ios.js +82 -107
- package/ImageAsset/ImageAsset.ios.js.map +1 -1
- package/ImageAsset/common.d.ts +1 -1
- package/ImageAsset/common.js +8 -16
- package/ImageAsset/common.js.map +1 -1
- package/ImageAsset/index.js +2 -7
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/common.d.ts +8 -0
- package/ImageBitmap/common.js +9 -0
- package/ImageBitmap/common.js.map +1 -0
- package/ImageBitmap/index.android.d.ts +12 -0
- package/ImageBitmap/index.android.js +332 -0
- package/ImageBitmap/index.android.js.map +1 -0
- package/ImageBitmap/index.ios.d.ts +12 -0
- package/ImageBitmap/index.ios.js +283 -0
- package/ImageBitmap/index.ios.js.map +1 -0
- package/README.md +26 -27
- package/SVG/Circle.d.ts +3 -3
- package/SVG/Circle.js +16 -89
- package/SVG/Circle.js.map +1 -1
- package/SVG/ClipPath.d.ts +1 -0
- package/SVG/ClipPath.js +7 -10
- package/SVG/ClipPath.js.map +1 -1
- package/SVG/Defs.d.ts +1 -4
- package/SVG/Defs.js +7 -18
- package/SVG/Defs.js.map +1 -1
- package/SVG/Ellipse.d.ts +1 -2
- package/SVG/Ellipse.js +16 -43
- package/SVG/Ellipse.js.map +1 -1
- package/SVG/G.d.ts +1 -7
- package/SVG/G.js +7 -64
- package/SVG/G.js.map +1 -1
- package/SVG/Image.d.ts +5 -4
- package/SVG/Image.js +28 -74
- package/SVG/Image.js.map +1 -1
- package/SVG/Line.d.ts +1 -1
- package/SVG/Line.js +16 -39
- package/SVG/Line.js.map +1 -1
- package/SVG/LinearGradient.d.ts +1 -4
- package/SVG/LinearGradient.js +11 -54
- package/SVG/LinearGradient.js.map +1 -1
- package/SVG/Path.d.ts +2 -2
- package/SVG/Path.js +10 -81
- package/SVG/Path.js.map +1 -1
- package/SVG/Pattern.d.ts +1 -9
- package/SVG/Pattern.js +7 -89
- package/SVG/Pattern.js.map +1 -1
- package/SVG/Polygon.d.ts +2 -2
- package/SVG/Polygon.js +10 -63
- package/SVG/Polygon.js.map +1 -1
- package/SVG/Polyline.d.ts +1 -1
- package/SVG/Polyline.js +10 -64
- package/SVG/Polyline.js.map +1 -1
- package/SVG/Rect.d.ts +1 -1
- package/SVG/Rect.js +11 -74
- package/SVG/Rect.js.map +1 -1
- package/SVG/SVG.d.ts +23 -9
- package/SVG/SVG.js +162 -55
- package/SVG/SVG.js.map +1 -1
- package/SVG/SVGItem.d.ts +2 -19
- package/SVG/SVGItem.js +6 -191
- package/SVG/SVGItem.js.map +1 -1
- package/SVG/Stop.d.ts +1 -2
- package/SVG/Stop.js +7 -32
- package/SVG/Stop.js.map +1 -1
- package/SVG/Symbol.d.ts +1 -4
- package/SVG/Symbol.js +7 -18
- package/SVG/Symbol.js.map +1 -1
- package/SVG/Text.d.ts +6 -5
- package/SVG/Text.js +18 -19
- package/SVG/Text.js.map +1 -1
- package/SVG/Use.d.ts +1 -10
- package/SVG/Use.js +7 -96
- package/SVG/Use.js.map +1 -1
- package/SVG/index.js +18 -40
- package/SVG/index.js.map +1 -1
- package/TextDecoder/TextDecoder.android.d.ts +2 -1
- package/TextDecoder/TextDecoder.android.js +39 -40
- package/TextDecoder/TextDecoder.android.js.map +1 -1
- package/TextDecoder/TextDecoder.ios.d.ts +1 -1
- package/TextDecoder/TextDecoder.ios.js +23 -36
- package/TextDecoder/TextDecoder.ios.js.map +1 -1
- package/TextDecoder/common.d.ts +4 -4
- package/TextDecoder/common.js +6 -17
- package/TextDecoder/common.js.map +1 -1
- package/TextDecoder/index.js +2 -7
- package/TextDecoder/index.js.map +1 -1
- package/TextEncoder/TextEncoder.android.d.ts +1 -1
- package/TextEncoder/TextEncoder.android.js +11 -21
- package/TextEncoder/TextEncoder.android.js.map +1 -1
- package/TextEncoder/TextEncoder.ios.d.ts +1 -1
- package/TextEncoder/TextEncoder.ios.js +11 -21
- package/TextEncoder/TextEncoder.ios.js.map +1 -1
- package/TextEncoder/common.d.ts +4 -4
- package/TextEncoder/common.js +6 -17
- package/TextEncoder/common.js.map +1 -1
- package/TextEncoder/index.js +2 -7
- package/TextEncoder/index.js.map +1 -1
- package/WebGL/WebGLActiveInfo.js +8 -10
- package/WebGL/WebGLActiveInfo.js.map +1 -1
- package/WebGL/WebGLBuffer.d.ts +1 -1
- package/WebGL/WebGLBuffer.js +11 -17
- package/WebGL/WebGLBuffer.js.map +1 -1
- package/WebGL/WebGLExtensions/index.android.js +137 -190
- package/WebGL/WebGLExtensions/index.android.js.map +1 -1
- package/WebGL/WebGLExtensions/index.ios.js +110 -163
- package/WebGL/WebGLExtensions/index.ios.js.map +1 -1
- package/WebGL/WebGLFramebuffer.d.ts +1 -1
- package/WebGL/WebGLFramebuffer.js +11 -17
- package/WebGL/WebGLFramebuffer.js.map +1 -1
- package/WebGL/WebGLProgram.d.ts +1 -1
- package/WebGL/WebGLProgram.js +11 -17
- package/WebGL/WebGLProgram.js.map +1 -1
- package/WebGL/WebGLRenderbuffer.d.ts +1 -1
- package/WebGL/WebGLRenderbuffer.js +11 -17
- package/WebGL/WebGLRenderbuffer.js.map +1 -1
- package/WebGL/WebGLRenderingContext/common.d.ts +301 -301
- package/WebGL/WebGLRenderingContext/common.js +940 -2140
- package/WebGL/WebGLRenderingContext/common.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.android.d.ts +10 -5
- package/WebGL/WebGLRenderingContext/index.android.js +1014 -587
- package/WebGL/WebGLRenderingContext/index.android.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.d.ts +2 -0
- package/WebGL/WebGLRenderingContext/index.ios.d.ts +3 -3
- package/WebGL/WebGLRenderingContext/index.ios.js +502 -573
- package/WebGL/WebGLRenderingContext/index.ios.js.map +1 -1
- package/WebGL/WebGLShader.d.ts +1 -1
- package/WebGL/WebGLShader.js +11 -17
- package/WebGL/WebGLShader.js.map +1 -1
- package/WebGL/WebGLShaderPrecisionFormat.js +8 -10
- package/WebGL/WebGLShaderPrecisionFormat.js.map +1 -1
- package/WebGL/WebGLTexture.d.ts +1 -1
- package/WebGL/WebGLTexture.js +11 -17
- package/WebGL/WebGLTexture.js.map +1 -1
- package/WebGL/WebGLUniformLocation.d.ts +1 -1
- package/WebGL/WebGLUniformLocation.js +11 -17
- package/WebGL/WebGLUniformLocation.js.map +1 -1
- package/WebGL/index.js +9 -14
- package/WebGL/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/common.d.ts +265 -265
- package/WebGL2/WebGL2RenderingContext/common.js +817 -1885
- package/WebGL2/WebGL2RenderingContext/common.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.android.d.ts +4 -1
- package/WebGL2/WebGL2RenderingContext/index.android.js +359 -293
- package/WebGL2/WebGL2RenderingContext/index.android.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.ios.d.ts +3 -1
- package/WebGL2/WebGL2RenderingContext/index.ios.js +289 -260
- package/WebGL2/WebGL2RenderingContext/index.ios.js.map +1 -1
- package/WebGL2/WebGLQuery.d.ts +1 -1
- package/WebGL2/WebGLQuery.js +11 -17
- package/WebGL2/WebGLQuery.js.map +1 -1
- package/WebGL2/WebGLSampler.d.ts +1 -1
- package/WebGL2/WebGLSampler.js +11 -17
- package/WebGL2/WebGLSampler.js.map +1 -1
- package/WebGL2/WebGLSync.d.ts +1 -1
- package/WebGL2/WebGLSync.js +11 -17
- package/WebGL2/WebGLSync.js.map +1 -1
- package/WebGL2/WebGLTransformFeedback.d.ts +1 -1
- package/WebGL2/WebGLTransformFeedback.js +11 -17
- package/WebGL2/WebGLTransformFeedback.js.map +1 -1
- package/WebGL2/WebGLVertexArrayObject.d.ts +1 -1
- package/WebGL2/WebGLVertexArrayObject.js +11 -17
- package/WebGL2/WebGLVertexArrayObject.js.map +1 -1
- package/WebGL2/index.js +5 -10
- package/WebGL2/index.js.map +1 -1
- package/angular/bundles/nativescript-canvas-angular.umd.js +29 -0
- package/angular/bundles/nativescript-canvas-angular.umd.js.map +1 -0
- package/angular/esm2015/index.js +12 -0
- package/angular/esm2015/nativescript-canvas-angular.js +5 -0
- package/angular/fesm2015/nativescript-canvas-angular.js +19 -0
- package/angular/fesm2015/nativescript-canvas-angular.js.map +1 -0
- package/angular/nativescript-canvas-angular.d.ts +4 -0
- package/angular/nativescript-canvas-angular.metadata.json +1 -0
- package/angular/package.json +14 -0
- package/common.js +4 -12
- package/common.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +56 -28
- package/index.js.map +1 -1
- package/package.json +10 -6
- package/platforms/android/include.gradle +22 -1
- package/platforms/ios/Podfile +2 -4
- package/react/index.js +2 -4
- package/react/index.js.map +1 -1
- package/svelte/index.js +2 -4
- package/svelte/index.js.map +1 -1
- package/utils.d.ts +4 -0
- package/utils.js +46 -22
- package/utils.js.map +1 -1
- package/vue/index.d.ts +4 -0
- package/vue/index.js +6 -0
- package/vue/index.js.map +1 -0
- package/Canvas/common.metadata.json +0 -1
- package/Canvas/index.android.metadata.json +0 -1
- package/Canvas/index.ios.metadata.json +0 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.android.metadata.json +0 -1
- package/Canvas2D/CanvasGradient/CanvasGradient.ios.metadata.json +0 -1
- package/Canvas2D/CanvasGradient/common.metadata.json +0 -1
- package/Canvas2D/CanvasGradient/index.metadata.json +0 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.android.metadata.json +0 -1
- package/Canvas2D/CanvasPattern/CanvasPattern.ios.metadata.json +0 -1
- package/Canvas2D/CanvasPattern/common.metadata.json +0 -1
- package/Canvas2D/CanvasPattern/index.metadata.json +0 -1
- package/Canvas2D/CanvasRenderingContext2D/common.metadata.json +0 -1
- package/Canvas2D/CanvasRenderingContext2D/index.android.metadata.json +0 -1
- package/Canvas2D/CanvasRenderingContext2D/index.ios.metadata.json +0 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.android.metadata.json +0 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.ios.metadata.json +0 -1
- package/Canvas2D/DOMMatrix/common.metadata.json +0 -1
- package/Canvas2D/DOMMatrix/index.metadata.json +0 -1
- package/Canvas2D/ImageData/ImageData.android.metadata.json +0 -1
- package/Canvas2D/ImageData/ImageData.ios.metadata.json +0 -1
- package/Canvas2D/ImageData/common.metadata.json +0 -1
- package/Canvas2D/ImageData/index.metadata.json +0 -1
- package/Canvas2D/Path2D/Path2D.android.metadata.json +0 -1
- package/Canvas2D/Path2D/Path2D.ios.metadata.json +0 -1
- package/Canvas2D/Path2D/common.metadata.json +0 -1
- package/Canvas2D/Path2D/index.metadata.json +0 -1
- package/Canvas2D/TextMetrics/TextMetrics.android.metadata.json +0 -1
- package/Canvas2D/TextMetrics/TextMetrics.ios.metadata.json +0 -1
- package/Canvas2D/TextMetrics/common.metadata.json +0 -1
- package/Canvas2D/TextMetrics/index.metadata.json +0 -1
- package/Canvas2D/index.metadata.json +0 -1
- package/ImageAsset/ImageAsset.android.metadata.json +0 -1
- package/ImageAsset/ImageAsset.ios.metadata.json +0 -1
- package/ImageAsset/common.metadata.json +0 -1
- package/ImageAsset/index.metadata.json +0 -1
- package/SVG/Circle.metadata.json +0 -1
- package/SVG/ClipPath.metadata.json +0 -1
- package/SVG/Defs.metadata.json +0 -1
- package/SVG/Ellipse.metadata.json +0 -1
- package/SVG/G.metadata.json +0 -1
- package/SVG/Image.metadata.json +0 -1
- package/SVG/Line.metadata.json +0 -1
- package/SVG/LinearGradient.metadata.json +0 -1
- package/SVG/Path.metadata.json +0 -1
- package/SVG/Pattern.metadata.json +0 -1
- package/SVG/Polygon.metadata.json +0 -1
- package/SVG/Polyline.metadata.json +0 -1
- package/SVG/Rect.metadata.json +0 -1
- package/SVG/SVG.metadata.json +0 -1
- package/SVG/SVGItem.metadata.json +0 -1
- package/SVG/Stop.metadata.json +0 -1
- package/SVG/Symbol.metadata.json +0 -1
- package/SVG/Text.metadata.json +0 -1
- package/SVG/Use.metadata.json +0 -1
- package/SVG/index.metadata.json +0 -1
- package/TextDecoder/TextDecoder.android.metadata.json +0 -1
- package/TextDecoder/TextDecoder.ios.metadata.json +0 -1
- package/TextDecoder/common.metadata.json +0 -1
- package/TextDecoder/index.metadata.json +0 -1
- package/TextEncoder/TextEncoder.android.metadata.json +0 -1
- package/TextEncoder/TextEncoder.ios.metadata.json +0 -1
- package/TextEncoder/common.metadata.json +0 -1
- package/TextEncoder/index.metadata.json +0 -1
- package/WebGL/WebGLActiveInfo.metadata.json +0 -1
- package/WebGL/WebGLBuffer.metadata.json +0 -1
- package/WebGL/WebGLExtensions/index.android.metadata.json +0 -1
- package/WebGL/WebGLExtensions/index.ios.metadata.json +0 -1
- package/WebGL/WebGLFramebuffer.metadata.json +0 -1
- package/WebGL/WebGLProgram.metadata.json +0 -1
- package/WebGL/WebGLRenderbuffer.metadata.json +0 -1
- package/WebGL/WebGLRenderingContext/common.metadata.json +0 -1
- package/WebGL/WebGLRenderingContext/index.android.metadata.json +0 -1
- package/WebGL/WebGLRenderingContext/index.ios.metadata.json +0 -1
- package/WebGL/WebGLShader.metadata.json +0 -1
- package/WebGL/WebGLShaderPrecisionFormat.metadata.json +0 -1
- package/WebGL/WebGLTexture.metadata.json +0 -1
- package/WebGL/WebGLUniformLocation.metadata.json +0 -1
- package/WebGL/index.metadata.json +0 -1
- package/WebGL2/WebGL2RenderingContext/common.metadata.json +0 -1
- package/WebGL2/WebGL2RenderingContext/index.android.metadata.json +0 -1
- package/WebGL2/WebGL2RenderingContext/index.ios.metadata.json +0 -1
- package/WebGL2/WebGLQuery.metadata.json +0 -1
- package/WebGL2/WebGLSampler.metadata.json +0 -1
- package/WebGL2/WebGLSync.metadata.json +0 -1
- package/WebGL2/WebGLTransformFeedback.metadata.json +0 -1
- package/WebGL2/WebGLVertexArrayObject.metadata.json +0 -1
- package/WebGL2/index.metadata.json +0 -1
- package/angular/index.js +0 -19
- package/angular/index.js.map +0 -1
- package/angular/index.metadata.json +0 -1
- package/common.metadata.json +0 -1
- package/index.metadata.json +0 -1
- package/react/index.metadata.json +0 -1
- package/utils.metadata.json +0 -1
|
@@ -1,653 +1,641 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { CanvasRenderingContext2DBase } from './common';
|
|
2
|
+
import { CanvasGradient } from '../CanvasGradient';
|
|
3
|
+
import { Path2D } from '../Path2D';
|
|
4
|
+
import { ImageData } from '../ImageData';
|
|
5
|
+
import { TextMetrics } from '../TextMetrics';
|
|
6
|
+
import { ImageSource } from '@nativescript/core';
|
|
7
|
+
import { ImageAsset } from '../../ImageAsset';
|
|
8
|
+
import { CanvasPattern } from '../CanvasPattern';
|
|
9
|
+
import { Canvas } from '../../Canvas';
|
|
10
|
+
import lazy from '@nativescript/canvas/utils';
|
|
11
|
+
const FillRule = {
|
|
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
|
+
};
|
|
75
|
+
export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
|
|
76
|
+
constructor(context) {
|
|
77
|
+
super();
|
|
78
|
+
this.context = context;
|
|
79
|
+
}
|
|
80
|
+
_fillRuleFromString(string) {
|
|
21
81
|
if (string === 'evenodd') {
|
|
22
|
-
return
|
|
82
|
+
return FillRule.EvenOdd();
|
|
23
83
|
}
|
|
24
84
|
else if (string === 'nonzero') {
|
|
25
|
-
return
|
|
85
|
+
return FillRule.NonZero();
|
|
26
86
|
}
|
|
27
87
|
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
set: function (enabled) {
|
|
108
|
-
this.log('imageSmoothingEnabled value:', enabled);
|
|
109
|
-
this._ensureLayoutBeforeDraw();
|
|
110
|
-
if (this.context) {
|
|
111
|
-
this.context.setImageSmoothingEnabled(enabled);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
enumerable: true,
|
|
115
|
-
configurable: true
|
|
116
|
-
});
|
|
117
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "imageSmoothingQuality", {
|
|
118
|
-
get: function () {
|
|
119
|
-
this.log('imageSmoothingQuality');
|
|
120
|
-
return this.context.getImageSmoothingQuality().toString();
|
|
121
|
-
},
|
|
122
|
-
set: function (quality) {
|
|
123
|
-
this.log('imageSmoothingQuality value:', quality);
|
|
124
|
-
this._ensureLayoutBeforeDraw();
|
|
125
|
-
if (this.context) {
|
|
126
|
-
switch (quality) {
|
|
127
|
-
case 'high':
|
|
128
|
-
this.context.setImageSmoothingQuality(org.nativescript.canvas.TNSImageSmoothingQuality.High);
|
|
129
|
-
break;
|
|
130
|
-
case 'medium':
|
|
131
|
-
this.context.setImageSmoothingQuality(org.nativescript.canvas.TNSImageSmoothingQuality.Medium);
|
|
132
|
-
break;
|
|
133
|
-
default:
|
|
134
|
-
this.context.setImageSmoothingQuality(org.nativescript.canvas.TNSImageSmoothingQuality.Low);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
enumerable: true,
|
|
140
|
-
configurable: true
|
|
141
|
-
});
|
|
142
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "lineDashOffset", {
|
|
143
|
-
get: function () {
|
|
144
|
-
this.log('lineDashOffset');
|
|
145
|
-
return this.context.getLineDashOffset();
|
|
146
|
-
},
|
|
147
|
-
set: function (offset) {
|
|
148
|
-
this.log('lineDashOffset value:', offset);
|
|
149
|
-
this._ensureLayoutBeforeDraw();
|
|
150
|
-
if (this.context) {
|
|
151
|
-
this.context.setLineDashOffset(offset);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
enumerable: true,
|
|
155
|
-
configurable: true
|
|
156
|
-
});
|
|
157
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "lineJoin", {
|
|
158
|
-
get: function () {
|
|
159
|
-
this.log('lineJoin');
|
|
160
|
-
return this.context.getLineJoin().toString();
|
|
161
|
-
},
|
|
162
|
-
set: function (join) {
|
|
163
|
-
this.log('lineJoin value:', join);
|
|
164
|
-
this._ensureLayoutBeforeDraw();
|
|
165
|
-
if (this.context) {
|
|
166
|
-
switch (join) {
|
|
167
|
-
case 'bevel':
|
|
168
|
-
this.context.setLineJoin(org.nativescript.canvas.TNSLineJoin.Bevel);
|
|
169
|
-
break;
|
|
170
|
-
case 'round':
|
|
171
|
-
this.context.setLineJoin(org.nativescript.canvas.TNSLineJoin.Round);
|
|
172
|
-
break;
|
|
173
|
-
default:
|
|
174
|
-
this.context.setLineJoin(org.nativescript.canvas.TNSLineJoin.Miter);
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
enumerable: true,
|
|
180
|
-
configurable: true
|
|
181
|
-
});
|
|
182
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "lineCap", {
|
|
183
|
-
get: function () {
|
|
184
|
-
this.log('lineCap');
|
|
185
|
-
return this.context.getLineCap().toString();
|
|
186
|
-
},
|
|
187
|
-
set: function (cap) {
|
|
188
|
-
this.log('lineCap value:', cap);
|
|
189
|
-
this._ensureLayoutBeforeDraw();
|
|
190
|
-
if (this.context) {
|
|
191
|
-
switch (cap) {
|
|
192
|
-
case 'round':
|
|
193
|
-
this.context.setLineCap(org.nativescript.canvas.TNSLineCap.Round);
|
|
194
|
-
break;
|
|
195
|
-
case 'square':
|
|
196
|
-
this.context.setLineCap(org.nativescript.canvas.TNSLineCap.Square);
|
|
197
|
-
break;
|
|
198
|
-
default:
|
|
199
|
-
this.context.setLineCap(org.nativescript.canvas.TNSLineCap.Butt);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
enumerable: true,
|
|
204
|
-
configurable: true
|
|
205
|
-
});
|
|
206
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "miterLimit", {
|
|
207
|
-
get: function () {
|
|
208
|
-
this.log('miterLimit value:');
|
|
209
|
-
return this.context.getMiterLimit();
|
|
210
|
-
},
|
|
211
|
-
set: function (limit) {
|
|
212
|
-
this.log('miterLimit value:', limit);
|
|
213
|
-
this._ensureLayoutBeforeDraw();
|
|
214
|
-
if (this.context) {
|
|
215
|
-
this.context.setMiterLimit(limit);
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
enumerable: true,
|
|
219
|
-
configurable: true
|
|
220
|
-
});
|
|
221
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "shadowBlur", {
|
|
222
|
-
get: function () {
|
|
223
|
-
this.log('shadowBlur');
|
|
224
|
-
return this.context.getShadowBlur();
|
|
225
|
-
},
|
|
226
|
-
set: function (blur) {
|
|
227
|
-
this.log('shadowBlur value:', blur);
|
|
228
|
-
this._ensureLayoutBeforeDraw();
|
|
229
|
-
if (this.context) {
|
|
230
|
-
this.context.setShadowBlur(blur);
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
enumerable: true,
|
|
234
|
-
configurable: true
|
|
235
|
-
});
|
|
236
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "shadowOffsetX", {
|
|
237
|
-
get: function () {
|
|
238
|
-
this.log('shadowOffsetX');
|
|
239
|
-
return this.context.getShadowOffsetX();
|
|
240
|
-
},
|
|
241
|
-
set: function (x) {
|
|
242
|
-
this.log('shadowOffsetX value:', x);
|
|
243
|
-
this._ensureLayoutBeforeDraw();
|
|
244
|
-
if (this.context) {
|
|
245
|
-
this.context.setShadowOffsetX(x);
|
|
88
|
+
}
|
|
89
|
+
get native() {
|
|
90
|
+
return this.context;
|
|
91
|
+
}
|
|
92
|
+
get canvas() {
|
|
93
|
+
return this._canvas;
|
|
94
|
+
}
|
|
95
|
+
get shadowColor() {
|
|
96
|
+
this.log('shadowColor');
|
|
97
|
+
return this.context.getShadowColor();
|
|
98
|
+
}
|
|
99
|
+
set shadowColor(color) {
|
|
100
|
+
this.log('shadowColor value:', color);
|
|
101
|
+
this._ensureLayoutBeforeDraw();
|
|
102
|
+
if (this.context) {
|
|
103
|
+
this.context.setShadowColor(color);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get font() {
|
|
107
|
+
this.log('get font');
|
|
108
|
+
return this.context.getFont();
|
|
109
|
+
}
|
|
110
|
+
set font(value) {
|
|
111
|
+
this.log('set font value:', value);
|
|
112
|
+
if (this.context) {
|
|
113
|
+
this.context.setFont(value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
get direction() {
|
|
117
|
+
this.log('direction');
|
|
118
|
+
return this.context.getDirection() === TextDirection.Ltr() ? "ltr" : "rtl";
|
|
119
|
+
}
|
|
120
|
+
set direction(value) {
|
|
121
|
+
this.log('direction value:', value);
|
|
122
|
+
this._ensureLayoutBeforeDraw();
|
|
123
|
+
if (this.context) {
|
|
124
|
+
this.context.setDirection(value === "rtl" ? TextDirection.Rtl() : TextDirection.Ltr());
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get globalAlpha() {
|
|
128
|
+
this.log('globalAlpha');
|
|
129
|
+
return this.context.getGlobalAlpha();
|
|
130
|
+
}
|
|
131
|
+
set globalAlpha(alpha) {
|
|
132
|
+
this.log('globalAlpha value:', alpha);
|
|
133
|
+
this._ensureLayoutBeforeDraw();
|
|
134
|
+
if (this.context) {
|
|
135
|
+
this.context.setGlobalAlpha(alpha);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
get imageSmoothingEnabled() {
|
|
139
|
+
this.log('imageSmoothingEnabled');
|
|
140
|
+
return this.context.getImageSmoothingEnabled();
|
|
141
|
+
}
|
|
142
|
+
set imageSmoothingEnabled(enabled) {
|
|
143
|
+
this.log('imageSmoothingEnabled value:', enabled);
|
|
144
|
+
this._ensureLayoutBeforeDraw();
|
|
145
|
+
if (this.context) {
|
|
146
|
+
this.context.setImageSmoothingEnabled(enabled);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
get imageSmoothingQuality() {
|
|
150
|
+
this.log('imageSmoothingQuality');
|
|
151
|
+
return this.context.getImageSmoothingQuality().toString();
|
|
152
|
+
}
|
|
153
|
+
set imageSmoothingQuality(quality) {
|
|
154
|
+
this.log('imageSmoothingQuality value:', quality);
|
|
155
|
+
this._ensureLayoutBeforeDraw();
|
|
156
|
+
if (this.context) {
|
|
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;
|
|
246
167
|
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
this.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
get lineDashOffset() {
|
|
171
|
+
this.log('lineDashOffset');
|
|
172
|
+
return this.context.getLineDashOffset();
|
|
173
|
+
}
|
|
174
|
+
set lineDashOffset(offset) {
|
|
175
|
+
this.log('lineDashOffset value:', offset);
|
|
176
|
+
this._ensureLayoutBeforeDraw();
|
|
177
|
+
if (this.context) {
|
|
178
|
+
this.context.setLineDashOffset(offset);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
get lineJoin() {
|
|
182
|
+
this.log('lineJoin');
|
|
183
|
+
return this.context.getLineJoin().toString();
|
|
184
|
+
}
|
|
185
|
+
set lineJoin(join) {
|
|
186
|
+
this.log('lineJoin value:', join);
|
|
187
|
+
this._ensureLayoutBeforeDraw();
|
|
188
|
+
if (this.context) {
|
|
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;
|
|
261
199
|
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
break;
|
|
282
|
-
case 'end':
|
|
283
|
-
this.context.setTextAlign(org.nativescript.canvas.TNSTextAlignment.End);
|
|
284
|
-
break;
|
|
285
|
-
case 'right':
|
|
286
|
-
this.context.setTextAlign(org.nativescript.canvas.TNSTextAlignment.Right);
|
|
287
|
-
break;
|
|
288
|
-
default:
|
|
289
|
-
this.context.setTextAlign(org.nativescript.canvas.TNSTextAlignment.Left);
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
get lineCap() {
|
|
203
|
+
this.log('lineCap');
|
|
204
|
+
return this.context.getLineCap().toString();
|
|
205
|
+
}
|
|
206
|
+
set lineCap(cap) {
|
|
207
|
+
this.log('lineCap value:', cap);
|
|
208
|
+
this._ensureLayoutBeforeDraw();
|
|
209
|
+
if (this.context) {
|
|
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());
|
|
292
219
|
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.HardLight;
|
|
364
|
-
break;
|
|
365
|
-
case 'soft-light':
|
|
366
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.SoftLight;
|
|
367
|
-
break;
|
|
368
|
-
case 'difference':
|
|
369
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.Difference;
|
|
370
|
-
break;
|
|
371
|
-
case 'exclusion':
|
|
372
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.Exclusion;
|
|
373
|
-
break;
|
|
374
|
-
case 'hue':
|
|
375
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.Hue;
|
|
376
|
-
break;
|
|
377
|
-
case 'saturation':
|
|
378
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.Saturation;
|
|
379
|
-
break;
|
|
380
|
-
case 'color':
|
|
381
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.Color;
|
|
382
|
-
break;
|
|
383
|
-
case 'luminosity':
|
|
384
|
-
operation = org.nativescript.canvas.TNSCompositeOperationType.Luminosity;
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
this.context.setGlobalCompositeOperation(operation);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
get miterLimit() {
|
|
223
|
+
this.log('miterLimit value:');
|
|
224
|
+
return this.context.getMiterLimit();
|
|
225
|
+
}
|
|
226
|
+
set miterLimit(limit) {
|
|
227
|
+
this.log('miterLimit value:', limit);
|
|
228
|
+
this._ensureLayoutBeforeDraw();
|
|
229
|
+
if (this.context) {
|
|
230
|
+
this.context.setMiterLimit(limit);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
get shadowBlur() {
|
|
234
|
+
this.log('shadowBlur');
|
|
235
|
+
return this.context.getShadowBlur();
|
|
236
|
+
}
|
|
237
|
+
set shadowBlur(blur) {
|
|
238
|
+
this.log('shadowBlur value:', blur);
|
|
239
|
+
this._ensureLayoutBeforeDraw();
|
|
240
|
+
if (this.context) {
|
|
241
|
+
this.context.setShadowBlur(blur);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
get shadowOffsetX() {
|
|
245
|
+
this.log('shadowOffsetX');
|
|
246
|
+
return this.context.getShadowOffsetX();
|
|
247
|
+
}
|
|
248
|
+
set shadowOffsetX(x) {
|
|
249
|
+
this.log('shadowOffsetX value:', x);
|
|
250
|
+
this._ensureLayoutBeforeDraw();
|
|
251
|
+
if (this.context) {
|
|
252
|
+
this.context.setShadowOffsetX(x);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
get shadowOffsetY() {
|
|
256
|
+
this.log('shadowOffsetY');
|
|
257
|
+
return this.context.getShadowOffsetY();
|
|
258
|
+
}
|
|
259
|
+
set shadowOffsetY(y) {
|
|
260
|
+
this.log('shadowOffsetY value:', y);
|
|
261
|
+
this._ensureLayoutBeforeDraw();
|
|
262
|
+
if (this.context) {
|
|
263
|
+
this.context.setShadowOffsetY(y);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
get textAlign() {
|
|
267
|
+
this.log('textAlign');
|
|
268
|
+
return this.context.getTextAlign().toString();
|
|
269
|
+
}
|
|
270
|
+
set textAlign(alignment) {
|
|
271
|
+
this.log('textAlign value:', alignment);
|
|
272
|
+
this._ensureLayoutBeforeDraw();
|
|
273
|
+
if (this.context) {
|
|
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;
|
|
388
290
|
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
get globalCompositeOperation() {
|
|
294
|
+
this.log('globalCompositeOperation');
|
|
295
|
+
return this.context.getGlobalCompositeOperation().toString();
|
|
296
|
+
}
|
|
297
|
+
set globalCompositeOperation(composite) {
|
|
298
|
+
this.log('globalCompositeOperation value:', composite);
|
|
299
|
+
this._ensureLayoutBeforeDraw();
|
|
300
|
+
if (this.context) {
|
|
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
|
+
}
|
|
384
|
+
}
|
|
385
|
+
get fillStyle() {
|
|
386
|
+
this.log('fillStyle');
|
|
387
|
+
if (this.context) {
|
|
396
388
|
switch (this.context.getFillStyle().getStyleType()) {
|
|
397
|
-
case
|
|
398
|
-
|
|
399
|
-
return color.getColor();
|
|
400
|
-
case 1 /* Gradient */:
|
|
401
|
-
return CanvasGradient_1.CanvasGradient.fromNative(this.context.getFillStyle());
|
|
402
|
-
case 2 /* Pattern */:
|
|
403
|
-
return new CanvasPattern_1.CanvasPattern(this.context.getFillStyle());
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
set: function (color) {
|
|
407
|
-
this.log('fillStyle:', color);
|
|
408
|
-
if (color === undefined || color === null) {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
this._ensureLayoutBeforeDraw();
|
|
412
|
-
if (typeof color === 'string') {
|
|
413
|
-
this.context.setFillStyle(new org.nativescript.canvas.TNSColor(color));
|
|
414
|
-
}
|
|
415
|
-
else if (color instanceof CanvasGradient_1.CanvasGradient) {
|
|
416
|
-
this.context.setFillStyle(color.native);
|
|
417
|
-
}
|
|
418
|
-
else if (color instanceof CanvasPattern_1.CanvasPattern) {
|
|
419
|
-
this.context.setFillStyle(color.native);
|
|
420
|
-
}
|
|
421
|
-
},
|
|
422
|
-
enumerable: true,
|
|
423
|
-
configurable: true
|
|
424
|
-
});
|
|
425
|
-
Object.defineProperty(CanvasRenderingContext2D.prototype, "strokeStyle", {
|
|
426
|
-
get: function () {
|
|
427
|
-
this.log('strokeStyle');
|
|
428
|
-
switch (this.context.getStrokeStyle().getStyleType()) {
|
|
429
|
-
case 0 /* Color */:
|
|
430
|
-
var color = this.context.getStrokeStyle();
|
|
389
|
+
case org.nativescript.canvas.TNSColorStyleType.Color:
|
|
390
|
+
const color = this.context.getFillStyle();
|
|
431
391
|
return color.getColor();
|
|
432
|
-
case
|
|
433
|
-
return
|
|
434
|
-
case
|
|
435
|
-
return new
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
set: function (color) {
|
|
439
|
-
this.log('strokeStyle:', color);
|
|
440
|
-
if (color === undefined || color === null) {
|
|
441
|
-
return;
|
|
392
|
+
case org.nativescript.canvas.TNSColorStyleType.Gradient:
|
|
393
|
+
return CanvasGradient.fromNative(this.context.getFillStyle());
|
|
394
|
+
case org.nativescript.canvas.TNSColorStyleType.Pattern:
|
|
395
|
+
return new CanvasPattern(this.context.getFillStyle());
|
|
442
396
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
this.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
397
|
+
}
|
|
398
|
+
return 'black';
|
|
399
|
+
}
|
|
400
|
+
set fillStyle(color) {
|
|
401
|
+
this.log('fillStyle:', color);
|
|
402
|
+
if (color === undefined || color === null) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
this._ensureLayoutBeforeDraw();
|
|
406
|
+
if (typeof color === 'string') {
|
|
407
|
+
this.context.setFillStyle(new org.nativescript.canvas.TNSColor(color));
|
|
408
|
+
}
|
|
409
|
+
else if (color instanceof CanvasGradient) {
|
|
410
|
+
this.context.setFillStyle(color.native);
|
|
411
|
+
}
|
|
412
|
+
else if (color instanceof CanvasPattern) {
|
|
413
|
+
this.context.setFillStyle(color.native);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
get filter() {
|
|
417
|
+
this.log('get filter');
|
|
418
|
+
return this.context.getFilter();
|
|
419
|
+
}
|
|
420
|
+
set filter(value) {
|
|
421
|
+
this.log('set filter', value);
|
|
422
|
+
if (this.context) {
|
|
423
|
+
this.context.setFilter(value);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
get strokeStyle() {
|
|
427
|
+
this.log('strokeStyle');
|
|
428
|
+
switch (this.context.getStrokeStyle().getStyleType()) {
|
|
429
|
+
case 0 /* Color */:
|
|
430
|
+
const color = this.context.getStrokeStyle();
|
|
431
|
+
return color.getColor();
|
|
432
|
+
case 1 /* Gradient */:
|
|
433
|
+
return CanvasGradient.fromNative(this.context.getStrokeStyle());
|
|
434
|
+
case 2 /* Pattern */:
|
|
435
|
+
return new CanvasPattern(this.context.getStrokeStyle());
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
set strokeStyle(color) {
|
|
439
|
+
this.log('strokeStyle:', color);
|
|
440
|
+
if (color === undefined || color === null) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
this._ensureLayoutBeforeDraw();
|
|
444
|
+
if (typeof color === 'string') {
|
|
445
|
+
this.context.setStrokeStyle(new org.nativescript.canvas.TNSColor(color));
|
|
446
|
+
}
|
|
447
|
+
else if (color instanceof CanvasGradient) {
|
|
448
|
+
this.context.setStrokeStyle(color.native);
|
|
449
|
+
}
|
|
450
|
+
else if (color instanceof CanvasPattern) {
|
|
451
|
+
this.context.setStrokeStyle(color.native);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
get lineWidth() {
|
|
455
|
+
this.log('lineWidth');
|
|
456
|
+
return this.context.getLineWidth();
|
|
457
|
+
}
|
|
458
|
+
set lineWidth(width) {
|
|
459
|
+
this.log('lineWidth value:', width);
|
|
460
|
+
this._ensureLayoutBeforeDraw();
|
|
461
|
+
if (this.context) {
|
|
462
|
+
this.context.setLineWidth(width);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
addHitRegion(region) {
|
|
466
|
+
}
|
|
467
|
+
arc(x, y, radius, startAngle, endAngle, anticlockwise = false) {
|
|
476
468
|
this.log('arc value:', x, y, radius, startAngle, endAngle, anticlockwise);
|
|
477
469
|
this._ensureLayoutBeforeDraw();
|
|
478
470
|
this.context.arc(x, y, radius, startAngle, endAngle, anticlockwise);
|
|
479
|
-
}
|
|
480
|
-
|
|
471
|
+
}
|
|
472
|
+
arcTo(x1, y1, x2, y2, radius) {
|
|
481
473
|
this.log('arcTo value:', x1, y1, x2, y2, radius);
|
|
482
474
|
this._ensureLayoutBeforeDraw();
|
|
483
475
|
this.context.arcTo(x1, y1, x2, y2, radius);
|
|
484
|
-
}
|
|
485
|
-
|
|
476
|
+
}
|
|
477
|
+
beginPath() {
|
|
486
478
|
this.log('beginPath');
|
|
487
479
|
this._ensureLayoutBeforeDraw();
|
|
488
480
|
this.context.beginPath();
|
|
489
|
-
}
|
|
490
|
-
|
|
481
|
+
}
|
|
482
|
+
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
491
483
|
this.log('bezierCurveTo value:', cp1x, cp1y, cp2x, cp2y, x, y);
|
|
492
484
|
this._ensureLayoutBeforeDraw();
|
|
493
485
|
this.context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
486
|
+
}
|
|
487
|
+
clearHitRegions() {
|
|
488
|
+
}
|
|
489
|
+
clearRect(x, y, width, height) {
|
|
498
490
|
this.log('clearRect value:', x, y, width, height);
|
|
499
491
|
this._ensureLayoutBeforeDraw();
|
|
500
492
|
this.context.clearRect(x, y, width, height);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
505
|
-
args[_i] = arguments[_i];
|
|
506
|
-
}
|
|
507
|
-
this.log.apply(this, ['clip value:'].concat(args));
|
|
493
|
+
}
|
|
494
|
+
clip(...args) {
|
|
495
|
+
this.log('clip value:', ...args);
|
|
508
496
|
this._ensureLayoutBeforeDraw();
|
|
509
497
|
if (typeof args[0] === 'string') {
|
|
510
|
-
this.
|
|
498
|
+
const rule = this._fillRuleFromString(args[0]);
|
|
499
|
+
this.context.clip(rule);
|
|
511
500
|
}
|
|
512
|
-
else if (args[0] instanceof
|
|
513
|
-
this.
|
|
501
|
+
else if (args[0] instanceof Path2D && typeof args[1] === 'string') {
|
|
502
|
+
const rule = this._fillRuleFromString(args[1]);
|
|
503
|
+
this.context.clip(args[0].native, rule);
|
|
514
504
|
}
|
|
515
|
-
else if (args[0] instanceof
|
|
505
|
+
else if (args[0] instanceof Path2D) {
|
|
516
506
|
this.context.clip(args[0].native);
|
|
517
507
|
}
|
|
518
508
|
else {
|
|
519
509
|
this.context.clip();
|
|
520
510
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
511
|
+
}
|
|
512
|
+
closePath() {
|
|
523
513
|
this.log('closePath');
|
|
524
514
|
this._ensureLayoutBeforeDraw();
|
|
525
515
|
this.context.closePath();
|
|
526
|
-
}
|
|
527
|
-
|
|
516
|
+
}
|
|
517
|
+
createImageData(width, height) {
|
|
528
518
|
this.log('createImageData value:', arguments);
|
|
529
|
-
if (width instanceof
|
|
530
|
-
return
|
|
519
|
+
if (width instanceof ImageData) {
|
|
520
|
+
return ImageData.from(width);
|
|
531
521
|
}
|
|
532
522
|
else {
|
|
533
|
-
return
|
|
523
|
+
return ImageData.fromNative(this.context.createImageData(width, height));
|
|
534
524
|
}
|
|
535
|
-
}
|
|
536
|
-
|
|
525
|
+
}
|
|
526
|
+
createLinearGradient(x0, y0, x1, y1) {
|
|
537
527
|
this.log('createLinearGradient value:', x0, y0, x1, y1);
|
|
538
528
|
this._ensureLayoutBeforeDraw();
|
|
539
|
-
return
|
|
540
|
-
}
|
|
541
|
-
|
|
529
|
+
return CanvasGradient.fromNative(this.context.createLinearGradient(x0, y0, x1, y1));
|
|
530
|
+
}
|
|
531
|
+
createPattern(image, repetition) {
|
|
542
532
|
this.log('createPattern value:', image, repetition);
|
|
543
533
|
this._ensureLayoutBeforeDraw();
|
|
544
534
|
if (repetition === undefined || typeof repetition !== 'string') {
|
|
545
|
-
|
|
535
|
+
const e = new Error('The string did not match the expected pattern.');
|
|
546
536
|
e.name = 'SyntaxError';
|
|
547
537
|
throw e;
|
|
548
538
|
}
|
|
549
|
-
|
|
550
|
-
if (image instanceof
|
|
539
|
+
let img;
|
|
540
|
+
if (image instanceof ImageSource) {
|
|
551
541
|
img = image.android;
|
|
552
542
|
}
|
|
553
543
|
else if (image instanceof android.graphics.Bitmap) {
|
|
554
544
|
img = image;
|
|
555
545
|
}
|
|
556
|
-
else if (image instanceof
|
|
546
|
+
else if (image instanceof ImageAsset) {
|
|
557
547
|
img = image.native;
|
|
558
548
|
}
|
|
559
|
-
else if (image instanceof
|
|
549
|
+
else if (image instanceof Canvas) {
|
|
560
550
|
img = image.android;
|
|
561
551
|
}
|
|
562
552
|
else if (image && typeof image.tagName === 'string' && (image.tagName === 'IMG' || image.tagName === 'IMAGE')) {
|
|
563
|
-
if (image._imageSource instanceof
|
|
553
|
+
if (image._imageSource instanceof ImageSource) {
|
|
564
554
|
img = image._imageSource.android;
|
|
565
555
|
}
|
|
566
556
|
else if (image._image instanceof android.graphics.Bitmap) {
|
|
567
557
|
img = image._image;
|
|
568
558
|
}
|
|
569
|
-
else if (image._asset instanceof
|
|
559
|
+
else if (image._asset instanceof ImageAsset) {
|
|
570
560
|
img = image._asset.native;
|
|
571
561
|
}
|
|
572
562
|
else if (typeof image.src === 'string') {
|
|
573
|
-
img =
|
|
563
|
+
img = ImageSource.fromFileSync(image.src).android;
|
|
574
564
|
}
|
|
575
565
|
}
|
|
576
566
|
else if (image &&
|
|
577
567
|
typeof image.tagName === 'string' &&
|
|
578
|
-
image.tagName === 'CANVAS' && image._canvas instanceof
|
|
568
|
+
image.tagName === 'CANVAS' && image._canvas instanceof Canvas) {
|
|
579
569
|
img = image._canvas.android;
|
|
580
570
|
}
|
|
571
|
+
else if (image instanceof ImageBitmap || (image === null || image === void 0 ? void 0 : image.nativeInstance) instanceof org.nativescript.canvas.TNSImageBitmap) {
|
|
572
|
+
img = image.native;
|
|
573
|
+
}
|
|
581
574
|
if (!img) {
|
|
582
575
|
return null;
|
|
583
576
|
}
|
|
584
|
-
|
|
577
|
+
let rep;
|
|
585
578
|
switch (repetition) {
|
|
586
579
|
case 'no-repeat':
|
|
587
|
-
rep =
|
|
580
|
+
rep = PatternRepetition.NoRepeat();
|
|
588
581
|
break;
|
|
589
582
|
case 'repeat-x':
|
|
590
|
-
rep =
|
|
583
|
+
rep = PatternRepetition.RepeatX();
|
|
591
584
|
break;
|
|
592
585
|
case 'repeat-y':
|
|
593
|
-
rep =
|
|
586
|
+
rep = PatternRepetition.RepeatY();
|
|
594
587
|
break;
|
|
595
588
|
default:
|
|
596
|
-
rep =
|
|
589
|
+
rep = PatternRepetition.Repeat();
|
|
597
590
|
break;
|
|
598
591
|
}
|
|
599
|
-
return new
|
|
600
|
-
}
|
|
601
|
-
|
|
592
|
+
return new CanvasPattern(this.context.createPattern(img, rep));
|
|
593
|
+
}
|
|
594
|
+
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
602
595
|
this.log('createRadialGradient value:', x0, y0, r0, x1, y1, r1);
|
|
603
596
|
this._ensureLayoutBeforeDraw();
|
|
604
|
-
return
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
CanvasRenderingContext2D.prototype.drawImage = function () {
|
|
613
|
-
var args = [];
|
|
614
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
615
|
-
args[_i] = arguments[_i];
|
|
616
|
-
}
|
|
617
|
-
this.log.apply(this, ['drawImage value:'].concat(args));
|
|
597
|
+
return CanvasGradient.fromNative(this.context.createRadialGradient(x0, y0, r0, x1, y1, r1));
|
|
598
|
+
}
|
|
599
|
+
drawFocusIfNeeded(...args) {
|
|
600
|
+
}
|
|
601
|
+
drawImage(...args) {
|
|
602
|
+
this.log('drawImage value:', ...args);
|
|
618
603
|
this._ensureLayoutBeforeDraw();
|
|
619
|
-
|
|
620
|
-
if (image instanceof
|
|
604
|
+
let image = args[0];
|
|
605
|
+
if (image instanceof ImageAsset) {
|
|
621
606
|
image = image.native;
|
|
622
607
|
}
|
|
623
|
-
else if (image instanceof
|
|
608
|
+
else if (image instanceof ImageSource) {
|
|
624
609
|
image = image.android;
|
|
625
610
|
}
|
|
626
611
|
else if (image instanceof android.graphics.Bitmap) {
|
|
627
612
|
image = image;
|
|
628
613
|
}
|
|
629
|
-
else if (image instanceof
|
|
614
|
+
else if (image instanceof Canvas) {
|
|
630
615
|
image = image.android;
|
|
631
616
|
}
|
|
632
617
|
else if (image && typeof image.tagName === 'string' && (image.tagName === 'IMG' || image.tagName === 'IMAGE')) {
|
|
633
|
-
if (image._imageSource instanceof
|
|
618
|
+
if (image._imageSource instanceof ImageSource) {
|
|
634
619
|
image = image._imageSource.android;
|
|
635
620
|
}
|
|
636
621
|
else if (image._image instanceof android.graphics.Bitmap) {
|
|
637
622
|
image = image._image;
|
|
638
623
|
}
|
|
639
|
-
else if (image._asset instanceof
|
|
624
|
+
else if (image._asset instanceof ImageAsset) {
|
|
640
625
|
image = image._asset.native;
|
|
641
626
|
}
|
|
642
627
|
else if (typeof image.src === 'string') {
|
|
643
|
-
image =
|
|
628
|
+
image = ImageSource.fromFileSync(image.src).android;
|
|
644
629
|
}
|
|
645
630
|
}
|
|
646
631
|
else if (image &&
|
|
647
632
|
typeof image.tagName === 'string' &&
|
|
648
|
-
image.tagName === 'CANVAS' && image._canvas instanceof
|
|
633
|
+
image.tagName === 'CANVAS' && image._canvas instanceof Canvas) {
|
|
649
634
|
image = image._canvas.android;
|
|
650
635
|
}
|
|
636
|
+
else if (image instanceof ImageBitmap || (image === null || image === void 0 ? void 0 : image.nativeInstance) instanceof org.nativescript.canvas.TNSImageBitmap) {
|
|
637
|
+
image = image.native;
|
|
638
|
+
}
|
|
651
639
|
if (args.length === 3) {
|
|
652
640
|
this.context.drawImage(image, args[1], args[2]);
|
|
653
641
|
}
|
|
@@ -657,39 +645,36 @@ var CanvasRenderingContext2D = /** @class */ (function (_super) {
|
|
|
657
645
|
else if (args.length === 9) {
|
|
658
646
|
this.context.drawImage(image, args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
|
|
659
647
|
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
if (anticlockwise === void 0) { anticlockwise = false; }
|
|
648
|
+
}
|
|
649
|
+
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
663
650
|
this.log('ellipse value:', x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
664
651
|
this._ensureLayoutBeforeDraw();
|
|
665
652
|
this.context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
670
|
-
args[_i] = arguments[_i];
|
|
671
|
-
}
|
|
672
|
-
this.log.apply(this, ['fill value:'].concat(args));
|
|
653
|
+
}
|
|
654
|
+
fill(...args) {
|
|
655
|
+
this.log('fill value:', ...args);
|
|
673
656
|
this._ensureLayoutBeforeDraw();
|
|
674
657
|
if (typeof args[0] === 'string') {
|
|
675
|
-
this.
|
|
658
|
+
const rule = this._fillRuleFromString(args[0]);
|
|
659
|
+
this.context.fill(rule);
|
|
676
660
|
}
|
|
677
|
-
else if (args[0] instanceof
|
|
678
|
-
this.
|
|
661
|
+
else if (args[0] instanceof Path2D && typeof args[1] === 'string') {
|
|
662
|
+
const rule = this._fillRuleFromString(args[1]);
|
|
663
|
+
this.context.fill(args[0].native, rule);
|
|
679
664
|
}
|
|
680
|
-
else if (args[0] instanceof
|
|
665
|
+
else if (args[0] instanceof Path2D) {
|
|
681
666
|
this.context.fill(args[0].native);
|
|
682
667
|
}
|
|
683
668
|
else {
|
|
684
669
|
this.context.fill();
|
|
685
670
|
}
|
|
686
|
-
}
|
|
687
|
-
|
|
671
|
+
}
|
|
672
|
+
fillRect(x, y, width, height) {
|
|
688
673
|
this.log('fillRect value:', x, y, width, height);
|
|
689
674
|
this._ensureLayoutBeforeDraw();
|
|
690
675
|
this.context.fillRect(x, y, width, height);
|
|
691
|
-
}
|
|
692
|
-
|
|
676
|
+
}
|
|
677
|
+
fillText(text, x, y, maxWidth) {
|
|
693
678
|
this.log('fillText value:', text, x, y, maxWidth);
|
|
694
679
|
this._ensureLayoutBeforeDraw();
|
|
695
680
|
if (typeof maxWidth === 'number') {
|
|
@@ -698,23 +683,19 @@ var CanvasRenderingContext2D = /** @class */ (function (_super) {
|
|
|
698
683
|
else {
|
|
699
684
|
this.context.fillText(text, x, y);
|
|
700
685
|
}
|
|
701
|
-
}
|
|
702
|
-
|
|
686
|
+
}
|
|
687
|
+
getImageData(sx, sy, sw, sh) {
|
|
703
688
|
this.log('getImageData value:', sx, sy, sw, sh);
|
|
704
689
|
this._ensureLayoutBeforeDraw();
|
|
705
|
-
return
|
|
706
|
-
}
|
|
707
|
-
|
|
690
|
+
return ImageData.fromNative(this.context.getImageData(sx, sy, sw, sh));
|
|
691
|
+
}
|
|
692
|
+
getLineDash() {
|
|
708
693
|
this.log('getLineDash');
|
|
709
694
|
this._ensureLayoutBeforeDraw();
|
|
710
695
|
return this.context.getLineDash();
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
715
|
-
args[_i] = arguments[_i];
|
|
716
|
-
}
|
|
717
|
-
this.log.apply(this, ['isPointInPath value:'].concat(args));
|
|
696
|
+
}
|
|
697
|
+
isPointInPath(...args) {
|
|
698
|
+
this.log('isPointInPath value:', ...args);
|
|
718
699
|
this._ensureLayoutBeforeDraw();
|
|
719
700
|
if (args.length === 2) {
|
|
720
701
|
return this.context.isPointInPath(args[0], args[1]);
|
|
@@ -722,112 +703,101 @@ var CanvasRenderingContext2D = /** @class */ (function (_super) {
|
|
|
722
703
|
else if (args.length === 3) {
|
|
723
704
|
return this.context.isPointInPath(args[0], args[1], args[2]);
|
|
724
705
|
}
|
|
725
|
-
else if (args.length === 4 && args[0] instanceof
|
|
706
|
+
else if (args.length === 4 && args[0] instanceof Path2D) {
|
|
726
707
|
return this.context.isPointInPath(args[0].native, args[1], args[2], args[3]);
|
|
727
708
|
}
|
|
728
709
|
return false;
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
733
|
-
args[_i] = arguments[_i];
|
|
734
|
-
}
|
|
735
|
-
this.log.apply(this, ['isPointInStroke value:'].concat(args));
|
|
710
|
+
}
|
|
711
|
+
isPointInStroke(...args) {
|
|
712
|
+
this.log('isPointInStroke value:', ...args);
|
|
736
713
|
this._ensureLayoutBeforeDraw();
|
|
737
714
|
if (args.length === 2) {
|
|
738
715
|
return this.context.isPointInStroke(args[0], args[1]);
|
|
739
716
|
}
|
|
740
|
-
else if (args.length === 3 && args[0] instanceof
|
|
717
|
+
else if (args.length === 3 && args[0] instanceof Path2D) {
|
|
741
718
|
return this.context.isPointInStroke(args[0].native, args[1], args[2]);
|
|
742
719
|
}
|
|
743
720
|
return false;
|
|
744
|
-
}
|
|
745
|
-
|
|
721
|
+
}
|
|
722
|
+
lineTo(x, y) {
|
|
746
723
|
this.log('lineTo value:', x, y);
|
|
747
724
|
this._ensureLayoutBeforeDraw();
|
|
748
725
|
this.context.lineTo(x, y);
|
|
749
|
-
}
|
|
750
|
-
|
|
726
|
+
}
|
|
727
|
+
measureText(text) {
|
|
751
728
|
this.log('measureText value:', text);
|
|
752
729
|
this._ensureLayoutBeforeDraw();
|
|
753
|
-
return new
|
|
754
|
-
}
|
|
755
|
-
|
|
730
|
+
return new TextMetrics(this.context.measureText(text));
|
|
731
|
+
}
|
|
732
|
+
moveTo(x, y) {
|
|
756
733
|
this.log('moveTo value:', x, y);
|
|
757
734
|
this._ensureLayoutBeforeDraw();
|
|
758
735
|
this.context.moveTo(x, y);
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
763
|
-
args[_i] = arguments[_i];
|
|
764
|
-
}
|
|
765
|
-
this.log.apply(this, ['putImageData value:'].concat(args));
|
|
736
|
+
}
|
|
737
|
+
putImageData(...args) {
|
|
738
|
+
this.log('putImageData value:', ...args);
|
|
766
739
|
this._ensureLayoutBeforeDraw();
|
|
767
740
|
if (!args) {
|
|
768
741
|
return;
|
|
769
742
|
}
|
|
770
|
-
|
|
771
|
-
// Would be nice not to update the native backing array each time ... but since buffers don't use pointers ... we are here 😅
|
|
743
|
+
let data = args[0];
|
|
772
744
|
if (args.length === 3) {
|
|
773
|
-
//data.native.updateData(Array.from(data.data));
|
|
774
745
|
this.context.putImageData(data.native, args[1], args[2]);
|
|
775
746
|
}
|
|
776
747
|
else if (args.length === 7) {
|
|
777
|
-
// data.native.updateData(Array.from(data.data));
|
|
778
748
|
this.context.putImageData(data.native, args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
779
749
|
}
|
|
780
|
-
}
|
|
781
|
-
|
|
750
|
+
}
|
|
751
|
+
quadraticCurveTo(cpx, cpy, x, y) {
|
|
782
752
|
this.log('quadraticCurveTo value:', cpx, cpy, x, y);
|
|
783
753
|
this._ensureLayoutBeforeDraw();
|
|
784
754
|
this.context.quadraticCurveTo(cpx, cpy, x, y);
|
|
785
|
-
}
|
|
786
|
-
|
|
755
|
+
}
|
|
756
|
+
rect(x, y, width, height) {
|
|
787
757
|
this.log('rect value:', x, y, width, height);
|
|
788
758
|
this._ensureLayoutBeforeDraw();
|
|
789
759
|
this.context.rect(x, y, width, height);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
|
|
760
|
+
}
|
|
761
|
+
removeHitRegion(id) {
|
|
762
|
+
}
|
|
763
|
+
resetTransform() {
|
|
794
764
|
this.log('resetTransform value:');
|
|
795
765
|
this._ensureLayoutBeforeDraw();
|
|
796
766
|
this.context.resetTransform();
|
|
797
|
-
}
|
|
798
|
-
|
|
767
|
+
}
|
|
768
|
+
restore() {
|
|
799
769
|
this.log('restore');
|
|
800
770
|
this._ensureLayoutBeforeDraw();
|
|
801
771
|
this.context.restore();
|
|
802
|
-
}
|
|
803
|
-
|
|
772
|
+
}
|
|
773
|
+
rotate(angle) {
|
|
804
774
|
this.log('rotate value:', angle);
|
|
805
775
|
this._ensureLayoutBeforeDraw();
|
|
806
776
|
this.context.rotate(angle);
|
|
807
|
-
}
|
|
808
|
-
|
|
777
|
+
}
|
|
778
|
+
save() {
|
|
809
779
|
this.log('save');
|
|
810
780
|
this._ensureLayoutBeforeDraw();
|
|
811
781
|
this.context.save();
|
|
812
|
-
}
|
|
813
|
-
|
|
782
|
+
}
|
|
783
|
+
scale(x, y) {
|
|
814
784
|
this.log('scale value:', x, y);
|
|
815
785
|
this._ensureLayoutBeforeDraw();
|
|
816
786
|
this.context.scale(x, y);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
}
|
|
820
|
-
|
|
787
|
+
}
|
|
788
|
+
scrollPathIntoView(path) {
|
|
789
|
+
}
|
|
790
|
+
setLineDash(segments) {
|
|
821
791
|
this.log('setLineDash value:', segments);
|
|
822
792
|
this._ensureLayoutBeforeDraw();
|
|
823
793
|
this.context.setLineDash(segments);
|
|
824
|
-
}
|
|
825
|
-
|
|
794
|
+
}
|
|
795
|
+
setTransform(a, b, c, d, e, f) {
|
|
826
796
|
this.log('setTransform value:', a, b, c, d, e, f);
|
|
827
797
|
this._ensureLayoutBeforeDraw();
|
|
828
798
|
this.context.setTransform(a, b, c, d, e, f);
|
|
829
|
-
}
|
|
830
|
-
|
|
799
|
+
}
|
|
800
|
+
stroke(path) {
|
|
831
801
|
this.log('stroke value:', path);
|
|
832
802
|
this._ensureLayoutBeforeDraw();
|
|
833
803
|
if (path) {
|
|
@@ -836,13 +806,13 @@ var CanvasRenderingContext2D = /** @class */ (function (_super) {
|
|
|
836
806
|
else {
|
|
837
807
|
this.context.stroke();
|
|
838
808
|
}
|
|
839
|
-
}
|
|
840
|
-
|
|
809
|
+
}
|
|
810
|
+
strokeRect(x, y, width, height) {
|
|
841
811
|
this.log('strokeRect value:', x, y, width, height);
|
|
842
812
|
this._ensureLayoutBeforeDraw();
|
|
843
813
|
this.context.strokeRect(x, y, width, height);
|
|
844
|
-
}
|
|
845
|
-
|
|
814
|
+
}
|
|
815
|
+
strokeText(text, x, y, maxWidth) {
|
|
846
816
|
this.log('strokeText value:', text, x, y, maxWidth);
|
|
847
817
|
this._ensureLayoutBeforeDraw();
|
|
848
818
|
if (typeof maxWidth === 'number') {
|
|
@@ -851,35 +821,29 @@ var CanvasRenderingContext2D = /** @class */ (function (_super) {
|
|
|
851
821
|
else {
|
|
852
822
|
this.context.strokeText(text, x, y);
|
|
853
823
|
}
|
|
854
|
-
}
|
|
855
|
-
|
|
824
|
+
}
|
|
825
|
+
transform(a, b, c, d, e, f) {
|
|
856
826
|
this.log('transform value:', a, b, c, d, e, f);
|
|
857
827
|
this._ensureLayoutBeforeDraw();
|
|
858
828
|
this.context.transform(a, b, c, d, e, f);
|
|
859
|
-
}
|
|
860
|
-
|
|
829
|
+
}
|
|
830
|
+
translate(x, y) {
|
|
861
831
|
this.log('translate value:', x, y);
|
|
862
832
|
this._ensureLayoutBeforeDraw();
|
|
863
833
|
this.context.translate(x, y);
|
|
864
|
-
}
|
|
865
|
-
|
|
834
|
+
}
|
|
835
|
+
_ensureLayoutBeforeDraw() {
|
|
866
836
|
if (this.canvas) {
|
|
867
837
|
this.canvas._layoutNative();
|
|
868
838
|
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
var args = [];
|
|
872
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
873
|
-
args[_i - 1] = arguments[_i];
|
|
874
|
-
}
|
|
839
|
+
}
|
|
840
|
+
log(message, ...args) {
|
|
875
841
|
if (!CanvasRenderingContext2D.isDebug) {
|
|
876
842
|
return;
|
|
877
843
|
}
|
|
878
844
|
console.log(message, args);
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}(common_1.CanvasRenderingContext2DBase));
|
|
884
|
-
exports.CanvasRenderingContext2D = CanvasRenderingContext2D;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
CanvasRenderingContext2D.isDebug = false;
|
|
848
|
+
CanvasRenderingContext2D.colorCache = {};
|
|
885
849
|
//# sourceMappingURL=index.android.js.map
|