uview-plus 3.3.30 → 3.3.31
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/changelog.md +5 -0
- package/components/u-qrcode/qrcode.js +56 -27
- package/components/u-qrcode/u-qrcode.vue +42 -11
- package/libs/util/gcanvas/bridge/bridge-weex.js +241 -0
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +666 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +21 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +298 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +142 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +23 -0
- package/libs/util/gcanvas/context-webgl/Program.js +21 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +22 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +22 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +3 -0
- package/libs/util/gcanvas/env/canvas.js +74 -0
- package/libs/util/gcanvas/env/image.js +96 -0
- package/libs/util/gcanvas/env/tool.js +24 -0
- package/libs/util/gcanvas/index.js +39 -0
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1031,6 +1031,7 @@ let QRCode = {};
|
|
|
1031
1031
|
image: '',
|
|
1032
1032
|
imageSize: 30,
|
|
1033
1033
|
canvasId: opt.canvasId,
|
|
1034
|
+
nvueContext: opt.nvueContext,
|
|
1034
1035
|
context: opt.context,
|
|
1035
1036
|
usingComponents: opt.usingComponents,
|
|
1036
1037
|
showLoading: opt.showLoading,
|
|
@@ -1090,7 +1091,12 @@ let QRCode = {};
|
|
|
1090
1091
|
mask: true
|
|
1091
1092
|
});
|
|
1092
1093
|
}
|
|
1093
|
-
var ctx =
|
|
1094
|
+
var ctx = '';
|
|
1095
|
+
if (options.nvueContext) {
|
|
1096
|
+
ctx = options.nvueContext;
|
|
1097
|
+
} else {
|
|
1098
|
+
ctx = uni.createCanvasContext(options.canvasId, options.context);
|
|
1099
|
+
}
|
|
1094
1100
|
var count = qrCodeAlg.getModuleCount();
|
|
1095
1101
|
var ratioSize = options.size;
|
|
1096
1102
|
var ratioImgSize = options.imageSize;
|
|
@@ -1141,34 +1147,52 @@ let QRCode = {};
|
|
|
1141
1147
|
ctx.draw(true, () => {
|
|
1142
1148
|
// 保存到临时区域
|
|
1143
1149
|
setTimeout(() => {
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
} else if (!empty(res.apFilePath)) {
|
|
1157
|
-
options.cbResult(res.apFilePath)
|
|
1158
|
-
} else {
|
|
1150
|
+
if (options.nvueContext) {
|
|
1151
|
+
ctx.toTempFilePath(
|
|
1152
|
+
0,
|
|
1153
|
+
0,
|
|
1154
|
+
options.width,
|
|
1155
|
+
options.height,
|
|
1156
|
+
options.width,
|
|
1157
|
+
options.height,
|
|
1158
|
+
"",
|
|
1159
|
+
1,
|
|
1160
|
+
function(res) {
|
|
1161
|
+
if (options.cbResult) {
|
|
1159
1162
|
options.cbResult(res.tempFilePath)
|
|
1160
1163
|
}
|
|
1161
1164
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1165
|
+
);
|
|
1166
|
+
} else {
|
|
1167
|
+
uni.canvasToTempFilePath({
|
|
1168
|
+
width: options.width,
|
|
1169
|
+
height: options.height,
|
|
1170
|
+
destWidth: options.width,
|
|
1171
|
+
destHeight: options.height,
|
|
1172
|
+
canvasId: options.canvasId,
|
|
1173
|
+
quality: Number(1),
|
|
1174
|
+
success: function (res) {
|
|
1175
|
+
if (options.cbResult) {
|
|
1176
|
+
// 由于官方还没有统一此接口的输出字段,所以先判定下 支付宝为 res.apFilePath
|
|
1177
|
+
if (!empty(res.tempFilePath)) {
|
|
1178
|
+
options.cbResult(res.tempFilePath)
|
|
1179
|
+
} else if (!empty(res.apFilePath)) {
|
|
1180
|
+
options.cbResult(res.apFilePath)
|
|
1181
|
+
} else {
|
|
1182
|
+
options.cbResult(res.tempFilePath)
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
fail: function (res) {
|
|
1187
|
+
if (options.cbResult) {
|
|
1188
|
+
options.cbResult(res)
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
complete: function () {
|
|
1192
|
+
uni.hideLoading();
|
|
1193
|
+
},
|
|
1194
|
+
}, options.context);
|
|
1195
|
+
}
|
|
1172
1196
|
}, options.text.length + 100);
|
|
1173
1197
|
});
|
|
1174
1198
|
}, options.usingComponents ? 0 : 150);
|
|
@@ -1193,7 +1217,12 @@ let QRCode = {};
|
|
|
1193
1217
|
}
|
|
1194
1218
|
};
|
|
1195
1219
|
QRCode.prototype.clear = function (fn) {
|
|
1196
|
-
var ctx =
|
|
1220
|
+
var ctx = '';
|
|
1221
|
+
if (options.nvueContext) {
|
|
1222
|
+
ctx = options.nvueContext;
|
|
1223
|
+
} else {
|
|
1224
|
+
uni.createCanvasContext(this.options.canvasId, this.options.context)
|
|
1225
|
+
}
|
|
1197
1226
|
ctx.clearRect(0, 0, this.options.size, this.options.size)
|
|
1198
1227
|
ctx.draw(false, () => {
|
|
1199
1228
|
if (fn) {
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="u-qrcode" @longpress="longpress">
|
|
3
3
|
<view class="u-qrcode__content" @click="preview">
|
|
4
|
+
<!-- #ifndef APP-NVUE -->
|
|
4
5
|
<canvas class="u-qrcode__canvas"
|
|
5
6
|
:id="cid" :canvas-id="cid" :style="{ width: size + unit, height: size + unit }" />
|
|
7
|
+
<!-- #endif -->
|
|
8
|
+
<!-- #ifdef APP-NVUE -->
|
|
9
|
+
<gcanvas class="u-qrcode__canvas" ref="gcanvess"
|
|
10
|
+
:style="{ width: size + unit, height: size + unit }">
|
|
11
|
+
</gcanvas>
|
|
12
|
+
<!-- #endif -->
|
|
6
13
|
<view v-if="showLoading && loading" class="u-qrcode__loading"
|
|
7
14
|
:style="{ width: size + unit, height: size + unit }">
|
|
8
15
|
<up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
|
|
@@ -17,6 +24,13 @@
|
|
|
17
24
|
|
|
18
25
|
<script>
|
|
19
26
|
import QRCode from "./qrcode.js"
|
|
27
|
+
// #ifdef APP-NVUE
|
|
28
|
+
// https://github.com/dcloudio/NvueCanvasDemo/blob/master/README.md
|
|
29
|
+
import {
|
|
30
|
+
enable,
|
|
31
|
+
WeexBridge
|
|
32
|
+
} from '../../libs/util/gcanvas/index.js';
|
|
33
|
+
// #endif
|
|
20
34
|
let qrcode
|
|
21
35
|
export default {
|
|
22
36
|
name: "u-qrcode",
|
|
@@ -96,17 +110,43 @@ export default {
|
|
|
96
110
|
{
|
|
97
111
|
name: '保存二维码',
|
|
98
112
|
}
|
|
99
|
-
]
|
|
113
|
+
],
|
|
114
|
+
ganvas: null,
|
|
115
|
+
context: '',
|
|
116
|
+
canvasObj: {}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
mounted: function () {
|
|
120
|
+
// #ifdef APP-NVUE
|
|
121
|
+
/*获取元素引用*/
|
|
122
|
+
this.ganvas = this.$refs["gcanvess"]
|
|
123
|
+
/*通过元素引用获取canvas对象*/
|
|
124
|
+
this.canvasObj = enable(this.ganvas, {
|
|
125
|
+
bridge: WeexBridge
|
|
126
|
+
})
|
|
127
|
+
/*获取绘图所需的上下文,目前不支持3d*/
|
|
128
|
+
this.context = this.canvasObj.getContext('2d')
|
|
129
|
+
// #endif
|
|
130
|
+
|
|
131
|
+
if (this.loadMake) {
|
|
132
|
+
if (!this._empty(this.val)) {
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
this._makeCode()
|
|
135
|
+
}, 0);
|
|
136
|
+
}
|
|
100
137
|
}
|
|
101
138
|
},
|
|
102
139
|
methods: {
|
|
103
140
|
_makeCode() {
|
|
104
141
|
let that = this
|
|
105
142
|
if (!this._empty(this.val)) {
|
|
143
|
+
// #ifndef APP-NVUE
|
|
106
144
|
this.loading = true
|
|
145
|
+
// #endif
|
|
107
146
|
qrcode = new QRCode({
|
|
108
147
|
context: that, // 上下文环境
|
|
109
148
|
canvasId: that.cid, // canvas-id
|
|
149
|
+
nvueContext: that.context,
|
|
110
150
|
usingComponents: that.usingComponents, // 是否是自定义组件
|
|
111
151
|
showLoading: false, // 是否显示loading
|
|
112
152
|
loadingText: that.loadingText, // loading文字
|
|
@@ -225,16 +265,7 @@ export default {
|
|
|
225
265
|
}
|
|
226
266
|
},
|
|
227
267
|
computed: {
|
|
228
|
-
}
|
|
229
|
-
mounted: function () {
|
|
230
|
-
if (this.loadMake) {
|
|
231
|
-
if (!this._empty(this.val)) {
|
|
232
|
-
setTimeout(() => {
|
|
233
|
-
this._makeCode()
|
|
234
|
-
}, 0);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
},
|
|
268
|
+
}
|
|
238
269
|
}
|
|
239
270
|
</script>
|
|
240
271
|
<style lang="scss" scoped>
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const isWeex = typeof WXEnvironment !== 'undefined';
|
|
2
|
+
const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform);
|
|
3
|
+
const isWeexAndroid = isWeex && !isWeexIOS;
|
|
4
|
+
|
|
5
|
+
import GLmethod from '../context-webgl/GLmethod';
|
|
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
|
+
|
|
48
|
+
commandsCache[ref] = [];
|
|
49
|
+
|
|
50
|
+
return GCanvasModule.enable({
|
|
51
|
+
componentId: ref,
|
|
52
|
+
config: configArray
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
callEnableDebug: () => {
|
|
57
|
+
isDebugging = true;
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
callEnableDisableCombo: () => {
|
|
61
|
+
isComboDisabled = true;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
callSetContextType: function (componentId, context_type) {
|
|
65
|
+
GCanvasModule.setContextType(context_type, componentId);
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
callReset: function(id){
|
|
69
|
+
GCanvasModule.resetComponent && canvasModule.resetComponent(componentId);
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
render: isWeexIOS ? function (componentId) {
|
|
73
|
+
return GCanvasModule.extendCallNative({
|
|
74
|
+
contextId: componentId,
|
|
75
|
+
type: 0x60000001
|
|
76
|
+
});
|
|
77
|
+
} : function (componentId) {
|
|
78
|
+
return callGCanvasLinkNative(componentId, 0x60000001, 'render');
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
render2d: isWeexIOS ? function (componentId, commands, callback) {
|
|
82
|
+
|
|
83
|
+
if (isDebugging) {
|
|
84
|
+
console.log('>>> >>> render2d ===');
|
|
85
|
+
console.log('>>> commands: ' + commands);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
GCanvasModule.render([commands, callback?true:false], componentId, callback);
|
|
89
|
+
|
|
90
|
+
} : function (componentId, commands,callback) {
|
|
91
|
+
|
|
92
|
+
if (isDebugging) {
|
|
93
|
+
console.log('>>> >>> render2d ===');
|
|
94
|
+
console.log('>>> commands: ' + commands);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
callGCanvasLinkNative(componentId, 0x20000001, commands);
|
|
98
|
+
if(callback){
|
|
99
|
+
callback();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
callExtendCallNative: isWeexIOS ? function (componentId, cmdArgs) {
|
|
104
|
+
|
|
105
|
+
throw 'should not be here anymore ' + cmdArgs;
|
|
106
|
+
|
|
107
|
+
} : function (componentId, cmdArgs) {
|
|
108
|
+
|
|
109
|
+
throw 'should not be here anymore ' + cmdArgs;
|
|
110
|
+
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
flushNative: isWeexIOS ? function (componentId) {
|
|
115
|
+
|
|
116
|
+
const cmdArgs = joinArray(commandsCache[componentId], ';');
|
|
117
|
+
commandsCache[componentId] = [];
|
|
118
|
+
|
|
119
|
+
if (isDebugging) {
|
|
120
|
+
console.log('>>> >>> flush native ===');
|
|
121
|
+
console.log('>>> commands: ' + cmdArgs);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const result = GCanvasModule.extendCallNative({
|
|
125
|
+
"contextId": componentId,
|
|
126
|
+
"type": 0x60000000,
|
|
127
|
+
"args": cmdArgs
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const res = result && result.result;
|
|
131
|
+
|
|
132
|
+
if (isDebugging) {
|
|
133
|
+
console.log('>>> result: ' + res);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return res;
|
|
137
|
+
|
|
138
|
+
} : function (componentId) {
|
|
139
|
+
|
|
140
|
+
const cmdArgs = joinArray(commandsCache[componentId], ';');
|
|
141
|
+
commandsCache[componentId] = [];
|
|
142
|
+
|
|
143
|
+
if (isDebugging) {
|
|
144
|
+
console.log('>>> >>> flush native ===');
|
|
145
|
+
console.log('>>> commands: ' + cmdArgs);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs);
|
|
149
|
+
|
|
150
|
+
if (isDebugging) {
|
|
151
|
+
console.log('>>> result: ' + result);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return result;
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
callNative: function (componentId, cmdArgs, cache) {
|
|
158
|
+
|
|
159
|
+
if (isDebugging) {
|
|
160
|
+
logCommand(componentId, cmdArgs);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
commandsCache[componentId].push(cmdArgs);
|
|
164
|
+
|
|
165
|
+
if (!cache || isComboDisabled) {
|
|
166
|
+
return GBridge.flushNative(componentId);
|
|
167
|
+
} else {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
texImage2D(componentId, ...args) {
|
|
173
|
+
if (isWeexIOS) {
|
|
174
|
+
if (args.length === 6) {
|
|
175
|
+
const [target, level, internalformat, format, type, image] = args;
|
|
176
|
+
GBridge.callNative(
|
|
177
|
+
componentId,
|
|
178
|
+
GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src
|
|
179
|
+
)
|
|
180
|
+
} else if (args.length === 9) {
|
|
181
|
+
const [target, level, internalformat, width, height, border, format, type, image] = args;
|
|
182
|
+
GBridge.callNative(
|
|
183
|
+
componentId,
|
|
184
|
+
GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' +
|
|
185
|
+
+ format + ',' + type + ',' + (image ? image.src : 0)
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
} else if (isWeexAndroid) {
|
|
189
|
+
if (args.length === 6) {
|
|
190
|
+
const [target, level, internalformat, format, type, image] = args;
|
|
191
|
+
GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src);
|
|
192
|
+
} else if (args.length === 9) {
|
|
193
|
+
const [target, level, internalformat, width, height, border, format, type, image] = args;
|
|
194
|
+
GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, (image ? image.src : 0));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) {
|
|
200
|
+
if (isWeexIOS) {
|
|
201
|
+
if (arguments.length === 8) {
|
|
202
|
+
GBridge.callNative(
|
|
203
|
+
componentId,
|
|
204
|
+
GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
} else if (isWeexAndroid) {
|
|
208
|
+
GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src);
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
bindImageTexture(componentId, src, imageId) {
|
|
213
|
+
GCanvasModule.bindImageTexture([src, imageId], componentId);
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
perloadImage([url, id], callback) {
|
|
217
|
+
GCanvasModule.preLoadImage([url, id], function (image) {
|
|
218
|
+
image.url = url;
|
|
219
|
+
image.id = id;
|
|
220
|
+
callback(image);
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
measureText(text, fontStyle, componentId) {
|
|
225
|
+
return GCanvasModule.measureText([text, fontStyle], componentId);
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
getImageData (componentId, x, y, w, h, callback) {
|
|
229
|
+
GCanvasModule.getImageData([x, y,w,h],componentId,callback);
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
putImageData (componentId, data, x, y, w, h, callback) {
|
|
233
|
+
GCanvasModule.putImageData([x, y,w,h,data],componentId,callback);
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
toTempFilePath(componentId, x, y, width, height, destWidth, destHeight, fileType, quality, callback){
|
|
237
|
+
GCanvasModule.toTempFilePath([x, y, width,height, destWidth, destHeight, fileType, quality], componentId, callback);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export default GBridge;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class FillStyleLinearGradient {
|
|
2
|
+
|
|
3
|
+
constructor(x0, y0, x1, y1) {
|
|
4
|
+
this._start_pos = { _x: x0, _y: y0 };
|
|
5
|
+
this._end_pos = { _x: x1, _y: y1 };
|
|
6
|
+
this._stop_count = 0;
|
|
7
|
+
this._stops = [0, 0, 0, 0, 0];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
addColorStop = function (pos, color) {
|
|
11
|
+
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
|
|
12
|
+
this._stops[this._stop_count] = { _pos: pos, _color: color };
|
|
13
|
+
this._stop_count++;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default FillStyleLinearGradient;
|
|
@@ -0,0 +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
|
+
|
|
17
|
+
export default FillStyleRadialGradient;
|