@hxa-rn/react-native-gcanvas 6.0.25 → 6.0.26

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/LICENSE +203 -21
  3. package/README.md +5 -5
  4. package/harmony/gcanvas/LICENSE +203 -21
  5. package/harmony/gcanvas/NOTICE +32 -32
  6. package/harmony/gcanvas/OAT.xml +37 -37
  7. package/harmony/gcanvas/build-profile.json5 +16 -16
  8. package/harmony/gcanvas/hvigorfile.ts +1 -1
  9. package/harmony/gcanvas/index.ets +1 -1
  10. package/harmony/gcanvas/oh-package.json5 +14 -14
  11. package/harmony/gcanvas/src/main/cpp/CMakeLists.txt +126 -126
  12. package/harmony/gcanvas/src/main/cpp/GCanvasNapi.cpp +485 -485
  13. package/harmony/gcanvas/src/main/cpp/GCanvasXComponent.cpp +106 -106
  14. package/harmony/gcanvas/src/main/cpp/GcanvasPackage.h +24 -24
  15. package/harmony/gcanvas/src/main/ets/GCanvasModuleTurboModule.ts +448 -448
  16. package/harmony/gcanvas/src/main/ets/GCanvasNativeEngine.ts +206 -206
  17. package/harmony/gcanvas/src/main/ets/components/GCanvasView.ets +64 -64
  18. package/harmony/gcanvas/src/main/module.json5 +21 -21
  19. package/harmony/gcanvas/src/main/resources/base/element/string.json +12 -12
  20. package/harmony/gcanvas/src/main/resources/en_US/element/string.json +8 -8
  21. package/harmony/gcanvas/src/main/resources/zh_CN/element/string.json +12 -12
  22. package/harmony/gcanvas.har +0 -0
  23. package/package.json +4 -4
  24. package/packages/gcanvas/.babelrc +4 -4
  25. package/packages/gcanvas/.eslintrc.js +133 -133
  26. package/packages/gcanvas/package.json +19 -19
  27. package/packages/gcanvas/rollup.config.js +13 -13
  28. package/packages/gcanvas/src/bridge/react-native.js +286 -286
  29. package/packages/gcanvas/src/bridge/weex.js +210 -210
  30. package/packages/gcanvas/src/context/2d/FillStyleLinearGradient.js +16 -16
  31. package/packages/gcanvas/src/context/2d/FillStylePattern.js +7 -7
  32. package/packages/gcanvas/src/context/2d/FillStyleRadialGradient.js +16 -16
  33. package/packages/gcanvas/src/context/2d/OffScreenRenderingContext.js +48 -48
  34. package/packages/gcanvas/src/context/2d/RenderingContext.js +787 -787
  35. package/packages/gcanvas/src/context/webgl/ActiveInfo.js +10 -10
  36. package/packages/gcanvas/src/context/webgl/Buffer.js +20 -20
  37. package/packages/gcanvas/src/context/webgl/Framebuffer.js +20 -20
  38. package/packages/gcanvas/src/context/webgl/GLenum.js +300 -300
  39. package/packages/gcanvas/src/context/webgl/GLmethod.js +141 -141
  40. package/packages/gcanvas/src/context/webgl/GLtype.js +22 -22
  41. package/packages/gcanvas/src/context/webgl/Program.js +20 -20
  42. package/packages/gcanvas/src/context/webgl/Renderbuffer.js +20 -20
  43. package/packages/gcanvas/src/context/webgl/RenderingContext.js +1479 -1479
  44. package/packages/gcanvas/src/context/webgl/Shader.js +21 -21
  45. package/packages/gcanvas/src/context/webgl/ShaderPrecisionFormat.js +10 -10
  46. package/packages/gcanvas/src/context/webgl/Texture.js +21 -21
  47. package/packages/gcanvas/src/context/webgl/UniformLocation.js +21 -21
  48. package/packages/gcanvas/src/context/webgl/classUtils.js +2 -2
  49. package/packages/gcanvas/src/env/canvas.js +210 -210
  50. package/packages/gcanvas/src/env/image.js +76 -76
  51. package/packages/gcanvas/src/env/off-screen-canvas.js +74 -74
  52. package/packages/gcanvas/src/index.js +56 -56
  53. package/src/components/CanvasView.js +20 -20
  54. package/src/components/GCanvasComponent.js +408 -408
  55. package/src/index.js +69 -69
  56. package/src/packages/gcanvas/.babelrc +4 -4
  57. package/src/packages/gcanvas/.eslintrc.js +133 -133
  58. package/src/packages/gcanvas/package.json +19 -19
  59. package/src/packages/gcanvas/rollup.config.js +13 -13
  60. package/src/packages/gcanvas/src/bridge/react-native.js +288 -288
  61. package/src/packages/gcanvas/src/bridge/weex.js +210 -210
  62. package/src/packages/gcanvas/src/context/2d/FillStyleLinearGradient.js +16 -16
  63. package/src/packages/gcanvas/src/context/2d/FillStylePattern.js +7 -7
  64. package/src/packages/gcanvas/src/context/2d/FillStyleRadialGradient.js +16 -16
  65. package/src/packages/gcanvas/src/context/2d/OffScreenRenderingContext.js +48 -48
  66. package/src/packages/gcanvas/src/context/2d/RenderingContext.js +801 -801
  67. package/src/packages/gcanvas/src/context/webgl/ActiveInfo.js +10 -10
  68. package/src/packages/gcanvas/src/context/webgl/Buffer.js +20 -20
  69. package/src/packages/gcanvas/src/context/webgl/Framebuffer.js +20 -20
  70. package/src/packages/gcanvas/src/context/webgl/GLenum.js +300 -300
  71. package/src/packages/gcanvas/src/context/webgl/GLmethod.js +141 -141
  72. package/src/packages/gcanvas/src/context/webgl/GLtype.js +22 -22
  73. package/src/packages/gcanvas/src/context/webgl/Program.js +20 -20
  74. package/src/packages/gcanvas/src/context/webgl/Renderbuffer.js +20 -20
  75. package/src/packages/gcanvas/src/context/webgl/RenderingContext.js +1479 -1479
  76. package/src/packages/gcanvas/src/context/webgl/Shader.js +21 -21
  77. package/src/packages/gcanvas/src/context/webgl/ShaderPrecisionFormat.js +10 -10
  78. package/src/packages/gcanvas/src/context/webgl/Texture.js +21 -21
  79. package/src/packages/gcanvas/src/context/webgl/UniformLocation.js +21 -21
  80. package/src/packages/gcanvas/src/context/webgl/classUtils.js +2 -2
  81. package/src/packages/gcanvas/src/env/canvas.js +210 -210
  82. package/src/packages/gcanvas/src/env/image.js +76 -76
  83. package/src/packages/gcanvas/src/env/off-screen-canvas.js +74 -74
  84. package/src/packages/gcanvas/src/index.js +56 -56
  85. package/src/specs/v1/GCanvasViewNativeComponent.ts +42 -42
  86. package/src/specs/v1/NativeGCanvasModule.ts +140 -140
@@ -1,210 +1,210 @@
1
- import GLmethod from '../context/webgl/GLmethod';
2
-
3
- const isWeex = typeof WXEnvironment !== 'undefined';
4
- const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform);
5
- const isWeexAndroid = isWeex && !isWeexIOS;
6
-
7
- const GCanvasModule =
8
- typeof weex !== 'undefined' && weex.requireModule ? weex.requireModule('gcanvas') :
9
- typeof __weex_require__ !== 'undefined' ? __weex_require__('@weex-module/gcanvas') : {};
10
-
11
- let isDebugging = false;
12
-
13
- let isComboDisabled = false;
14
-
15
- const logCommand = (function() {
16
- const methodQuery = [];
17
- Object.keys(GLmethod).forEach(key => {
18
- methodQuery[GLmethod[key]] = key;
19
- });
20
- const queryMethod = (id) => {
21
- return methodQuery[parseInt(id)] || 'NotFoundMethod';
22
- };
23
- const logCommand = (id, cmds) => {
24
- const mId = cmds.split(',')[0];
25
- const mName = queryMethod(mId);
26
- console.log(`=== callNative - componentId:${id}; method: ${mName}; cmds: ${cmds}`);
27
- };
28
- return logCommand;
29
- })();
30
-
31
- function joinArray(arr, sep) {
32
- let res = '';
33
- for (let i = 0; i < arr.length; i++) {
34
- if (i !== 0) {
35
- res += sep;
36
- }
37
- res += arr[i];
38
- }
39
- return res;
40
- }
41
-
42
- const commandsCache = {};
43
-
44
- const GBridge = {
45
-
46
- callEnable: (ref, configArray) => {
47
- commandsCache[ref] = [];
48
-
49
- return GCanvasModule.enable({
50
- componentId: ref,
51
- config: configArray
52
- });
53
- },
54
-
55
- callEnableDebug: () => {
56
- isDebugging = true;
57
- },
58
-
59
- callEnableDisableCombo: () => {
60
- isComboDisabled = true;
61
- },
62
-
63
- callSetContextType: function(componentId, context_type) {
64
- GCanvasModule.setContextType(context_type, componentId);
65
- },
66
-
67
- callReset: function(componentId) {
68
- GCanvasModule.resetComponent && GCanvasModule.resetComponent(componentId);
69
- },
70
-
71
- render: isWeexIOS ? function(componentId) {
72
- return GCanvasModule.extendCallNative({
73
- contextId: componentId,
74
- type: 0x60000001
75
- });
76
- } : function(componentId) {
77
- return callGCanvasLinkNative(componentId, 0x60000001, 'render');
78
- },
79
-
80
- render2d: isWeexIOS ? function(componentId, commands) {
81
- if (isDebugging) {
82
- console.log('>>> >>> render2d ===');
83
- console.log('>>> commands: ' + commands);
84
- }
85
-
86
- GCanvasModule.render(commands, componentId);
87
- } : function(componentId, commands) {
88
- if (isDebugging) {
89
- console.log('>>> >>> render2d ===');
90
- console.log('>>> commands: ' + commands);
91
- }
92
-
93
- callGCanvasLinkNative(componentId, 0x20000001, commands);
94
- },
95
-
96
- callExtendCallNative: isWeexIOS ? function(componentId, cmdArgs) {
97
- throw 'should not be here anymore ' + cmdArgs;
98
- } : function(componentId, cmdArgs) {
99
- throw 'should not be here anymore ' + cmdArgs;
100
- },
101
-
102
-
103
- flushNative: isWeexIOS ? function(componentId) {
104
- const cmdArgs = joinArray(commandsCache[componentId], ';');
105
- commandsCache[componentId] = [];
106
-
107
- if (isDebugging) {
108
- console.log('>>> >>> flush native ===');
109
- console.log('>>> commands: ' + cmdArgs);
110
- }
111
-
112
- const result = GCanvasModule.extendCallNative({
113
- 'contextId': componentId,
114
- 'type': 0x60000000,
115
- 'args': cmdArgs
116
- });
117
-
118
- const res = result && result.result;
119
-
120
- if (isDebugging) {
121
- console.log('>>> result: ' + res);
122
- }
123
-
124
- return res;
125
- } : function(componentId) {
126
- const cmdArgs = joinArray(commandsCache[componentId], ';');
127
- commandsCache[componentId] = [];
128
-
129
- if (isDebugging) {
130
- console.log('>>> >>> flush native ===');
131
- console.log('>>> commands: ' + cmdArgs);
132
- }
133
-
134
- const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs);
135
-
136
- if (isDebugging) {
137
- console.log('>>> result: ' + result);
138
- }
139
-
140
- return result;
141
- },
142
-
143
- callNative: function(componentId, cmdArgs, cache) {
144
- if (isDebugging) {
145
- logCommand(componentId, cmdArgs);
146
- }
147
-
148
- commandsCache[componentId].push(cmdArgs);
149
-
150
- if (!cache || isComboDisabled) {
151
- return GBridge.flushNative(componentId);
152
- } else {
153
- return undefined;
154
- }
155
- },
156
-
157
- texImage2D(componentId, ...args) {
158
- if (isWeexIOS) {
159
- if (args.length === 6) {
160
- const [target, level, internalformat, format, type, image] = args;
161
- GBridge.callNative(
162
- componentId,
163
- GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src
164
- );
165
- } else if (args.length === 9) {
166
- const [target, level, internalformat, width, height, border, format, type, image] = args;
167
- GBridge.callNative(
168
- componentId,
169
- GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' +
170
- + format + ',' + type + ',' + (image ? image.src : 0)
171
- );
172
- }
173
- } else if (isWeexAndroid) {
174
- if (args.length === 6) {
175
- const [target, level, internalformat, format, type, image] = args;
176
- GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src);
177
- } else if (args.length === 9) {
178
- const [target, level, internalformat, width, height, border, format, type, image] = args;
179
- GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, image ? image.src : 0);
180
- }
181
- }
182
- },
183
-
184
- texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) {
185
- if (isWeexIOS) {
186
- if (arguments.length === 8) {
187
- GBridge.callNative(
188
- componentId,
189
- GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src
190
- );
191
- }
192
- } else if (isWeexAndroid) {
193
- GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src);
194
- }
195
- },
196
-
197
- bindImageTexture(componentId, src, imageId) {
198
- GCanvasModule.bindImageTexture([src, imageId], componentId);
199
- },
200
-
201
- preloadImage([url, id], callback) {
202
- GCanvasModule.preLoadImage([url, id], function(image) {
203
- image.url = url;
204
- image.id = id;
205
- callback(image);
206
- });
207
- }
208
- };
209
-
210
- export default GBridge;
1
+ import GLmethod from '../context/webgl/GLmethod';
2
+
3
+ const isWeex = typeof WXEnvironment !== 'undefined';
4
+ const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform);
5
+ const isWeexAndroid = isWeex && !isWeexIOS;
6
+
7
+ const GCanvasModule =
8
+ typeof weex !== 'undefined' && weex.requireModule ? weex.requireModule('gcanvas') :
9
+ typeof __weex_require__ !== 'undefined' ? __weex_require__('@weex-module/gcanvas') : {};
10
+
11
+ let isDebugging = false;
12
+
13
+ let isComboDisabled = false;
14
+
15
+ const logCommand = (function() {
16
+ const methodQuery = [];
17
+ Object.keys(GLmethod).forEach(key => {
18
+ methodQuery[GLmethod[key]] = key;
19
+ });
20
+ const queryMethod = (id) => {
21
+ return methodQuery[parseInt(id)] || 'NotFoundMethod';
22
+ };
23
+ const logCommand = (id, cmds) => {
24
+ const mId = cmds.split(',')[0];
25
+ const mName = queryMethod(mId);
26
+ console.log(`=== callNative - componentId:${id}; method: ${mName}; cmds: ${cmds}`);
27
+ };
28
+ return logCommand;
29
+ })();
30
+
31
+ function joinArray(arr, sep) {
32
+ let res = '';
33
+ for (let i = 0; i < arr.length; i++) {
34
+ if (i !== 0) {
35
+ res += sep;
36
+ }
37
+ res += arr[i];
38
+ }
39
+ return res;
40
+ }
41
+
42
+ const commandsCache = {};
43
+
44
+ const GBridge = {
45
+
46
+ callEnable: (ref, configArray) => {
47
+ commandsCache[ref] = [];
48
+
49
+ return GCanvasModule.enable({
50
+ componentId: ref,
51
+ config: configArray
52
+ });
53
+ },
54
+
55
+ callEnableDebug: () => {
56
+ isDebugging = true;
57
+ },
58
+
59
+ callEnableDisableCombo: () => {
60
+ isComboDisabled = true;
61
+ },
62
+
63
+ callSetContextType: function(componentId, context_type) {
64
+ GCanvasModule.setContextType(context_type, componentId);
65
+ },
66
+
67
+ callReset: function(componentId) {
68
+ GCanvasModule.resetComponent && GCanvasModule.resetComponent(componentId);
69
+ },
70
+
71
+ render: isWeexIOS ? function(componentId) {
72
+ return GCanvasModule.extendCallNative({
73
+ contextId: componentId,
74
+ type: 0x60000001
75
+ });
76
+ } : function(componentId) {
77
+ return callGCanvasLinkNative(componentId, 0x60000001, 'render');
78
+ },
79
+
80
+ render2d: isWeexIOS ? function(componentId, commands) {
81
+ if (isDebugging) {
82
+ console.log('>>> >>> render2d ===');
83
+ console.log('>>> commands: ' + commands);
84
+ }
85
+
86
+ GCanvasModule.render(commands, componentId);
87
+ } : function(componentId, commands) {
88
+ if (isDebugging) {
89
+ console.log('>>> >>> render2d ===');
90
+ console.log('>>> commands: ' + commands);
91
+ }
92
+
93
+ callGCanvasLinkNative(componentId, 0x20000001, commands);
94
+ },
95
+
96
+ callExtendCallNative: isWeexIOS ? function(componentId, cmdArgs) {
97
+ throw 'should not be here anymore ' + cmdArgs;
98
+ } : function(componentId, cmdArgs) {
99
+ throw 'should not be here anymore ' + cmdArgs;
100
+ },
101
+
102
+
103
+ flushNative: isWeexIOS ? function(componentId) {
104
+ const cmdArgs = joinArray(commandsCache[componentId], ';');
105
+ commandsCache[componentId] = [];
106
+
107
+ if (isDebugging) {
108
+ console.log('>>> >>> flush native ===');
109
+ console.log('>>> commands: ' + cmdArgs);
110
+ }
111
+
112
+ const result = GCanvasModule.extendCallNative({
113
+ 'contextId': componentId,
114
+ 'type': 0x60000000,
115
+ 'args': cmdArgs
116
+ });
117
+
118
+ const res = result && result.result;
119
+
120
+ if (isDebugging) {
121
+ console.log('>>> result: ' + res);
122
+ }
123
+
124
+ return res;
125
+ } : function(componentId) {
126
+ const cmdArgs = joinArray(commandsCache[componentId], ';');
127
+ commandsCache[componentId] = [];
128
+
129
+ if (isDebugging) {
130
+ console.log('>>> >>> flush native ===');
131
+ console.log('>>> commands: ' + cmdArgs);
132
+ }
133
+
134
+ const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs);
135
+
136
+ if (isDebugging) {
137
+ console.log('>>> result: ' + result);
138
+ }
139
+
140
+ return result;
141
+ },
142
+
143
+ callNative: function(componentId, cmdArgs, cache) {
144
+ if (isDebugging) {
145
+ logCommand(componentId, cmdArgs);
146
+ }
147
+
148
+ commandsCache[componentId].push(cmdArgs);
149
+
150
+ if (!cache || isComboDisabled) {
151
+ return GBridge.flushNative(componentId);
152
+ } else {
153
+ return undefined;
154
+ }
155
+ },
156
+
157
+ texImage2D(componentId, ...args) {
158
+ if (isWeexIOS) {
159
+ if (args.length === 6) {
160
+ const [target, level, internalformat, format, type, image] = args;
161
+ GBridge.callNative(
162
+ componentId,
163
+ GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src
164
+ );
165
+ } else if (args.length === 9) {
166
+ const [target, level, internalformat, width, height, border, format, type, image] = args;
167
+ GBridge.callNative(
168
+ componentId,
169
+ GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' +
170
+ + format + ',' + type + ',' + (image ? image.src : 0)
171
+ );
172
+ }
173
+ } else if (isWeexAndroid) {
174
+ if (args.length === 6) {
175
+ const [target, level, internalformat, format, type, image] = args;
176
+ GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src);
177
+ } else if (args.length === 9) {
178
+ const [target, level, internalformat, width, height, border, format, type, image] = args;
179
+ GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, image ? image.src : 0);
180
+ }
181
+ }
182
+ },
183
+
184
+ texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) {
185
+ if (isWeexIOS) {
186
+ if (arguments.length === 8) {
187
+ GBridge.callNative(
188
+ componentId,
189
+ GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src
190
+ );
191
+ }
192
+ } else if (isWeexAndroid) {
193
+ GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src);
194
+ }
195
+ },
196
+
197
+ bindImageTexture(componentId, src, imageId) {
198
+ GCanvasModule.bindImageTexture([src, imageId], componentId);
199
+ },
200
+
201
+ preloadImage([url, id], callback) {
202
+ GCanvasModule.preLoadImage([url, id], function(image) {
203
+ image.url = url;
204
+ image.id = id;
205
+ callback(image);
206
+ });
207
+ }
208
+ };
209
+
210
+ export default GBridge;
@@ -1,17 +1,17 @@
1
- class FillStyleLinearGradient {
2
- constructor(x0, y0, x1, y1) {
3
- this._start_pos = { _x: x0, _y: y0 };
4
- this._end_pos = { _x: x1, _y: y1 };
5
- this._stop_count = 0;
6
- this._stops = [0, 0, 0, 0, 0];
7
- }
8
-
9
- addColorStop(pos, color) {
10
- if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
11
- this._stops[this._stop_count] = { _pos: pos, _color: color };
12
- this._stop_count++;
13
- }
14
- }
15
- }
16
-
1
+ class FillStyleLinearGradient {
2
+ constructor(x0, y0, x1, y1) {
3
+ this._start_pos = { _x: x0, _y: y0 };
4
+ this._end_pos = { _x: x1, _y: y1 };
5
+ this._stop_count = 0;
6
+ this._stops = [0, 0, 0, 0, 0];
7
+ }
8
+
9
+ addColorStop(pos, color) {
10
+ if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
11
+ this._stops[this._stop_count] = { _pos: pos, _color: color };
12
+ this._stop_count++;
13
+ }
14
+ }
15
+ }
16
+
17
17
  export default FillStyleLinearGradient;
@@ -1,8 +1,8 @@
1
- class FillStylePattern {
2
- constructor(img, pattern) {
3
- this._style = pattern;
4
- this._img = img;
5
- }
6
- }
7
-
1
+ class FillStylePattern {
2
+ constructor(img, pattern) {
3
+ this._style = pattern;
4
+ this._img = img;
5
+ }
6
+ }
7
+
8
8
  export default FillStylePattern;
@@ -1,17 +1,17 @@
1
- class FillStyleRadialGradient {
2
- constructor(x0, y0, r0, x1, y1, r1) {
3
- this._start_pos = { _x: x0, _y: y0, _r: r0 };
4
- this._end_pos = { _x: x1, _y: y1, _r: r1 };
5
- this._stop_count = 0;
6
- this._stops = [0, 0, 0, 0, 0];
7
- }
8
-
9
- addColorStop(pos, color) {
10
- if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
11
- this._stops[this._stop_count] = { _pos: pos, _color: color };
12
- this._stop_count++;
13
- }
14
- }
15
- }
16
-
1
+ class FillStyleRadialGradient {
2
+ constructor(x0, y0, r0, x1, y1, r1) {
3
+ this._start_pos = { _x: x0, _y: y0, _r: r0 };
4
+ this._end_pos = { _x: x1, _y: y1, _r: r1 };
5
+ this._stop_count = 0;
6
+ this._stops = [0, 0, 0, 0, 0];
7
+ }
8
+
9
+ addColorStop(pos, color) {
10
+ if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
11
+ this._stops[this._stop_count] = { _pos: pos, _color: color };
12
+ this._stop_count++;
13
+ }
14
+ }
15
+ }
16
+
17
17
  export default FillStyleRadialGradient;
@@ -1,49 +1,49 @@
1
- import GImage from '../env/image';
2
- import GContext2D from './RenderingContext';
3
-
4
-
5
- export default class GOffScreenContext2D extends GContext2D {
6
- constructor() {
7
- super();
8
- this.className = 'OffScreenCanvasRenderingContext2D';
9
- this.images = [];
10
- }
11
-
12
- drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
13
- const numArgs = arguments.length;
14
- function drawImageCommands() {
15
- if (numArgs === 3) {
16
- const x = parseFloat(sx) || 0.0;
17
- const y = parseFloat(sy) || 0.0;
18
-
19
- return 'd' + image._id + ',0,0,'
20
- + image.width + ',' + image.height + ','
21
- + x + ',' + y + ',' + image.width + ',' + image.height + ';';
22
- } else if (numArgs === 5) {
23
- const x = parseFloat(sx) || 0.0;
24
- const y = parseFloat(sy) || 0.0;
25
- const width = parseInt(sw) || image.width;
26
- const height = parseInt(sh) || image.height;
27
-
28
- return 'd' + image._id + ',0,0,'
29
- + image.width + ',' + image.height + ','
30
- + x + ',' + y + ',' + width + ',' + height + ';';
31
- } else if (numArgs === 9) {
32
- sx = parseFloat(sx) || 0.0;
33
- sy = parseFloat(sy) || 0.0;
34
- sw = parseInt(sw) || image.width;
35
- sh = parseInt(sh) || image.height;
36
- dx = parseFloat(dx) || 0.0;
37
- dy = parseFloat(dy) || 0.0;
38
- dw = parseInt(dw) || image.width;
39
- dh = parseInt(dh) || image.height;
40
-
41
- return 'd' + image._id + ','
42
- + sx + ',' + sy + ',' + sw + ',' + sh + ','
43
- + dx + ',' + dy + ',' + dw + ',' + dh + ';';
44
- }
45
- }
46
- this.images.push(image);
47
- this._drawCommands += drawImageCommands();
48
- }
1
+ import GImage from '../env/image';
2
+ import GContext2D from './RenderingContext';
3
+
4
+
5
+ export default class GOffScreenContext2D extends GContext2D {
6
+ constructor() {
7
+ super();
8
+ this.className = 'OffScreenCanvasRenderingContext2D';
9
+ this.images = [];
10
+ }
11
+
12
+ drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
13
+ const numArgs = arguments.length;
14
+ function drawImageCommands() {
15
+ if (numArgs === 3) {
16
+ const x = parseFloat(sx) || 0.0;
17
+ const y = parseFloat(sy) || 0.0;
18
+
19
+ return 'd' + image._id + ',0,0,'
20
+ + image.width + ',' + image.height + ','
21
+ + x + ',' + y + ',' + image.width + ',' + image.height + ';';
22
+ } else if (numArgs === 5) {
23
+ const x = parseFloat(sx) || 0.0;
24
+ const y = parseFloat(sy) || 0.0;
25
+ const width = parseInt(sw) || image.width;
26
+ const height = parseInt(sh) || image.height;
27
+
28
+ return 'd' + image._id + ',0,0,'
29
+ + image.width + ',' + image.height + ','
30
+ + x + ',' + y + ',' + width + ',' + height + ';';
31
+ } else if (numArgs === 9) {
32
+ sx = parseFloat(sx) || 0.0;
33
+ sy = parseFloat(sy) || 0.0;
34
+ sw = parseInt(sw) || image.width;
35
+ sh = parseInt(sh) || image.height;
36
+ dx = parseFloat(dx) || 0.0;
37
+ dy = parseFloat(dy) || 0.0;
38
+ dw = parseInt(dw) || image.width;
39
+ dh = parseInt(dh) || image.height;
40
+
41
+ return 'd' + image._id + ','
42
+ + sx + ',' + sy + ',' + sw + ',' + sh + ','
43
+ + dx + ',' + dy + ',' + dw + ',' + dh + ';';
44
+ }
45
+ }
46
+ this.images.push(image);
47
+ this._drawCommands += drawImageCommands();
48
+ }
49
49
  }