@nativescript/canvas 2.0.0-alpha.20 → 2.0.0-alpha.21
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 +2 -0
- package/Canvas/common.js +6 -0
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +0 -2
- package/Canvas/index.android.js +8 -22
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +7 -0
- package/Canvas/index.ios.d.ts +0 -2
- package/Canvas/index.ios.js +7 -26
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasGradient/index.d.ts +1 -3
- package/Canvas2D/CanvasGradient/index.js +1 -10
- package/Canvas2D/CanvasGradient/index.js.map +1 -1
- package/Canvas2D/CanvasPattern/index.d.ts +1 -3
- package/Canvas2D/CanvasPattern/index.js +1 -10
- package/Canvas2D/CanvasPattern/index.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -2
- package/Canvas2D/CanvasRenderingContext2D/index.js +120 -138
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.js +3 -3
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/ImageData/index.js +5 -5
- package/Canvas2D/ImageData/index.js.map +1 -1
- package/Canvas2D/Path2D/index.d.ts +0 -2
- package/Canvas2D/Path2D/index.js +34 -39
- package/Canvas2D/Path2D/index.js.map +1 -1
- package/ImageAsset/index.d.ts +2 -2
- package/ImageAsset/index.js +33 -37
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.d.ts +0 -2
- package/ImageBitmap/index.js +23 -29
- package/ImageBitmap/index.js.map +1 -1
- package/SVG/SVG.js +1 -1
- package/TextDecoder/index.d.ts +0 -2
- package/TextDecoder/index.js +3 -12
- package/TextDecoder/index.js.map +1 -1
- package/TextEncoder/index.d.ts +0 -2
- package/TextEncoder/index.js +4 -13
- package/TextEncoder/index.js.map +1 -1
- package/WebGL/WebGLExtensions/index.d.ts +0 -9
- package/WebGL/WebGLExtensions/index.js +17 -74
- package/WebGL/WebGLExtensions/index.js.map +1 -1
- package/WebGL/WebGLRenderingContext/common.d.ts +0 -2
- package/WebGL/WebGLRenderingContext/common.js +0 -10
- package/WebGL/WebGLRenderingContext/common.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.js +159 -298
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +107 -195
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/angular/esm2020/index.mjs +5 -5
- package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
- package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/android/include.gradle +15 -0
- 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 +87 -57
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +10 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +142 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2589 -110
- 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/arm64-apple-ios.abi.json +1174 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -2
- 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 +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 +174 -114
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +10 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +142 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2589 -110
- 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/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1174 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -2
- 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 +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1174 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -2
- 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 +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +42 -31
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/Podfile +3 -0
- package/platforms/ios/build.xcconfig +3 -3
- package/platforms/ios/src/CanvasModule.h +0 -2
- package/platforms/ios/src/CanvasModule.mm +4 -4
- package/platforms/ios/src/NSOperationQueueWrapper.h +11 -0
- package/platforms/ios/src/NSOperationQueueWrapper.mm +74 -0
- package/platforms/ios/src/cpp/Caches.cpp +35 -0
- package/platforms/ios/src/cpp/Caches.h +186 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1582 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -34
- package/platforms/ios/src/cpp/Common.h +30 -0
- package/platforms/ios/src/cpp/ConcurrentMap.h +54 -0
- package/platforms/ios/src/cpp/Helpers.h +304 -38
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +802 -0
- package/platforms/ios/src/cpp/ImageAssetImpl.h +44 -12
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +189 -0
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +22 -16
- package/platforms/ios/src/cpp/JSICallback.h +61 -5
- package/platforms/ios/src/cpp/JSIReadFileCallback.h +86 -6
- package/platforms/ios/src/cpp/JSIRuntime.cpp +21 -0
- package/platforms/ios/src/cpp/JSIRuntime.h +7 -0
- package/platforms/ios/src/cpp/OneByteStringResource.cpp +25 -0
- package/platforms/ios/src/cpp/OneByteStringResource.h +21 -0
- package/platforms/ios/src/cpp/RafImpl.cpp +8 -0
- package/platforms/ios/src/cpp/RafImpl.h +11 -8
- package/platforms/ios/src/cpp/TextDecoderImpl.cpp +188 -0
- package/platforms/ios/src/cpp/TextDecoderImpl.h +20 -14
- package/platforms/ios/src/cpp/TextEncoderImpl.cpp +139 -0
- package/platforms/ios/src/cpp/TextEncoderImpl.h +20 -11
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.cpp +71 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +27 -13
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +89 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +26 -13
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +2402 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +264 -21
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +203 -0
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +26 -12
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +800 -0
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +172 -13
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +449 -0
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +41 -12
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.cpp +253 -0
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +50 -12
- package/platforms/ios/src/cpp/gl.h +57 -7
- package/platforms/ios/src/cpp/gl3stub.c +425 -0
- package/platforms/ios/src/cpp/gl3stub.h +665 -0
- package/platforms/ios/src/cpp/gles3jni.h +37 -0
- package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.cpp +93 -0
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +33 -13
- package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +41 -6
- package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +46 -10
- package/platforms/ios/src/cpp/webgl/WebGLProgram.h +40 -5
- package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +40 -6
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +6691 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +261 -390
- package/platforms/ios/src/cpp/webgl/{WebGLRenderingContextBase.mm → WebGLRenderingContextBase.cpp} +17 -16
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +15 -36
- package/platforms/ios/src/cpp/webgl/WebGLShader.h +40 -6
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.cpp +50 -0
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +66 -11
- package/platforms/ios/src/cpp/webgl/WebGLTexture.h +40 -6
- package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +44 -8
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +126 -0
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +25 -12
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.cpp +35 -0
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +25 -5
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.cpp +41 -0
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +25 -5
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +323 -0
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +47 -13
- package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +49 -6
- package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +37 -15
- package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +47 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +49 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +36 -15
- package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +44 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +38 -15
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +37 -16
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +41 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +40 -16
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.cpp +102 -0
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +69 -14
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +51 -8
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +49 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +49 -8
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +76 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +57 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +53 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +59 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +46 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.cpp +43 -0
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +126 -14
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.cpp +32 -0
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +61 -12
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +4517 -0
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +139 -343
- package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +40 -4
- package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +42 -3
- package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +44 -11
- package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +42 -4
- package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +43 -4
- package/platforms/ios/src/module.modulemap +1 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.mm +0 -1105
- package/platforms/ios/src/cpp/ImageAssetImpl.mm +0 -417
- package/platforms/ios/src/cpp/ImageBitmapImpl.mm +0 -126
- package/platforms/ios/src/cpp/RafImpl.mm +0 -10
- package/platforms/ios/src/cpp/TextDecoderImpl.mm +0 -97
- package/platforms/ios/src/cpp/TextEncoderImpl.mm +0 -60
- package/platforms/ios/src/cpp/VecMutableBuffer.h +0 -46
- package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.cc +0 -6156
- package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.h +0 -2867
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.mm +0 -42
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.mm +0 -49
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.mm +0 -1972
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.mm +0 -68
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.mm +0 -149
- package/platforms/ios/src/cpp/canvas2d/Path2D.mm +0 -335
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.mm +0 -68
- package/platforms/ios/src/cpp/rust/cxx.cc +0 -793
- package/platforms/ios/src/cpp/rust/cxx.h +0 -1111
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.mm +0 -39
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.mm +0 -5958
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.mm +0 -40
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.mm +0 -108
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.mm +0 -28
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.mm +0 -42
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.mm +0 -295
- package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.mm +0 -40
- package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.mm +0 -37
- package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.mm +0 -28
- package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.mm +0 -31
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.mm +0 -28
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.mm +0 -127
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.mm +0 -45
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.mm +0 -45
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.mm +0 -31
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.mm +0 -70
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.mm +0 -47
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.mm +0 -46
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.mm +0 -49
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.mm +0 -30
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.mm +0 -177
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.mm +0 -64
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.mm +0 -4551
- /package/platforms/ios/src/cpp/{OnRafCallback.mm → OnRafCallback.cpp} +0 -0
|
@@ -4,26 +4,185 @@
|
|
|
4
4
|
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
|
-
#include "rust/cxx.h"
|
|
8
|
-
#include "canvas-cxx/src/lib.rs.h"
|
|
9
|
-
#import <NativeScript/JSIRuntime.h>
|
|
10
7
|
#include <vector>
|
|
8
|
+
#include "Helpers.h"
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
using namespace org::nativescript::canvas;
|
|
14
|
-
|
|
15
|
-
class JSI_EXPORT MatrixImpl : public jsi::HostObject {
|
|
10
|
+
class MatrixImpl {
|
|
16
11
|
public:
|
|
17
|
-
MatrixImpl(
|
|
12
|
+
MatrixImpl(Matrix* matrix);
|
|
13
|
+
~MatrixImpl(){
|
|
14
|
+
canvas_native_matrix_destroy(this->GetMatrix());
|
|
15
|
+
this->matrix_ = nullptr;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Matrix* GetMatrix();
|
|
19
|
+
|
|
20
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
21
|
+
|
|
22
|
+
static MatrixImpl *GetPointer(v8::Local<v8::Object> object);
|
|
23
|
+
|
|
24
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
25
|
+
|
|
26
|
+
static void Ctor(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
27
|
+
|
|
28
|
+
static void GetA(v8::Local<v8::String> property,
|
|
29
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
30
|
+
|
|
31
|
+
static void SetA(v8::Local<v8::String> property,
|
|
32
|
+
v8::Local<v8::Value> value,
|
|
33
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
static void GetB(v8::Local<v8::String> property,
|
|
37
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
38
|
+
|
|
39
|
+
static void SetB(v8::Local<v8::String> property,
|
|
40
|
+
v8::Local<v8::Value> value,
|
|
41
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
42
|
+
|
|
43
|
+
static void GetC(v8::Local<v8::String> property,
|
|
44
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
45
|
+
|
|
46
|
+
static void SetC(v8::Local<v8::String> property,
|
|
47
|
+
v8::Local<v8::Value> value,
|
|
48
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
49
|
+
|
|
50
|
+
static void GetD(v8::Local<v8::String> property,
|
|
51
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
52
|
+
|
|
53
|
+
static void SetD(v8::Local<v8::String> property,
|
|
54
|
+
v8::Local<v8::Value> value,
|
|
55
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
56
|
+
|
|
57
|
+
static void GetE(v8::Local<v8::String> property,
|
|
58
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
59
|
+
|
|
60
|
+
static void SetE(v8::Local<v8::String> property,
|
|
61
|
+
v8::Local<v8::Value> value,
|
|
62
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
63
|
+
|
|
64
|
+
static void GetF(v8::Local<v8::String> property,
|
|
65
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
66
|
+
|
|
67
|
+
static void SetF(v8::Local<v8::String> property,
|
|
68
|
+
v8::Local<v8::Value> value,
|
|
69
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
static void GetM11(v8::Local<v8::String> property,
|
|
73
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
74
|
+
|
|
75
|
+
static void SetM11(v8::Local<v8::String> property,
|
|
76
|
+
v8::Local<v8::Value> value,
|
|
77
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
static void GetM12(v8::Local<v8::String> property,
|
|
81
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
82
|
+
|
|
83
|
+
static void SetM12(v8::Local<v8::String> property,
|
|
84
|
+
v8::Local<v8::Value> value,
|
|
85
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
static void GetM13(v8::Local<v8::String> property,
|
|
89
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
90
|
+
|
|
91
|
+
static void SetM13(v8::Local<v8::String> property,
|
|
92
|
+
v8::Local<v8::Value> value,
|
|
93
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
94
|
+
|
|
95
|
+
static void GetM14(v8::Local<v8::String> property,
|
|
96
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
97
|
+
|
|
98
|
+
static void SetM14(v8::Local<v8::String> property,
|
|
99
|
+
v8::Local<v8::Value> value,
|
|
100
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
101
|
+
|
|
102
|
+
static void GetM21(v8::Local<v8::String> property,
|
|
103
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
104
|
+
|
|
105
|
+
static void SetM21(v8::Local<v8::String> property,
|
|
106
|
+
v8::Local<v8::Value> value,
|
|
107
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
108
|
+
|
|
109
|
+
static void GetM22(v8::Local<v8::String> property,
|
|
110
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
111
|
+
|
|
112
|
+
static void SetM22(v8::Local<v8::String> property,
|
|
113
|
+
v8::Local<v8::Value> value,
|
|
114
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
115
|
+
|
|
116
|
+
static void GetM23(v8::Local<v8::String> property,
|
|
117
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
118
|
+
|
|
119
|
+
static void SetM23(v8::Local<v8::String> property,
|
|
120
|
+
v8::Local<v8::Value> value,
|
|
121
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
122
|
+
|
|
123
|
+
static void GetM24(v8::Local<v8::String> property,
|
|
124
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
125
|
+
|
|
126
|
+
static void SetM24(v8::Local<v8::String> property,
|
|
127
|
+
v8::Local<v8::Value> value,
|
|
128
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
129
|
+
|
|
130
|
+
static void GetM31(v8::Local<v8::String> property,
|
|
131
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
132
|
+
|
|
133
|
+
static void SetM31(v8::Local<v8::String> property,
|
|
134
|
+
v8::Local<v8::Value> value,
|
|
135
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
136
|
+
|
|
137
|
+
static void GetM32(v8::Local<v8::String> property,
|
|
138
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
139
|
+
|
|
140
|
+
static void SetM32(v8::Local<v8::String> property,
|
|
141
|
+
v8::Local<v8::Value> value,
|
|
142
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
143
|
+
|
|
144
|
+
static void GetM33(v8::Local<v8::String> property,
|
|
145
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
146
|
+
|
|
147
|
+
static void SetM33(v8::Local<v8::String> property,
|
|
148
|
+
v8::Local<v8::Value> value,
|
|
149
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
150
|
+
|
|
151
|
+
static void GetM34(v8::Local<v8::String> property,
|
|
152
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
153
|
+
|
|
154
|
+
static void SetM34(v8::Local<v8::String> property,
|
|
155
|
+
v8::Local<v8::Value> value,
|
|
156
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
157
|
+
|
|
158
|
+
static void GetM41(v8::Local<v8::String> property,
|
|
159
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
160
|
+
|
|
161
|
+
static void SetM41(v8::Local<v8::String> property,
|
|
162
|
+
v8::Local<v8::Value> value,
|
|
163
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
164
|
+
|
|
165
|
+
static void GetM42(v8::Local<v8::String> property,
|
|
166
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
167
|
+
|
|
168
|
+
static void SetM42(v8::Local<v8::String> property,
|
|
169
|
+
v8::Local<v8::Value> value,
|
|
170
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
18
171
|
|
|
19
|
-
|
|
172
|
+
static void GetM43(v8::Local<v8::String> property,
|
|
173
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
20
174
|
|
|
21
|
-
void
|
|
175
|
+
static void SetM43(v8::Local<v8::String> property,
|
|
176
|
+
v8::Local<v8::Value> value,
|
|
177
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
22
178
|
|
|
23
|
-
|
|
179
|
+
static void GetM44(v8::Local<v8::String> property,
|
|
180
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
24
181
|
|
|
25
|
-
|
|
182
|
+
static void SetM44(v8::Local<v8::String> property,
|
|
183
|
+
v8::Local<v8::Value> value,
|
|
184
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
26
185
|
|
|
27
186
|
private:
|
|
28
|
-
|
|
187
|
+
Matrix* matrix_;
|
|
29
188
|
};
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 28/03/2022.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "Path2D.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
#include "Helpers.h"
|
|
8
|
+
#include "OneByteStringResource.h"
|
|
9
|
+
|
|
10
|
+
Path2D::Path2D(Path* path)
|
|
11
|
+
: path_(path) {}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
void Path2D::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
15
|
+
v8::Locker locker(isolate);
|
|
16
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
17
|
+
v8::HandleScope handle_scope(isolate);
|
|
18
|
+
|
|
19
|
+
auto ctor = GetCtor(isolate);
|
|
20
|
+
auto context = isolate->GetCurrentContext();
|
|
21
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
22
|
+
|
|
23
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "Path2D"), func);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Path2D *Path2D::GetPointer(const v8::Local<v8::Object> &object) {
|
|
27
|
+
auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
|
|
28
|
+
if (ptr == nullptr) {
|
|
29
|
+
return nullptr;
|
|
30
|
+
}
|
|
31
|
+
return static_cast<Path2D *>(ptr);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
v8::Local<v8::FunctionTemplate> Path2D::GetCtor(v8::Isolate *isolate) {
|
|
35
|
+
auto cache = Caches::Get(isolate);
|
|
36
|
+
auto ctor = cache->Path2DTmpl.get();
|
|
37
|
+
if (ctor != nullptr) {
|
|
38
|
+
return ctor->Get(isolate);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate, Ctor);
|
|
42
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
43
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "Path2D"));
|
|
44
|
+
|
|
45
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
46
|
+
|
|
47
|
+
tmpl->SetInternalFieldCount(1);
|
|
48
|
+
tmpl->Set(
|
|
49
|
+
ConvertToV8String(isolate, "addPath"),
|
|
50
|
+
v8::FunctionTemplate::New(isolate, &AddPath));
|
|
51
|
+
|
|
52
|
+
tmpl->Set(
|
|
53
|
+
ConvertToV8String(isolate, "arc"),
|
|
54
|
+
v8::FunctionTemplate::New(isolate, &Arc));
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
tmpl->Set(
|
|
58
|
+
ConvertToV8String(isolate, "arcTo"),
|
|
59
|
+
v8::FunctionTemplate::New(isolate, &ArcTo));
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
tmpl->Set(
|
|
63
|
+
ConvertToV8String(isolate, "bezierCurveTo"),
|
|
64
|
+
v8::FunctionTemplate::New(isolate, &BezierCurveTo));
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
tmpl->Set(
|
|
68
|
+
ConvertToV8String(isolate, "closePath"),
|
|
69
|
+
v8::FunctionTemplate::New(isolate, &ClosePath));
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
tmpl->Set(
|
|
73
|
+
ConvertToV8String(isolate, "ellipse"),
|
|
74
|
+
v8::FunctionTemplate::New(isolate, &Ellipse));
|
|
75
|
+
|
|
76
|
+
tmpl->Set(
|
|
77
|
+
ConvertToV8String(isolate, "lineTo"),
|
|
78
|
+
v8::FunctionTemplate::New(isolate, &LineTo));
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
tmpl->Set(
|
|
82
|
+
ConvertToV8String(isolate, "moveTo"),
|
|
83
|
+
v8::FunctionTemplate::New(isolate, &MoveTo));
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
tmpl->Set(
|
|
87
|
+
ConvertToV8String(isolate, "quadraticCurveTo"),
|
|
88
|
+
v8::FunctionTemplate::New(isolate, &QuadraticCurveTo));
|
|
89
|
+
|
|
90
|
+
tmpl->Set(
|
|
91
|
+
ConvertToV8String(isolate, "rect"),
|
|
92
|
+
v8::FunctionTemplate::New(isolate, &Rect));
|
|
93
|
+
|
|
94
|
+
tmpl->Set(
|
|
95
|
+
ConvertToV8String(isolate, "roundRect"),
|
|
96
|
+
v8::FunctionTemplate::New(isolate, &RoundRect));
|
|
97
|
+
|
|
98
|
+
tmpl->Set(
|
|
99
|
+
ConvertToV8String(isolate, "__toSVG"),
|
|
100
|
+
v8::FunctionTemplate::New(isolate, &__toSVG));
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
cache->Path2DTmpl =
|
|
104
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
105
|
+
return ctorTmpl;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
109
|
+
auto count = args.Length();
|
|
110
|
+
auto value = args[0];
|
|
111
|
+
auto isolate = args.GetIsolate();
|
|
112
|
+
|
|
113
|
+
auto ret = args.This();
|
|
114
|
+
|
|
115
|
+
SetNativeType(isolate, ret, NativeType::Path2D);
|
|
116
|
+
|
|
117
|
+
if (count > 0) {
|
|
118
|
+
if (value->IsString()) {
|
|
119
|
+
auto d = ConvertFromV8String(isolate, value);
|
|
120
|
+
auto path = canvas_native_path_create_with_string(d.c_str());
|
|
121
|
+
auto object = new Path2D(std::move(path));
|
|
122
|
+
|
|
123
|
+
auto ext = v8::External::New(isolate, object);
|
|
124
|
+
|
|
125
|
+
ret->SetInternalField(0, ext);
|
|
126
|
+
|
|
127
|
+
args.GetReturnValue().Set(ret);
|
|
128
|
+
|
|
129
|
+
return;
|
|
130
|
+
|
|
131
|
+
} else if (value->IsObject()) {
|
|
132
|
+
auto path_to_copy = GetPointer(value.As<v8::Object>());
|
|
133
|
+
if (path_to_copy != nullptr) {
|
|
134
|
+
auto path = canvas_native_path_create_with_path(
|
|
135
|
+
path_to_copy->GetPath());
|
|
136
|
+
auto object = new Path2D(path);
|
|
137
|
+
|
|
138
|
+
auto ext = v8::External::New(isolate, object);
|
|
139
|
+
|
|
140
|
+
ret->SetInternalField(0, ext);
|
|
141
|
+
|
|
142
|
+
args.GetReturnValue().Set(ret);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
auto path = new Path2D(canvas_native_path_create());
|
|
148
|
+
|
|
149
|
+
auto ext = v8::External::New(isolate, path);
|
|
150
|
+
|
|
151
|
+
ret->SetInternalField(0, ext);
|
|
152
|
+
|
|
153
|
+
args.GetReturnValue().Set(ret);
|
|
154
|
+
return;
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
args.GetReturnValue().SetUndefined();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void Path2D::AddPath(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
162
|
+
Path2D *ptr = GetPointer(args.This());
|
|
163
|
+
if (ptr == nullptr) {
|
|
164
|
+
args.GetReturnValue().SetUndefined();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
auto value = args[0];
|
|
169
|
+
if (value->IsObject()) {
|
|
170
|
+
auto object = GetPointer(value.As<v8::Object>());
|
|
171
|
+
if (object != nullptr) {
|
|
172
|
+
canvas_native_path_add_path(
|
|
173
|
+
ptr->GetPath(),
|
|
174
|
+
object->GetPath());
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
void Path2D::Arc(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
180
|
+
Path2D *ptr = GetPointer(args.This());
|
|
181
|
+
if (ptr == nullptr) {
|
|
182
|
+
args.GetReturnValue().SetUndefined();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
auto isolate = args.GetIsolate();
|
|
187
|
+
auto context = isolate->GetCurrentContext();
|
|
188
|
+
auto anti_clockwise = false;
|
|
189
|
+
if (args.Length() == 6) {
|
|
190
|
+
anti_clockwise = args[5]->BooleanValue(isolate);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
canvas_native_path_arc(
|
|
194
|
+
ptr->GetPath(),
|
|
195
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
196
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()),
|
|
197
|
+
static_cast<float>(args[2]->NumberValue(context).ToChecked()),
|
|
198
|
+
static_cast<float>(args[3]->NumberValue(context).ToChecked()),
|
|
199
|
+
static_cast<float>(args[4]->NumberValue(context).ToChecked()),
|
|
200
|
+
anti_clockwise
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
args.GetReturnValue().SetUndefined();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
void Path2D::ArcTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
208
|
+
Path2D *ptr = GetPointer(args.This());
|
|
209
|
+
if (ptr == nullptr) {
|
|
210
|
+
args.GetReturnValue().SetUndefined();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
auto isolate = args.GetIsolate();
|
|
215
|
+
auto context = isolate->GetCurrentContext();
|
|
216
|
+
|
|
217
|
+
canvas_native_path_arc_to(
|
|
218
|
+
ptr->GetPath(),
|
|
219
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
220
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()),
|
|
221
|
+
static_cast<float>(args[2]->NumberValue(context).ToChecked()),
|
|
222
|
+
static_cast<float>(args[3]->NumberValue(context).ToChecked()),
|
|
223
|
+
static_cast<float>(args[4]->NumberValue(context).ToChecked())
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
args.GetReturnValue().SetUndefined();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
void Path2D::BezierCurveTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
231
|
+
Path2D *ptr = GetPointer(args.This());
|
|
232
|
+
if (ptr == nullptr) {
|
|
233
|
+
args.GetReturnValue().SetUndefined();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
auto isolate = args.GetIsolate();
|
|
238
|
+
auto context = isolate->GetCurrentContext();
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
canvas_native_path_bezier_curve_to(
|
|
242
|
+
ptr->GetPath(),
|
|
243
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
244
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()),
|
|
245
|
+
static_cast<float>(args[2]->NumberValue(context).ToChecked()),
|
|
246
|
+
static_cast<float>(args[3]->NumberValue(context).ToChecked()),
|
|
247
|
+
static_cast<float>(args[4]->NumberValue(context).ToChecked()),
|
|
248
|
+
static_cast<float>(args[5]->NumberValue(context).ToChecked())
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
args.GetReturnValue().SetUndefined();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
void Path2D::ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
255
|
+
Path2D *ptr = GetPointer(args.This());
|
|
256
|
+
if (ptr == nullptr) {
|
|
257
|
+
args.GetReturnValue().SetUndefined();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
canvas_native_path_close_path(ptr->GetPath());
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
void Path2D::Ellipse(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
265
|
+
Path2D *ptr = GetPointer(args.This());
|
|
266
|
+
if (ptr == nullptr) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
auto isolate = args.GetIsolate();
|
|
271
|
+
auto context = isolate->GetCurrentContext();
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
auto anti_clockwise = false;
|
|
275
|
+
if (args.Length() > 7) {
|
|
276
|
+
anti_clockwise = args[7]->BooleanValue(isolate);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
canvas_native_path_ellipse(
|
|
280
|
+
ptr->GetPath(),
|
|
281
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
282
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()),
|
|
283
|
+
static_cast<float>(args[2]->NumberValue(context).ToChecked()),
|
|
284
|
+
static_cast<float>(args[3]->NumberValue(context).ToChecked()),
|
|
285
|
+
static_cast<float>(args[4]->NumberValue(context).ToChecked()),
|
|
286
|
+
static_cast<float>(args[5]->NumberValue(context).ToChecked()),
|
|
287
|
+
static_cast<float>(args[6]->NumberValue(context).ToChecked()),
|
|
288
|
+
anti_clockwise
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
args.GetReturnValue().SetUndefined();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
void Path2D::LineTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
296
|
+
Path2D *ptr = GetPointer(args.This());
|
|
297
|
+
if (ptr == nullptr) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
auto isolate = args.GetIsolate();
|
|
302
|
+
auto context = isolate->GetCurrentContext();
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
canvas_native_path_line_to(ptr->GetPath(),
|
|
306
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
307
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()));
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
args.GetReturnValue().SetUndefined();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
void Path2D::MoveTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
314
|
+
Path2D *ptr = GetPointer(args.This());
|
|
315
|
+
if (ptr == nullptr) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
auto isolate = args.GetIsolate();
|
|
320
|
+
auto context = isolate->GetCurrentContext();
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
canvas_native_path_move_to(ptr->GetPath(),
|
|
324
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
325
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()));
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
args.GetReturnValue().SetUndefined();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
void Path2D::QuadraticCurveTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
332
|
+
Path2D *ptr = GetPointer(args.This());
|
|
333
|
+
if (ptr == nullptr) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
auto isolate = args.GetIsolate();
|
|
338
|
+
auto context = isolate->GetCurrentContext();
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
canvas_native_path_quadratic_curve_to(
|
|
342
|
+
ptr->GetPath(),
|
|
343
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
344
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()),
|
|
345
|
+
static_cast<float>(args[2]->NumberValue(context).ToChecked()),
|
|
346
|
+
static_cast<float>(args[3]->NumberValue(context).ToChecked())
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
args.GetReturnValue().SetUndefined();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
void Path2D::Rect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
353
|
+
Path2D *ptr = GetPointer(args.This());
|
|
354
|
+
if (ptr == nullptr) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
auto isolate = args.GetIsolate();
|
|
359
|
+
auto context = isolate->GetCurrentContext();
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
canvas_native_path_rect(
|
|
363
|
+
ptr->GetPath(),
|
|
364
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
365
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()),
|
|
366
|
+
static_cast<float>(args[2]->NumberValue(context).ToChecked()),
|
|
367
|
+
static_cast<float>(args[3]->NumberValue(context).ToChecked())
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
args.GetReturnValue().SetUndefined();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
void Path2D::RoundRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
374
|
+
Path2D *ptr = GetPointer(args.This());
|
|
375
|
+
if (ptr == nullptr) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
auto isolate = args.GetIsolate();
|
|
380
|
+
auto context = isolate->GetCurrentContext();
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
if (args.Length() == 5) {
|
|
384
|
+
auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
|
|
385
|
+
auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
|
|
386
|
+
auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
|
|
387
|
+
auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
|
|
388
|
+
auto objectOrNumber = args[4];
|
|
389
|
+
if (objectOrNumber->IsObject()) {
|
|
390
|
+
auto radii = objectOrNumber.As<v8::Object>();
|
|
391
|
+
if (radii->IsArray()) {
|
|
392
|
+
auto array = radii.As<v8::Array>();
|
|
393
|
+
auto size = array->Length();
|
|
394
|
+
|
|
395
|
+
if (size > 1) {
|
|
396
|
+
std::vector<float> store;
|
|
397
|
+
store.reserve(size);
|
|
398
|
+
for (int i = 0;
|
|
399
|
+
i < size; i++) {
|
|
400
|
+
store[i] = (float) array->Get(context, i).ToLocalChecked()->NumberValue(
|
|
401
|
+
context).ToChecked();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
canvas_native_path_round_rect(
|
|
405
|
+
ptr->GetPath(),
|
|
406
|
+
x, y,
|
|
407
|
+
width,
|
|
408
|
+
height, store.data(),
|
|
409
|
+
store.size());
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
} else {
|
|
414
|
+
auto radii = (float) objectOrNumber->NumberValue(context).ToChecked();
|
|
415
|
+
canvas_native_path_round_rect_tl_tr_br_bl(
|
|
416
|
+
ptr->GetPath(), x, y,
|
|
417
|
+
width,
|
|
418
|
+
height, radii, radii,
|
|
419
|
+
radii, radii);
|
|
420
|
+
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
args.GetReturnValue().SetUndefined();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
void Path2D::__toSVG(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
428
|
+
Path2D *ptr = GetPointer(args.This());
|
|
429
|
+
if (ptr == nullptr) {
|
|
430
|
+
args.GetReturnValue().SetEmptyString();
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
auto isolate = args.GetIsolate();
|
|
435
|
+
|
|
436
|
+
auto d = canvas_native_path_to_string(
|
|
437
|
+
ptr->GetPath());
|
|
438
|
+
|
|
439
|
+
// args.GetReturnValue().Set(ConvertToV8String(isolate, d.c_str()));
|
|
440
|
+
|
|
441
|
+
auto value = new OneByteStringResource((char *)d);
|
|
442
|
+
auto ret = v8::String::NewExternalOneByte(isolate, value);
|
|
443
|
+
args.GetReturnValue().Set(ret.ToLocalChecked());
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
Path* Path2D::GetPath() {
|
|
447
|
+
return this->path_;
|
|
448
|
+
}
|
|
449
|
+
|