konva 9.3.19 → 9.3.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/README.md +1 -1
- package/konva.js +705 -663
- package/konva.min.js +3 -3
- package/lib/Container.d.ts +3 -3
- package/lib/Container.js +4 -10
- package/lib/Factory.js +4 -4
- package/lib/Global.js +1 -1
- package/lib/Layer.d.ts +2 -2
- package/lib/Layer.js +2 -2
- package/lib/Node.d.ts +9 -9
- package/lib/Node.js +39 -22
- package/lib/PointerEvents.d.ts +1 -1
- package/lib/Shape.d.ts +1 -1
- package/lib/Shape.js +7 -6
- package/lib/Stage.js +2 -1
- package/lib/Tween.js +9 -0
- package/lib/Validators.js +3 -3
- package/lib/filters/Blur.js +11 -11
- package/lib/filters/Enhance.js +4 -4
- package/lib/filters/HSV.js +4 -5
- package/lib/filters/Pixelate.js +18 -18
- package/lib/shapes/Line.d.ts +2 -2
- package/lib/shapes/Line.js +4 -3
- package/lib/shapes/Path.d.ts +3 -3
- package/lib/shapes/Path.js +33 -29
- package/lib/shapes/Text.js +14 -16
- package/lib/shapes/Transformer.js +14 -14
- package/package.json +3 -2
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v9.3.
|
|
8
|
+
* Konva JavaScript Framework v9.3.21
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Mon Jul 07 2025
|
|
12
12
|
*
|
|
13
13
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
|
14
14
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
: {};
|
|
36
36
|
const Konva$2 = {
|
|
37
37
|
_global: glob,
|
|
38
|
-
version: '9.3.
|
|
38
|
+
version: '9.3.21',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
},
|
|
152
152
|
isTransforming() {
|
|
153
153
|
var _a;
|
|
154
|
-
return (_a = Konva$2['Transformer']) === null || _a ===
|
|
154
|
+
return (_a = Konva$2['Transformer']) === null || _a === void 0 ? void 0 : _a.isTransforming();
|
|
155
155
|
},
|
|
156
156
|
/**
|
|
157
157
|
* returns whether or not a drag and drop operation is ready, but may
|
|
@@ -1150,290 +1150,6 @@
|
|
|
1150
1150
|
},
|
|
1151
1151
|
};
|
|
1152
1152
|
|
|
1153
|
-
function _formatValue(val) {
|
|
1154
|
-
if (Util._isString(val)) {
|
|
1155
|
-
return '"' + val + '"';
|
|
1156
|
-
}
|
|
1157
|
-
if (Object.prototype.toString.call(val) === '[object Number]') {
|
|
1158
|
-
return val;
|
|
1159
|
-
}
|
|
1160
|
-
if (Util._isBoolean(val)) {
|
|
1161
|
-
return val;
|
|
1162
|
-
}
|
|
1163
|
-
return Object.prototype.toString.call(val);
|
|
1164
|
-
}
|
|
1165
|
-
function RGBComponent(val) {
|
|
1166
|
-
if (val > 255) {
|
|
1167
|
-
return 255;
|
|
1168
|
-
}
|
|
1169
|
-
else if (val < 0) {
|
|
1170
|
-
return 0;
|
|
1171
|
-
}
|
|
1172
|
-
return Math.round(val);
|
|
1173
|
-
}
|
|
1174
|
-
function getNumberValidator() {
|
|
1175
|
-
if (Konva$2.isUnminified) {
|
|
1176
|
-
return function (val, attr) {
|
|
1177
|
-
if (!Util._isNumber(val)) {
|
|
1178
|
-
Util.warn(_formatValue(val) +
|
|
1179
|
-
' is a not valid value for "' +
|
|
1180
|
-
attr +
|
|
1181
|
-
'" attribute. The value should be a number.');
|
|
1182
|
-
}
|
|
1183
|
-
return val;
|
|
1184
|
-
};
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
function getNumberOrArrayOfNumbersValidator(noOfElements) {
|
|
1188
|
-
if (Konva$2.isUnminified) {
|
|
1189
|
-
return function (val, attr) {
|
|
1190
|
-
let isNumber = Util._isNumber(val);
|
|
1191
|
-
let isValidArray = Util._isArray(val) && val.length == noOfElements;
|
|
1192
|
-
if (!isNumber && !isValidArray) {
|
|
1193
|
-
Util.warn(_formatValue(val) +
|
|
1194
|
-
' is a not valid value for "' +
|
|
1195
|
-
attr +
|
|
1196
|
-
'" attribute. The value should be a number or Array<number>(' +
|
|
1197
|
-
noOfElements +
|
|
1198
|
-
')');
|
|
1199
|
-
}
|
|
1200
|
-
return val;
|
|
1201
|
-
};
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
function getNumberOrAutoValidator() {
|
|
1205
|
-
if (Konva$2.isUnminified) {
|
|
1206
|
-
return function (val, attr) {
|
|
1207
|
-
var isNumber = Util._isNumber(val);
|
|
1208
|
-
var isAuto = val === 'auto';
|
|
1209
|
-
if (!(isNumber || isAuto)) {
|
|
1210
|
-
Util.warn(_formatValue(val) +
|
|
1211
|
-
' is a not valid value for "' +
|
|
1212
|
-
attr +
|
|
1213
|
-
'" attribute. The value should be a number or "auto".');
|
|
1214
|
-
}
|
|
1215
|
-
return val;
|
|
1216
|
-
};
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
function getStringValidator() {
|
|
1220
|
-
if (Konva$2.isUnminified) {
|
|
1221
|
-
return function (val, attr) {
|
|
1222
|
-
if (!Util._isString(val)) {
|
|
1223
|
-
Util.warn(_formatValue(val) +
|
|
1224
|
-
' is a not valid value for "' +
|
|
1225
|
-
attr +
|
|
1226
|
-
'" attribute. The value should be a string.');
|
|
1227
|
-
}
|
|
1228
|
-
return val;
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
function getStringOrGradientValidator() {
|
|
1233
|
-
if (Konva$2.isUnminified) {
|
|
1234
|
-
return function (val, attr) {
|
|
1235
|
-
const isString = Util._isString(val);
|
|
1236
|
-
const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
|
|
1237
|
-
(val && val['addColorStop']);
|
|
1238
|
-
if (!(isString || isGradient)) {
|
|
1239
|
-
Util.warn(_formatValue(val) +
|
|
1240
|
-
' is a not valid value for "' +
|
|
1241
|
-
attr +
|
|
1242
|
-
'" attribute. The value should be a string or a native gradient.');
|
|
1243
|
-
}
|
|
1244
|
-
return val;
|
|
1245
|
-
};
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
function getNumberArrayValidator() {
|
|
1249
|
-
if (Konva$2.isUnminified) {
|
|
1250
|
-
return function (val, attr) {
|
|
1251
|
-
// Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
|
|
1252
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
|
|
1253
|
-
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
|
|
1254
|
-
if (TypedArray && val instanceof TypedArray) {
|
|
1255
|
-
return val;
|
|
1256
|
-
}
|
|
1257
|
-
if (!Util._isArray(val)) {
|
|
1258
|
-
Util.warn(_formatValue(val) +
|
|
1259
|
-
' is a not valid value for "' +
|
|
1260
|
-
attr +
|
|
1261
|
-
'" attribute. The value should be a array of numbers.');
|
|
1262
|
-
}
|
|
1263
|
-
else {
|
|
1264
|
-
val.forEach(function (item) {
|
|
1265
|
-
if (!Util._isNumber(item)) {
|
|
1266
|
-
Util.warn('"' +
|
|
1267
|
-
attr +
|
|
1268
|
-
'" attribute has non numeric element ' +
|
|
1269
|
-
item +
|
|
1270
|
-
'. Make sure that all elements are numbers.');
|
|
1271
|
-
}
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
return val;
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
function getBooleanValidator() {
|
|
1279
|
-
if (Konva$2.isUnminified) {
|
|
1280
|
-
return function (val, attr) {
|
|
1281
|
-
var isBool = val === true || val === false;
|
|
1282
|
-
if (!isBool) {
|
|
1283
|
-
Util.warn(_formatValue(val) +
|
|
1284
|
-
' is a not valid value for "' +
|
|
1285
|
-
attr +
|
|
1286
|
-
'" attribute. The value should be a boolean.');
|
|
1287
|
-
}
|
|
1288
|
-
return val;
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
function getComponentValidator(components) {
|
|
1293
|
-
if (Konva$2.isUnminified) {
|
|
1294
|
-
return function (val, attr) {
|
|
1295
|
-
// ignore validation on undefined value, because it will reset to defalt
|
|
1296
|
-
if (val === undefined || val === null) {
|
|
1297
|
-
return val;
|
|
1298
|
-
}
|
|
1299
|
-
if (!Util.isObject(val)) {
|
|
1300
|
-
Util.warn(_formatValue(val) +
|
|
1301
|
-
' is a not valid value for "' +
|
|
1302
|
-
attr +
|
|
1303
|
-
'" attribute. The value should be an object with properties ' +
|
|
1304
|
-
components);
|
|
1305
|
-
}
|
|
1306
|
-
return val;
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
const GET = 'get';
|
|
1312
|
-
const SET$1 = 'set';
|
|
1313
|
-
const Factory = {
|
|
1314
|
-
addGetterSetter(constructor, attr, def, validator, after) {
|
|
1315
|
-
Factory.addGetter(constructor, attr, def);
|
|
1316
|
-
Factory.addSetter(constructor, attr, validator, after);
|
|
1317
|
-
Factory.addOverloadedGetterSetter(constructor, attr);
|
|
1318
|
-
},
|
|
1319
|
-
addGetter(constructor, attr, def) {
|
|
1320
|
-
var method = GET + Util._capitalize(attr);
|
|
1321
|
-
constructor.prototype[method] =
|
|
1322
|
-
constructor.prototype[method] ||
|
|
1323
|
-
function () {
|
|
1324
|
-
const val = this.attrs[attr];
|
|
1325
|
-
return val === undefined ? def : val;
|
|
1326
|
-
};
|
|
1327
|
-
},
|
|
1328
|
-
addSetter(constructor, attr, validator, after) {
|
|
1329
|
-
var method = SET$1 + Util._capitalize(attr);
|
|
1330
|
-
if (!constructor.prototype[method]) {
|
|
1331
|
-
Factory.overWriteSetter(constructor, attr, validator, after);
|
|
1332
|
-
}
|
|
1333
|
-
},
|
|
1334
|
-
overWriteSetter(constructor, attr, validator, after) {
|
|
1335
|
-
var method = SET$1 + Util._capitalize(attr);
|
|
1336
|
-
constructor.prototype[method] = function (val) {
|
|
1337
|
-
if (validator && val !== undefined && val !== null) {
|
|
1338
|
-
val = validator.call(this, val, attr);
|
|
1339
|
-
}
|
|
1340
|
-
this._setAttr(attr, val);
|
|
1341
|
-
if (after) {
|
|
1342
|
-
after.call(this);
|
|
1343
|
-
}
|
|
1344
|
-
return this;
|
|
1345
|
-
};
|
|
1346
|
-
},
|
|
1347
|
-
addComponentsGetterSetter(constructor, attr, components, validator, after) {
|
|
1348
|
-
const len = components.length, capitalize = Util._capitalize, getter = GET + capitalize(attr), setter = SET$1 + capitalize(attr);
|
|
1349
|
-
// getter
|
|
1350
|
-
constructor.prototype[getter] = function () {
|
|
1351
|
-
const ret = {};
|
|
1352
|
-
for (let n = 0; n < len; n++) {
|
|
1353
|
-
const component = components[n];
|
|
1354
|
-
ret[component] = this.getAttr(attr + capitalize(component));
|
|
1355
|
-
}
|
|
1356
|
-
return ret;
|
|
1357
|
-
};
|
|
1358
|
-
const basicValidator = getComponentValidator(components);
|
|
1359
|
-
// setter
|
|
1360
|
-
constructor.prototype[setter] = function (val) {
|
|
1361
|
-
const oldVal = this.attrs[attr];
|
|
1362
|
-
if (validator) {
|
|
1363
|
-
val = validator.call(this, val, attr);
|
|
1364
|
-
}
|
|
1365
|
-
if (basicValidator) {
|
|
1366
|
-
basicValidator.call(this, val, attr);
|
|
1367
|
-
}
|
|
1368
|
-
for (const key in val) {
|
|
1369
|
-
if (!val.hasOwnProperty(key)) {
|
|
1370
|
-
continue;
|
|
1371
|
-
}
|
|
1372
|
-
this._setAttr(attr + capitalize(key), val[key]);
|
|
1373
|
-
}
|
|
1374
|
-
if (!val) {
|
|
1375
|
-
components.forEach((component) => {
|
|
1376
|
-
this._setAttr(attr + capitalize(component), undefined);
|
|
1377
|
-
});
|
|
1378
|
-
}
|
|
1379
|
-
this._fireChangeEvent(attr, oldVal, val);
|
|
1380
|
-
if (after) {
|
|
1381
|
-
after.call(this);
|
|
1382
|
-
}
|
|
1383
|
-
return this;
|
|
1384
|
-
};
|
|
1385
|
-
Factory.addOverloadedGetterSetter(constructor, attr);
|
|
1386
|
-
},
|
|
1387
|
-
addOverloadedGetterSetter(constructor, attr) {
|
|
1388
|
-
var capitalizedAttr = Util._capitalize(attr), setter = SET$1 + capitalizedAttr, getter = GET + capitalizedAttr;
|
|
1389
|
-
constructor.prototype[attr] = function () {
|
|
1390
|
-
// setting
|
|
1391
|
-
if (arguments.length) {
|
|
1392
|
-
this[setter](arguments[0]);
|
|
1393
|
-
return this;
|
|
1394
|
-
}
|
|
1395
|
-
// getting
|
|
1396
|
-
return this[getter]();
|
|
1397
|
-
};
|
|
1398
|
-
},
|
|
1399
|
-
addDeprecatedGetterSetter(constructor, attr, def, validator) {
|
|
1400
|
-
Util.error('Adding deprecated ' + attr);
|
|
1401
|
-
const method = GET + Util._capitalize(attr);
|
|
1402
|
-
const message = attr +
|
|
1403
|
-
' property is deprecated and will be removed soon. Look at Konva change log for more information.';
|
|
1404
|
-
constructor.prototype[method] = function () {
|
|
1405
|
-
Util.error(message);
|
|
1406
|
-
const val = this.attrs[attr];
|
|
1407
|
-
return val === undefined ? def : val;
|
|
1408
|
-
};
|
|
1409
|
-
Factory.addSetter(constructor, attr, validator, function () {
|
|
1410
|
-
Util.error(message);
|
|
1411
|
-
});
|
|
1412
|
-
Factory.addOverloadedGetterSetter(constructor, attr);
|
|
1413
|
-
},
|
|
1414
|
-
backCompat(constructor, methods) {
|
|
1415
|
-
Util.each(methods, function (oldMethodName, newMethodName) {
|
|
1416
|
-
const method = constructor.prototype[newMethodName];
|
|
1417
|
-
const oldGetter = GET + Util._capitalize(oldMethodName);
|
|
1418
|
-
const oldSetter = SET$1 + Util._capitalize(oldMethodName);
|
|
1419
|
-
function deprecated() {
|
|
1420
|
-
method.apply(this, arguments);
|
|
1421
|
-
Util.error('"' +
|
|
1422
|
-
oldMethodName +
|
|
1423
|
-
'" method is deprecated and will be removed soon. Use ""' +
|
|
1424
|
-
newMethodName +
|
|
1425
|
-
'" instead.');
|
|
1426
|
-
}
|
|
1427
|
-
constructor.prototype[oldMethodName] = deprecated;
|
|
1428
|
-
constructor.prototype[oldGetter] = deprecated;
|
|
1429
|
-
constructor.prototype[oldSetter] = deprecated;
|
|
1430
|
-
});
|
|
1431
|
-
},
|
|
1432
|
-
afterSetFilter() {
|
|
1433
|
-
this._filterUpToDate = false;
|
|
1434
|
-
},
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
1153
|
function simplifyArray(arr) {
|
|
1438
1154
|
const retArr = [], len = arr.length, util = Util;
|
|
1439
1155
|
for (let n = 0; n < len; n++) {
|
|
@@ -2178,7 +1894,7 @@
|
|
|
2178
1894
|
}
|
|
2179
1895
|
_applyShadow(shape) {
|
|
2180
1896
|
var _a, _b, _c;
|
|
2181
|
-
const color = (_a = shape.getShadowRGBA()) !== null && _a !==
|
|
1897
|
+
const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
|
|
2182
1898
|
x: 0,
|
|
2183
1899
|
y: 0,
|
|
2184
1900
|
}, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
|
|
@@ -2278,243 +1994,527 @@
|
|
|
2278
1994
|
this._canvas.style.top = '0';
|
|
2279
1995
|
this._canvas.style.left = '0';
|
|
2280
1996
|
}
|
|
2281
|
-
/**
|
|
2282
|
-
* get canvas context
|
|
2283
|
-
* @method
|
|
2284
|
-
* @name Konva.Canvas#getContext
|
|
2285
|
-
* @returns {CanvasContext} context
|
|
2286
|
-
*/
|
|
2287
|
-
getContext() {
|
|
2288
|
-
return this.context;
|
|
1997
|
+
/**
|
|
1998
|
+
* get canvas context
|
|
1999
|
+
* @method
|
|
2000
|
+
* @name Konva.Canvas#getContext
|
|
2001
|
+
* @returns {CanvasContext} context
|
|
2002
|
+
*/
|
|
2003
|
+
getContext() {
|
|
2004
|
+
return this.context;
|
|
2005
|
+
}
|
|
2006
|
+
/**
|
|
2007
|
+
* get pixel ratio
|
|
2008
|
+
* @method
|
|
2009
|
+
* @name Konva.Canvas#getPixelRatio
|
|
2010
|
+
* @returns {Number} pixel ratio
|
|
2011
|
+
* @example
|
|
2012
|
+
* var pixelRatio = layer.getCanvas.getPixelRatio();
|
|
2013
|
+
*/
|
|
2014
|
+
getPixelRatio() {
|
|
2015
|
+
return this.pixelRatio;
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* set pixel ratio
|
|
2019
|
+
* KonvaJS automatically handles pixel ratio adustments in order to render crisp drawings
|
|
2020
|
+
* on all devices. Most desktops, low end tablets, and low end phones, have device pixel ratios
|
|
2021
|
+
* of 1. Some high end tablets and phones, like iPhones and iPads have a device pixel ratio
|
|
2022
|
+
* of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel
|
|
2023
|
+
* ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise
|
|
2024
|
+
* specificed, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel
|
|
2025
|
+
* ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1.
|
|
2026
|
+
* @method
|
|
2027
|
+
* @name Konva.Canvas#setPixelRatio
|
|
2028
|
+
* @param {Number} pixelRatio
|
|
2029
|
+
* @example
|
|
2030
|
+
* layer.getCanvas().setPixelRatio(3);
|
|
2031
|
+
*/
|
|
2032
|
+
setPixelRatio(pixelRatio) {
|
|
2033
|
+
const previousRatio = this.pixelRatio;
|
|
2034
|
+
this.pixelRatio = pixelRatio;
|
|
2035
|
+
this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
|
|
2036
|
+
}
|
|
2037
|
+
setWidth(width) {
|
|
2038
|
+
// take into account pixel ratio
|
|
2039
|
+
this.width = this._canvas.width = width * this.pixelRatio;
|
|
2040
|
+
this._canvas.style.width = width + 'px';
|
|
2041
|
+
const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
|
|
2042
|
+
_context.scale(pixelRatio, pixelRatio);
|
|
2043
|
+
}
|
|
2044
|
+
setHeight(height) {
|
|
2045
|
+
// take into account pixel ratio
|
|
2046
|
+
this.height = this._canvas.height = height * this.pixelRatio;
|
|
2047
|
+
this._canvas.style.height = height + 'px';
|
|
2048
|
+
const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
|
|
2049
|
+
_context.scale(pixelRatio, pixelRatio);
|
|
2050
|
+
}
|
|
2051
|
+
getWidth() {
|
|
2052
|
+
return this.width;
|
|
2053
|
+
}
|
|
2054
|
+
getHeight() {
|
|
2055
|
+
return this.height;
|
|
2056
|
+
}
|
|
2057
|
+
setSize(width, height) {
|
|
2058
|
+
this.setWidth(width || 0);
|
|
2059
|
+
this.setHeight(height || 0);
|
|
2060
|
+
}
|
|
2061
|
+
/**
|
|
2062
|
+
* to data url
|
|
2063
|
+
* @method
|
|
2064
|
+
* @name Konva.Canvas#toDataURL
|
|
2065
|
+
* @param {String} mimeType
|
|
2066
|
+
* @param {Number} quality between 0 and 1 for jpg mime types
|
|
2067
|
+
* @returns {String} data url string
|
|
2068
|
+
*/
|
|
2069
|
+
toDataURL(mimeType, quality) {
|
|
2070
|
+
try {
|
|
2071
|
+
// If this call fails (due to browser bug, like in Firefox 3.6),
|
|
2072
|
+
// then revert to previous no-parameter image/png behavior
|
|
2073
|
+
return this._canvas.toDataURL(mimeType, quality);
|
|
2074
|
+
}
|
|
2075
|
+
catch (e) {
|
|
2076
|
+
try {
|
|
2077
|
+
return this._canvas.toDataURL();
|
|
2078
|
+
}
|
|
2079
|
+
catch (err) {
|
|
2080
|
+
Util.error('Unable to get data URL. ' +
|
|
2081
|
+
err.message +
|
|
2082
|
+
' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
|
|
2083
|
+
return '';
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
class SceneCanvas extends Canvas {
|
|
2089
|
+
constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
|
|
2090
|
+
super(config);
|
|
2091
|
+
this.context = new SceneContext(this, {
|
|
2092
|
+
willReadFrequently: config.willReadFrequently,
|
|
2093
|
+
});
|
|
2094
|
+
this.setSize(config.width, config.height);
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
class HitCanvas extends Canvas {
|
|
2098
|
+
constructor(config = { width: 0, height: 0 }) {
|
|
2099
|
+
super(config);
|
|
2100
|
+
this.hitCanvas = true;
|
|
2101
|
+
this.context = new HitContext(this);
|
|
2102
|
+
this.setSize(config.width, config.height);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
const DD = {
|
|
2107
|
+
get isDragging() {
|
|
2108
|
+
let flag = false;
|
|
2109
|
+
DD._dragElements.forEach((elem) => {
|
|
2110
|
+
if (elem.dragStatus === 'dragging') {
|
|
2111
|
+
flag = true;
|
|
2112
|
+
}
|
|
2113
|
+
});
|
|
2114
|
+
return flag;
|
|
2115
|
+
},
|
|
2116
|
+
justDragged: false,
|
|
2117
|
+
get node() {
|
|
2118
|
+
// return first dragging node
|
|
2119
|
+
let node;
|
|
2120
|
+
DD._dragElements.forEach((elem) => {
|
|
2121
|
+
node = elem.node;
|
|
2122
|
+
});
|
|
2123
|
+
return node;
|
|
2124
|
+
},
|
|
2125
|
+
_dragElements: new Map(),
|
|
2126
|
+
// methods
|
|
2127
|
+
_drag(evt) {
|
|
2128
|
+
const nodesToFireEvents = [];
|
|
2129
|
+
DD._dragElements.forEach((elem, key) => {
|
|
2130
|
+
const { node } = elem;
|
|
2131
|
+
// we need to find pointer relative to that node
|
|
2132
|
+
const stage = node.getStage();
|
|
2133
|
+
stage.setPointersPositions(evt);
|
|
2134
|
+
// it is possible that user call startDrag without any event
|
|
2135
|
+
// it that case we need to detect first movable pointer and attach it into the node
|
|
2136
|
+
if (elem.pointerId === undefined) {
|
|
2137
|
+
elem.pointerId = Util._getFirstPointerId(evt);
|
|
2138
|
+
}
|
|
2139
|
+
const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
|
|
2140
|
+
// not related pointer
|
|
2141
|
+
if (!pos) {
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
if (elem.dragStatus !== 'dragging') {
|
|
2145
|
+
const dragDistance = node.dragDistance();
|
|
2146
|
+
const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
|
|
2147
|
+
if (distance < dragDistance) {
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
node.startDrag({ evt });
|
|
2151
|
+
// a user can stop dragging inside `dragstart`
|
|
2152
|
+
if (!node.isDragging()) {
|
|
2153
|
+
return;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
node._setDragPosition(evt, elem);
|
|
2157
|
+
nodesToFireEvents.push(node);
|
|
2158
|
+
});
|
|
2159
|
+
// call dragmove only after ALL positions are changed
|
|
2160
|
+
nodesToFireEvents.forEach((node) => {
|
|
2161
|
+
node.fire('dragmove', {
|
|
2162
|
+
type: 'dragmove',
|
|
2163
|
+
target: node,
|
|
2164
|
+
evt: evt,
|
|
2165
|
+
}, true);
|
|
2166
|
+
});
|
|
2167
|
+
},
|
|
2168
|
+
// dragBefore and dragAfter allows us to set correct order of events
|
|
2169
|
+
// setup all in dragbefore, and stop dragging only after pointerup triggered.
|
|
2170
|
+
_endDragBefore(evt) {
|
|
2171
|
+
const drawNodes = [];
|
|
2172
|
+
DD._dragElements.forEach((elem) => {
|
|
2173
|
+
const { node } = elem;
|
|
2174
|
+
// we need to find pointer relative to that node
|
|
2175
|
+
const stage = node.getStage();
|
|
2176
|
+
if (evt) {
|
|
2177
|
+
stage.setPointersPositions(evt);
|
|
2178
|
+
}
|
|
2179
|
+
const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
|
|
2180
|
+
// that pointer is not related
|
|
2181
|
+
if (!pos) {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
|
|
2185
|
+
// if a node is stopped manually we still need to reset events:
|
|
2186
|
+
DD.justDragged = true;
|
|
2187
|
+
Konva$2._mouseListenClick = false;
|
|
2188
|
+
Konva$2._touchListenClick = false;
|
|
2189
|
+
Konva$2._pointerListenClick = false;
|
|
2190
|
+
elem.dragStatus = 'stopped';
|
|
2191
|
+
}
|
|
2192
|
+
const drawNode = elem.node.getLayer() ||
|
|
2193
|
+
(elem.node instanceof Konva$2['Stage'] && elem.node);
|
|
2194
|
+
if (drawNode && drawNodes.indexOf(drawNode) === -1) {
|
|
2195
|
+
drawNodes.push(drawNode);
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
// draw in a sync way
|
|
2199
|
+
// because mousemove event may trigger BEFORE batch draw is called
|
|
2200
|
+
// but as we have not hit canvas updated yet, it will trigger incorrect mouseover/mouseout events
|
|
2201
|
+
drawNodes.forEach((drawNode) => {
|
|
2202
|
+
drawNode.draw();
|
|
2203
|
+
});
|
|
2204
|
+
},
|
|
2205
|
+
_endDragAfter(evt) {
|
|
2206
|
+
DD._dragElements.forEach((elem, key) => {
|
|
2207
|
+
if (elem.dragStatus === 'stopped') {
|
|
2208
|
+
elem.node.fire('dragend', {
|
|
2209
|
+
type: 'dragend',
|
|
2210
|
+
target: elem.node,
|
|
2211
|
+
evt: evt,
|
|
2212
|
+
}, true);
|
|
2213
|
+
}
|
|
2214
|
+
if (elem.dragStatus !== 'dragging') {
|
|
2215
|
+
DD._dragElements.delete(key);
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
},
|
|
2219
|
+
};
|
|
2220
|
+
if (Konva$2.isBrowser) {
|
|
2221
|
+
window.addEventListener('mouseup', DD._endDragBefore, true);
|
|
2222
|
+
window.addEventListener('touchend', DD._endDragBefore, true);
|
|
2223
|
+
// add touchcancel to fix this: https://github.com/konvajs/konva/issues/1843
|
|
2224
|
+
window.addEventListener('touchcancel', DD._endDragBefore, true);
|
|
2225
|
+
window.addEventListener('mousemove', DD._drag);
|
|
2226
|
+
window.addEventListener('touchmove', DD._drag);
|
|
2227
|
+
window.addEventListener('mouseup', DD._endDragAfter, false);
|
|
2228
|
+
window.addEventListener('touchend', DD._endDragAfter, false);
|
|
2229
|
+
window.addEventListener('touchcancel', DD._endDragAfter, false);
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
function _formatValue(val) {
|
|
2233
|
+
if (Util._isString(val)) {
|
|
2234
|
+
return '"' + val + '"';
|
|
2235
|
+
}
|
|
2236
|
+
if (Object.prototype.toString.call(val) === '[object Number]') {
|
|
2237
|
+
return val;
|
|
2289
2238
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
* @method
|
|
2293
|
-
* @name Konva.Canvas#getPixelRatio
|
|
2294
|
-
* @returns {Number} pixel ratio
|
|
2295
|
-
* @example
|
|
2296
|
-
* var pixelRatio = layer.getCanvas.getPixelRatio();
|
|
2297
|
-
*/
|
|
2298
|
-
getPixelRatio() {
|
|
2299
|
-
return this.pixelRatio;
|
|
2239
|
+
if (Util._isBoolean(val)) {
|
|
2240
|
+
return val;
|
|
2300
2241
|
}
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
* of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel
|
|
2307
|
-
* ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise
|
|
2308
|
-
* specificed, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel
|
|
2309
|
-
* ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1.
|
|
2310
|
-
* @method
|
|
2311
|
-
* @name Konva.Canvas#setPixelRatio
|
|
2312
|
-
* @param {Number} pixelRatio
|
|
2313
|
-
* @example
|
|
2314
|
-
* layer.getCanvas().setPixelRatio(3);
|
|
2315
|
-
*/
|
|
2316
|
-
setPixelRatio(pixelRatio) {
|
|
2317
|
-
const previousRatio = this.pixelRatio;
|
|
2318
|
-
this.pixelRatio = pixelRatio;
|
|
2319
|
-
this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
|
|
2242
|
+
return Object.prototype.toString.call(val);
|
|
2243
|
+
}
|
|
2244
|
+
function RGBComponent(val) {
|
|
2245
|
+
if (val > 255) {
|
|
2246
|
+
return 255;
|
|
2320
2247
|
}
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
this.width = this._canvas.width = width * this.pixelRatio;
|
|
2324
|
-
this._canvas.style.width = width + 'px';
|
|
2325
|
-
const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
|
|
2326
|
-
_context.scale(pixelRatio, pixelRatio);
|
|
2248
|
+
else if (val < 0) {
|
|
2249
|
+
return 0;
|
|
2327
2250
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2251
|
+
return Math.round(val);
|
|
2252
|
+
}
|
|
2253
|
+
function getNumberValidator() {
|
|
2254
|
+
if (Konva$2.isUnminified) {
|
|
2255
|
+
return function (val, attr) {
|
|
2256
|
+
if (!Util._isNumber(val)) {
|
|
2257
|
+
Util.warn(_formatValue(val) +
|
|
2258
|
+
' is a not valid value for "' +
|
|
2259
|
+
attr +
|
|
2260
|
+
'" attribute. The value should be a number.');
|
|
2261
|
+
}
|
|
2262
|
+
return val;
|
|
2263
|
+
};
|
|
2334
2264
|
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2265
|
+
}
|
|
2266
|
+
function getNumberOrArrayOfNumbersValidator(noOfElements) {
|
|
2267
|
+
if (Konva$2.isUnminified) {
|
|
2268
|
+
return function (val, attr) {
|
|
2269
|
+
let isNumber = Util._isNumber(val);
|
|
2270
|
+
let isValidArray = Util._isArray(val) && val.length == noOfElements;
|
|
2271
|
+
if (!isNumber && !isValidArray) {
|
|
2272
|
+
Util.warn(_formatValue(val) +
|
|
2273
|
+
' is a not valid value for "' +
|
|
2274
|
+
attr +
|
|
2275
|
+
'" attribute. The value should be a number or Array<number>(' +
|
|
2276
|
+
noOfElements +
|
|
2277
|
+
')');
|
|
2278
|
+
}
|
|
2279
|
+
return val;
|
|
2280
|
+
};
|
|
2337
2281
|
}
|
|
2338
|
-
|
|
2339
|
-
|
|
2282
|
+
}
|
|
2283
|
+
function getNumberOrAutoValidator() {
|
|
2284
|
+
if (Konva$2.isUnminified) {
|
|
2285
|
+
return function (val, attr) {
|
|
2286
|
+
const isNumber = Util._isNumber(val);
|
|
2287
|
+
const isAuto = val === 'auto';
|
|
2288
|
+
if (!(isNumber || isAuto)) {
|
|
2289
|
+
Util.warn(_formatValue(val) +
|
|
2290
|
+
' is a not valid value for "' +
|
|
2291
|
+
attr +
|
|
2292
|
+
'" attribute. The value should be a number or "auto".');
|
|
2293
|
+
}
|
|
2294
|
+
return val;
|
|
2295
|
+
};
|
|
2340
2296
|
}
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2297
|
+
}
|
|
2298
|
+
function getStringValidator() {
|
|
2299
|
+
if (Konva$2.isUnminified) {
|
|
2300
|
+
return function (val, attr) {
|
|
2301
|
+
if (!Util._isString(val)) {
|
|
2302
|
+
Util.warn(_formatValue(val) +
|
|
2303
|
+
' is a not valid value for "' +
|
|
2304
|
+
attr +
|
|
2305
|
+
'" attribute. The value should be a string.');
|
|
2306
|
+
}
|
|
2307
|
+
return val;
|
|
2308
|
+
};
|
|
2344
2309
|
}
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
return this._canvas.toDataURL(mimeType, quality);
|
|
2358
|
-
}
|
|
2359
|
-
catch (e) {
|
|
2360
|
-
try {
|
|
2361
|
-
return this._canvas.toDataURL();
|
|
2310
|
+
}
|
|
2311
|
+
function getStringOrGradientValidator() {
|
|
2312
|
+
if (Konva$2.isUnminified) {
|
|
2313
|
+
return function (val, attr) {
|
|
2314
|
+
const isString = Util._isString(val);
|
|
2315
|
+
const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
|
|
2316
|
+
(val && val['addColorStop']);
|
|
2317
|
+
if (!(isString || isGradient)) {
|
|
2318
|
+
Util.warn(_formatValue(val) +
|
|
2319
|
+
' is a not valid value for "' +
|
|
2320
|
+
attr +
|
|
2321
|
+
'" attribute. The value should be a string or a native gradient.');
|
|
2362
2322
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2323
|
+
return val;
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
function getNumberArrayValidator() {
|
|
2328
|
+
if (Konva$2.isUnminified) {
|
|
2329
|
+
return function (val, attr) {
|
|
2330
|
+
// Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
|
|
2331
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
|
|
2332
|
+
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
|
|
2333
|
+
if (TypedArray && val instanceof TypedArray) {
|
|
2334
|
+
return val;
|
|
2368
2335
|
}
|
|
2369
|
-
|
|
2336
|
+
if (!Util._isArray(val)) {
|
|
2337
|
+
Util.warn(_formatValue(val) +
|
|
2338
|
+
' is a not valid value for "' +
|
|
2339
|
+
attr +
|
|
2340
|
+
'" attribute. The value should be a array of numbers.');
|
|
2341
|
+
}
|
|
2342
|
+
else {
|
|
2343
|
+
val.forEach(function (item) {
|
|
2344
|
+
if (!Util._isNumber(item)) {
|
|
2345
|
+
Util.warn('"' +
|
|
2346
|
+
attr +
|
|
2347
|
+
'" attribute has non numeric element ' +
|
|
2348
|
+
item +
|
|
2349
|
+
'. Make sure that all elements are numbers.');
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
return val;
|
|
2354
|
+
};
|
|
2370
2355
|
}
|
|
2371
2356
|
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2357
|
+
function getBooleanValidator() {
|
|
2358
|
+
if (Konva$2.isUnminified) {
|
|
2359
|
+
return function (val, attr) {
|
|
2360
|
+
const isBool = val === true || val === false;
|
|
2361
|
+
if (!isBool) {
|
|
2362
|
+
Util.warn(_formatValue(val) +
|
|
2363
|
+
' is a not valid value for "' +
|
|
2364
|
+
attr +
|
|
2365
|
+
'" attribute. The value should be a boolean.');
|
|
2366
|
+
}
|
|
2367
|
+
return val;
|
|
2368
|
+
};
|
|
2379
2369
|
}
|
|
2380
2370
|
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2371
|
+
function getComponentValidator(components) {
|
|
2372
|
+
if (Konva$2.isUnminified) {
|
|
2373
|
+
return function (val, attr) {
|
|
2374
|
+
// ignore validation on undefined value, because it will reset to defalt
|
|
2375
|
+
if (val === undefined || val === null) {
|
|
2376
|
+
return val;
|
|
2377
|
+
}
|
|
2378
|
+
if (!Util.isObject(val)) {
|
|
2379
|
+
Util.warn(_formatValue(val) +
|
|
2380
|
+
' is a not valid value for "' +
|
|
2381
|
+
attr +
|
|
2382
|
+
'" attribute. The value should be an object with properties ' +
|
|
2383
|
+
components);
|
|
2384
|
+
}
|
|
2385
|
+
return val;
|
|
2386
|
+
};
|
|
2387
2387
|
}
|
|
2388
2388
|
}
|
|
2389
2389
|
|
|
2390
|
-
const
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2390
|
+
const GET = 'get';
|
|
2391
|
+
const SET$1 = 'set';
|
|
2392
|
+
const Factory = {
|
|
2393
|
+
addGetterSetter(constructor, attr, def, validator, after) {
|
|
2394
|
+
Factory.addGetter(constructor, attr, def);
|
|
2395
|
+
Factory.addSetter(constructor, attr, validator, after);
|
|
2396
|
+
Factory.addOverloadedGetterSetter(constructor, attr);
|
|
2397
|
+
},
|
|
2398
|
+
addGetter(constructor, attr, def) {
|
|
2399
|
+
const method = GET + Util._capitalize(attr);
|
|
2400
|
+
constructor.prototype[method] =
|
|
2401
|
+
constructor.prototype[method] ||
|
|
2402
|
+
function () {
|
|
2403
|
+
const val = this.attrs[attr];
|
|
2404
|
+
return val === undefined ? def : val;
|
|
2405
|
+
};
|
|
2399
2406
|
},
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
node = elem.node;
|
|
2406
|
-
});
|
|
2407
|
-
return node;
|
|
2407
|
+
addSetter(constructor, attr, validator, after) {
|
|
2408
|
+
const method = SET$1 + Util._capitalize(attr);
|
|
2409
|
+
if (!constructor.prototype[method]) {
|
|
2410
|
+
Factory.overWriteSetter(constructor, attr, validator, after);
|
|
2411
|
+
}
|
|
2408
2412
|
},
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
const { node } = elem;
|
|
2415
|
-
// we need to find pointer relative to that node
|
|
2416
|
-
const stage = node.getStage();
|
|
2417
|
-
stage.setPointersPositions(evt);
|
|
2418
|
-
// it is possible that user call startDrag without any event
|
|
2419
|
-
// it that case we need to detect first movable pointer and attach it into the node
|
|
2420
|
-
if (elem.pointerId === undefined) {
|
|
2421
|
-
elem.pointerId = Util._getFirstPointerId(evt);
|
|
2422
|
-
}
|
|
2423
|
-
const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
|
|
2424
|
-
// not related pointer
|
|
2425
|
-
if (!pos) {
|
|
2426
|
-
return;
|
|
2413
|
+
overWriteSetter(constructor, attr, validator, after) {
|
|
2414
|
+
const method = SET$1 + Util._capitalize(attr);
|
|
2415
|
+
constructor.prototype[method] = function (val) {
|
|
2416
|
+
if (validator && val !== undefined && val !== null) {
|
|
2417
|
+
val = validator.call(this, val, attr);
|
|
2427
2418
|
}
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
if (distance < dragDistance) {
|
|
2432
|
-
return;
|
|
2433
|
-
}
|
|
2434
|
-
node.startDrag({ evt });
|
|
2435
|
-
// a user can stop dragging inside `dragstart`
|
|
2436
|
-
if (!node.isDragging()) {
|
|
2437
|
-
return;
|
|
2438
|
-
}
|
|
2419
|
+
this._setAttr(attr, val);
|
|
2420
|
+
if (after) {
|
|
2421
|
+
after.call(this);
|
|
2439
2422
|
}
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
});
|
|
2443
|
-
// call dragmove only after ALL positions are changed
|
|
2444
|
-
nodesToFireEvents.forEach((node) => {
|
|
2445
|
-
node.fire('dragmove', {
|
|
2446
|
-
type: 'dragmove',
|
|
2447
|
-
target: node,
|
|
2448
|
-
evt: evt,
|
|
2449
|
-
}, true);
|
|
2450
|
-
});
|
|
2423
|
+
return this;
|
|
2424
|
+
};
|
|
2451
2425
|
},
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
if (evt) {
|
|
2461
|
-
stage.setPointersPositions(evt);
|
|
2426
|
+
addComponentsGetterSetter(constructor, attr, components, validator, after) {
|
|
2427
|
+
const len = components.length, capitalize = Util._capitalize, getter = GET + capitalize(attr), setter = SET$1 + capitalize(attr);
|
|
2428
|
+
// getter
|
|
2429
|
+
constructor.prototype[getter] = function () {
|
|
2430
|
+
const ret = {};
|
|
2431
|
+
for (let n = 0; n < len; n++) {
|
|
2432
|
+
const component = components[n];
|
|
2433
|
+
ret[component] = this.getAttr(attr + capitalize(component));
|
|
2462
2434
|
}
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2435
|
+
return ret;
|
|
2436
|
+
};
|
|
2437
|
+
const basicValidator = getComponentValidator(components);
|
|
2438
|
+
// setter
|
|
2439
|
+
constructor.prototype[setter] = function (val) {
|
|
2440
|
+
const oldVal = this.attrs[attr];
|
|
2441
|
+
if (validator) {
|
|
2442
|
+
val = validator.call(this, val, attr);
|
|
2467
2443
|
}
|
|
2468
|
-
if (
|
|
2469
|
-
|
|
2470
|
-
DD.justDragged = true;
|
|
2471
|
-
Konva$2._mouseListenClick = false;
|
|
2472
|
-
Konva$2._touchListenClick = false;
|
|
2473
|
-
Konva$2._pointerListenClick = false;
|
|
2474
|
-
elem.dragStatus = 'stopped';
|
|
2444
|
+
if (basicValidator) {
|
|
2445
|
+
basicValidator.call(this, val, attr);
|
|
2475
2446
|
}
|
|
2476
|
-
const
|
|
2477
|
-
(
|
|
2478
|
-
|
|
2479
|
-
|
|
2447
|
+
for (const key in val) {
|
|
2448
|
+
if (!val.hasOwnProperty(key)) {
|
|
2449
|
+
continue;
|
|
2450
|
+
}
|
|
2451
|
+
this._setAttr(attr + capitalize(key), val[key]);
|
|
2480
2452
|
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2453
|
+
if (!val) {
|
|
2454
|
+
components.forEach((component) => {
|
|
2455
|
+
this._setAttr(attr + capitalize(component), undefined);
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
this._fireChangeEvent(attr, oldVal, val);
|
|
2459
|
+
if (after) {
|
|
2460
|
+
after.call(this);
|
|
2461
|
+
}
|
|
2462
|
+
return this;
|
|
2463
|
+
};
|
|
2464
|
+
Factory.addOverloadedGetterSetter(constructor, attr);
|
|
2488
2465
|
},
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
}, true);
|
|
2466
|
+
addOverloadedGetterSetter(constructor, attr) {
|
|
2467
|
+
const capitalizedAttr = Util._capitalize(attr), setter = SET$1 + capitalizedAttr, getter = GET + capitalizedAttr;
|
|
2468
|
+
constructor.prototype[attr] = function () {
|
|
2469
|
+
// setting
|
|
2470
|
+
if (arguments.length) {
|
|
2471
|
+
this[setter](arguments[0]);
|
|
2472
|
+
return this;
|
|
2497
2473
|
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2474
|
+
// getting
|
|
2475
|
+
return this[getter]();
|
|
2476
|
+
};
|
|
2477
|
+
},
|
|
2478
|
+
addDeprecatedGetterSetter(constructor, attr, def, validator) {
|
|
2479
|
+
Util.error('Adding deprecated ' + attr);
|
|
2480
|
+
const method = GET + Util._capitalize(attr);
|
|
2481
|
+
const message = attr +
|
|
2482
|
+
' property is deprecated and will be removed soon. Look at Konva change log for more information.';
|
|
2483
|
+
constructor.prototype[method] = function () {
|
|
2484
|
+
Util.error(message);
|
|
2485
|
+
const val = this.attrs[attr];
|
|
2486
|
+
return val === undefined ? def : val;
|
|
2487
|
+
};
|
|
2488
|
+
Factory.addSetter(constructor, attr, validator, function () {
|
|
2489
|
+
Util.error(message);
|
|
2490
|
+
});
|
|
2491
|
+
Factory.addOverloadedGetterSetter(constructor, attr);
|
|
2492
|
+
},
|
|
2493
|
+
backCompat(constructor, methods) {
|
|
2494
|
+
Util.each(methods, function (oldMethodName, newMethodName) {
|
|
2495
|
+
const method = constructor.prototype[newMethodName];
|
|
2496
|
+
const oldGetter = GET + Util._capitalize(oldMethodName);
|
|
2497
|
+
const oldSetter = SET$1 + Util._capitalize(oldMethodName);
|
|
2498
|
+
function deprecated() {
|
|
2499
|
+
method.apply(this, arguments);
|
|
2500
|
+
Util.error('"' +
|
|
2501
|
+
oldMethodName +
|
|
2502
|
+
'" method is deprecated and will be removed soon. Use ""' +
|
|
2503
|
+
newMethodName +
|
|
2504
|
+
'" instead.');
|
|
2500
2505
|
}
|
|
2506
|
+
constructor.prototype[oldMethodName] = deprecated;
|
|
2507
|
+
constructor.prototype[oldGetter] = deprecated;
|
|
2508
|
+
constructor.prototype[oldSetter] = deprecated;
|
|
2501
2509
|
});
|
|
2502
2510
|
},
|
|
2511
|
+
afterSetFilter() {
|
|
2512
|
+
this._filterUpToDate = false;
|
|
2513
|
+
},
|
|
2503
2514
|
};
|
|
2504
|
-
if (Konva$2.isBrowser) {
|
|
2505
|
-
window.addEventListener('mouseup', DD._endDragBefore, true);
|
|
2506
|
-
window.addEventListener('touchend', DD._endDragBefore, true);
|
|
2507
|
-
// add touchcancel to fix this: https://github.com/konvajs/konva/issues/1843
|
|
2508
|
-
window.addEventListener('touchcancel', DD._endDragBefore, true);
|
|
2509
|
-
window.addEventListener('mousemove', DD._drag);
|
|
2510
|
-
window.addEventListener('touchmove', DD._drag);
|
|
2511
|
-
window.addEventListener('mouseup', DD._endDragAfter, false);
|
|
2512
|
-
window.addEventListener('touchend', DD._endDragAfter, false);
|
|
2513
|
-
window.addEventListener('touchcancel', DD._endDragAfter, false);
|
|
2514
|
-
}
|
|
2515
2515
|
|
|
2516
2516
|
// CONSTANTS
|
|
2517
|
-
const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER$1 = 'mouseenter', MOUSELEAVE$1 = 'mouseleave', SET = 'set', SHAPE = 'Shape', SPACE$1 = ' ', STAGE$1 = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR$1 = [
|
|
2517
|
+
const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER$1 = 'mouseenter', MOUSELEAVE$1 = 'mouseleave', POINTERENTER$1 = 'pointerenter', POINTERLEAVE$1 = 'pointerleave', TOUCHENTER = 'touchenter', TOUCHLEAVE = 'touchleave', SET = 'set', SHAPE = 'Shape', SPACE$1 = ' ', STAGE$1 = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR$1 = [
|
|
2518
2518
|
'xChange.konva',
|
|
2519
2519
|
'yChange.konva',
|
|
2520
2520
|
'scaleXChange.konva',
|
|
@@ -2646,8 +2646,8 @@
|
|
|
2646
2646
|
*/
|
|
2647
2647
|
clearCache() {
|
|
2648
2648
|
if (this._cache.has(CANVAS)) {
|
|
2649
|
-
const { scene, filter, hit } = this._cache.get(CANVAS);
|
|
2650
|
-
Util.releaseCanvas(scene, filter, hit);
|
|
2649
|
+
const { scene, filter, hit, buffer } = this._cache.get(CANVAS);
|
|
2650
|
+
Util.releaseCanvas(scene, filter, hit, buffer);
|
|
2651
2651
|
this._cache.delete(CANVAS);
|
|
2652
2652
|
}
|
|
2653
2653
|
this._clearSelfAndDescendantCache();
|
|
@@ -2749,6 +2749,14 @@
|
|
|
2749
2749
|
width: width,
|
|
2750
2750
|
height: height,
|
|
2751
2751
|
}), sceneContext = cachedSceneCanvas.getContext(), hitContext = cachedHitCanvas.getContext();
|
|
2752
|
+
const bufferCanvas = new SceneCanvas({
|
|
2753
|
+
// width and height already multiplied by pixelRatio
|
|
2754
|
+
// so we need to revert that
|
|
2755
|
+
// also increase size by x nd y offset to make sure content fits canvas
|
|
2756
|
+
width: cachedSceneCanvas.width / cachedSceneCanvas.pixelRatio + Math.abs(x),
|
|
2757
|
+
height: cachedSceneCanvas.height / cachedSceneCanvas.pixelRatio + Math.abs(y),
|
|
2758
|
+
pixelRatio: cachedSceneCanvas.pixelRatio,
|
|
2759
|
+
}), bufferContext = bufferCanvas.getContext();
|
|
2752
2760
|
cachedHitCanvas.isCache = true;
|
|
2753
2761
|
cachedSceneCanvas.isCache = true;
|
|
2754
2762
|
this._cache.delete(CANVAS);
|
|
@@ -2759,13 +2767,20 @@
|
|
|
2759
2767
|
}
|
|
2760
2768
|
sceneContext.save();
|
|
2761
2769
|
hitContext.save();
|
|
2770
|
+
bufferContext.save();
|
|
2762
2771
|
sceneContext.translate(-x, -y);
|
|
2763
2772
|
hitContext.translate(-x, -y);
|
|
2773
|
+
bufferContext.translate(-x, -y);
|
|
2774
|
+
// hard-code offset to make sure content fits canvas
|
|
2775
|
+
// @ts-ignore
|
|
2776
|
+
bufferCanvas.x = x;
|
|
2777
|
+
// @ts-ignore
|
|
2778
|
+
bufferCanvas.y = y;
|
|
2764
2779
|
// extra flag to skip on getAbsolute opacity calc
|
|
2765
2780
|
this._isUnderCache = true;
|
|
2766
2781
|
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
|
|
2767
2782
|
this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);
|
|
2768
|
-
this.drawScene(cachedSceneCanvas, this);
|
|
2783
|
+
this.drawScene(cachedSceneCanvas, this, bufferCanvas);
|
|
2769
2784
|
this.drawHit(cachedHitCanvas, this);
|
|
2770
2785
|
this._isUnderCache = false;
|
|
2771
2786
|
sceneContext.restore();
|
|
@@ -2786,6 +2801,7 @@
|
|
|
2786
2801
|
scene: cachedSceneCanvas,
|
|
2787
2802
|
filter: cachedFilterCanvas,
|
|
2788
2803
|
hit: cachedHitCanvas,
|
|
2804
|
+
buffer: bufferCanvas,
|
|
2789
2805
|
x: x,
|
|
2790
2806
|
y: y,
|
|
2791
2807
|
});
|
|
@@ -2985,29 +3001,28 @@
|
|
|
2985
3001
|
* });
|
|
2986
3002
|
*/
|
|
2987
3003
|
on(evtStr, handler) {
|
|
2988
|
-
|
|
3004
|
+
if (this._cache) {
|
|
3005
|
+
this._cache.delete(ALL_LISTENERS);
|
|
3006
|
+
}
|
|
2989
3007
|
if (arguments.length === 3) {
|
|
2990
3008
|
return this._delegate.apply(this, arguments);
|
|
2991
3009
|
}
|
|
2992
|
-
|
|
3010
|
+
const events = evtStr.split(SPACE$1);
|
|
2993
3011
|
/*
|
|
2994
3012
|
* loop through types and attach event listeners to
|
|
2995
3013
|
* each one. eg. 'click mouseover.namespace mouseout'
|
|
2996
3014
|
* will create three event bindings
|
|
2997
3015
|
*/
|
|
2998
|
-
for (n = 0; n <
|
|
2999
|
-
event = events[n];
|
|
3000
|
-
parts = event.split('.');
|
|
3001
|
-
baseEvent = parts[0];
|
|
3002
|
-
name = parts[1] || '';
|
|
3016
|
+
for (let n = 0; n < events.length; n++) {
|
|
3017
|
+
const event = events[n];
|
|
3018
|
+
const parts = event.split('.');
|
|
3019
|
+
const baseEvent = parts[0];
|
|
3020
|
+
const name = parts[1] || '';
|
|
3003
3021
|
// create events array if it doesn't exist
|
|
3004
3022
|
if (!this.eventListeners[baseEvent]) {
|
|
3005
3023
|
this.eventListeners[baseEvent] = [];
|
|
3006
3024
|
}
|
|
3007
|
-
this.eventListeners[baseEvent].push({
|
|
3008
|
-
name: name,
|
|
3009
|
-
handler: handler,
|
|
3010
|
-
});
|
|
3025
|
+
this.eventListeners[baseEvent].push({ name, handler });
|
|
3011
3026
|
}
|
|
3012
3027
|
return this;
|
|
3013
3028
|
}
|
|
@@ -4029,7 +4044,7 @@
|
|
|
4029
4044
|
// I was trying to use attributes directly here
|
|
4030
4045
|
// but it doesn't work for Transformer well
|
|
4031
4046
|
// because it overwrite x,y getters
|
|
4032
|
-
const x = this.x(), y = this.y(), rotation = Konva$2.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !==
|
|
4047
|
+
const x = this.x(), y = this.y(), rotation = Konva$2.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
|
|
4033
4048
|
if (x !== 0 || y !== 0) {
|
|
4034
4049
|
m.translate(x, y);
|
|
4035
4050
|
}
|
|
@@ -4416,7 +4431,7 @@
|
|
|
4416
4431
|
_requestDraw() {
|
|
4417
4432
|
if (Konva$2.autoDrawEnabled) {
|
|
4418
4433
|
const drawNode = this.getLayer() || this.getStage();
|
|
4419
|
-
drawNode === null || drawNode ===
|
|
4434
|
+
drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();
|
|
4420
4435
|
}
|
|
4421
4436
|
}
|
|
4422
4437
|
_setAttr(key, val) {
|
|
@@ -4451,7 +4466,15 @@
|
|
|
4451
4466
|
if (evt && this.nodeType === SHAPE) {
|
|
4452
4467
|
evt.target = this;
|
|
4453
4468
|
}
|
|
4454
|
-
const
|
|
4469
|
+
const nonBubbling = [
|
|
4470
|
+
MOUSEENTER$1,
|
|
4471
|
+
MOUSELEAVE$1,
|
|
4472
|
+
POINTERENTER$1,
|
|
4473
|
+
POINTERLEAVE$1,
|
|
4474
|
+
TOUCHENTER,
|
|
4475
|
+
TOUCHLEAVE,
|
|
4476
|
+
];
|
|
4477
|
+
const shouldStop = nonBubbling.indexOf(eventType) !== -1 &&
|
|
4455
4478
|
((compareShape &&
|
|
4456
4479
|
(this === compareShape ||
|
|
4457
4480
|
(this.isAncestorOf && this.isAncestorOf(compareShape)))) ||
|
|
@@ -4459,7 +4482,7 @@
|
|
|
4459
4482
|
if (!shouldStop) {
|
|
4460
4483
|
this._fire(eventType, evt);
|
|
4461
4484
|
// simulate event bubbling
|
|
4462
|
-
const stopBubble = (eventType
|
|
4485
|
+
const stopBubble = nonBubbling.indexOf(eventType) !== -1 &&
|
|
4463
4486
|
compareShape &&
|
|
4464
4487
|
compareShape.isAncestorOf &&
|
|
4465
4488
|
compareShape.isAncestorOf(this) &&
|
|
@@ -4479,14 +4502,14 @@
|
|
|
4479
4502
|
}
|
|
4480
4503
|
_getProtoListeners(eventType) {
|
|
4481
4504
|
var _a, _b, _c;
|
|
4482
|
-
const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !==
|
|
4483
|
-
let events = allListeners === null || allListeners ===
|
|
4505
|
+
const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== void 0 ? _a : {};
|
|
4506
|
+
let events = allListeners === null || allListeners === void 0 ? void 0 : allListeners[eventType];
|
|
4484
4507
|
if (events === undefined) {
|
|
4485
4508
|
//recalculate cache
|
|
4486
4509
|
events = [];
|
|
4487
4510
|
let obj = Object.getPrototypeOf(this);
|
|
4488
4511
|
while (obj) {
|
|
4489
|
-
const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b ===
|
|
4512
|
+
const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === void 0 ? void 0 : _b[eventType]) !== null && _c !== void 0 ? _c : [];
|
|
4490
4513
|
events.push(...hierarchyEvents);
|
|
4491
4514
|
obj = Object.getPrototypeOf(obj);
|
|
4492
4515
|
}
|
|
@@ -4502,7 +4525,7 @@
|
|
|
4502
4525
|
evt.type = eventType;
|
|
4503
4526
|
const topListeners = this._getProtoListeners(eventType);
|
|
4504
4527
|
if (topListeners) {
|
|
4505
|
-
for (
|
|
4528
|
+
for (let i = 0; i < topListeners.length; i++) {
|
|
4506
4529
|
topListeners[i].handler.call(this, evt);
|
|
4507
4530
|
}
|
|
4508
4531
|
}
|
|
@@ -4510,7 +4533,7 @@
|
|
|
4510
4533
|
// because events can be added/removed while firing
|
|
4511
4534
|
const selfListeners = this.eventListeners[eventType];
|
|
4512
4535
|
if (selfListeners) {
|
|
4513
|
-
for (
|
|
4536
|
+
for (let i = 0; i < selfListeners.length; i++) {
|
|
4514
4537
|
selfListeners[i].handler.call(this, evt);
|
|
4515
4538
|
}
|
|
4516
4539
|
}
|
|
@@ -5331,17 +5354,11 @@
|
|
|
5331
5354
|
* });
|
|
5332
5355
|
*/
|
|
5333
5356
|
getChildren(filterFunc) {
|
|
5334
|
-
if (!filterFunc) {
|
|
5335
|
-
return this.children || [];
|
|
5336
|
-
}
|
|
5337
5357
|
const children = this.children || [];
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
}
|
|
5343
|
-
});
|
|
5344
|
-
return results;
|
|
5358
|
+
if (filterFunc) {
|
|
5359
|
+
return children.filter(filterFunc);
|
|
5360
|
+
}
|
|
5361
|
+
return children;
|
|
5345
5362
|
}
|
|
5346
5363
|
/**
|
|
5347
5364
|
* determine if node has children
|
|
@@ -5398,8 +5415,6 @@
|
|
|
5398
5415
|
* layer.add(shape1, shape2, shape3);
|
|
5399
5416
|
* // empty arrays are accepted, though each individual child must be defined
|
|
5400
5417
|
* layer.add(...shapes);
|
|
5401
|
-
* // remember to redraw layer if you changed something
|
|
5402
|
-
* layer.draw();
|
|
5403
5418
|
*/
|
|
5404
5419
|
add(...children) {
|
|
5405
5420
|
if (children.length === 0) {
|
|
@@ -5598,13 +5613,13 @@
|
|
|
5598
5613
|
if (this.isCached()) {
|
|
5599
5614
|
return;
|
|
5600
5615
|
}
|
|
5601
|
-
(_a = this.children) === null || _a ===
|
|
5616
|
+
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
|
|
5602
5617
|
node._clearSelfAndDescendantCache(attr);
|
|
5603
5618
|
});
|
|
5604
5619
|
}
|
|
5605
5620
|
_setChildrenIndices() {
|
|
5606
5621
|
var _a;
|
|
5607
|
-
(_a = this.children) === null || _a ===
|
|
5622
|
+
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
|
|
5608
5623
|
child.index = n;
|
|
5609
5624
|
});
|
|
5610
5625
|
this._requestDraw();
|
|
@@ -5675,7 +5690,7 @@
|
|
|
5675
5690
|
context.save();
|
|
5676
5691
|
context._applyGlobalCompositeOperation(this);
|
|
5677
5692
|
}
|
|
5678
|
-
(_a = this.children) === null || _a ===
|
|
5693
|
+
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
5679
5694
|
child[drawMethod](canvas, top, bufferCanvas);
|
|
5680
5695
|
});
|
|
5681
5696
|
if (hasComposition) {
|
|
@@ -5697,7 +5712,7 @@
|
|
|
5697
5712
|
height: 0,
|
|
5698
5713
|
};
|
|
5699
5714
|
const that = this;
|
|
5700
|
-
(_a = this.children) === null || _a ===
|
|
5715
|
+
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
5701
5716
|
// skip invisible children
|
|
5702
5717
|
if (!child.visible()) {
|
|
5703
5718
|
return;
|
|
@@ -5920,6 +5935,7 @@
|
|
|
5920
5935
|
[POINTERMOVE, '_pointermove'],
|
|
5921
5936
|
[POINTERUP, '_pointerup'],
|
|
5922
5937
|
[POINTERCANCEL, '_pointercancel'],
|
|
5938
|
+
[POINTERLEAVE, '_pointerleave'],
|
|
5923
5939
|
[LOSTPOINTERCAPTURE, '_lostpointercapture'],
|
|
5924
5940
|
];
|
|
5925
5941
|
const EVENTS_MAP = {
|
|
@@ -6061,12 +6077,12 @@
|
|
|
6061
6077
|
*/
|
|
6062
6078
|
setContainer(container) {
|
|
6063
6079
|
if (typeof container === STRING) {
|
|
6080
|
+
let id;
|
|
6064
6081
|
if (container.charAt(0) === '.') {
|
|
6065
6082
|
const className = container.slice(1);
|
|
6066
6083
|
container = document.getElementsByClassName(className)[0];
|
|
6067
6084
|
}
|
|
6068
6085
|
else {
|
|
6069
|
-
var id;
|
|
6070
6086
|
if (container.charAt(0) !== '#') {
|
|
6071
6087
|
id = container;
|
|
6072
6088
|
}
|
|
@@ -6900,10 +6916,16 @@
|
|
|
6900
6916
|
this.colorKey = key;
|
|
6901
6917
|
shapes[key] = this;
|
|
6902
6918
|
}
|
|
6919
|
+
/**
|
|
6920
|
+
* @deprecated
|
|
6921
|
+
*/
|
|
6903
6922
|
getContext() {
|
|
6904
6923
|
Util.warn('shape.getContext() method is deprecated. Please do not use it.');
|
|
6905
6924
|
return this.getLayer().getContext();
|
|
6906
6925
|
}
|
|
6926
|
+
/**
|
|
6927
|
+
* @deprecated
|
|
6928
|
+
*/
|
|
6907
6929
|
getCanvas() {
|
|
6908
6930
|
Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
|
|
6909
6931
|
return this.getLayer().getCanvas();
|
|
@@ -7109,7 +7131,7 @@
|
|
|
7109
7131
|
// it probably will be simpler, then copy/paste the code
|
|
7110
7132
|
var _a;
|
|
7111
7133
|
// force skip buffer canvas
|
|
7112
|
-
const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !==
|
|
7134
|
+
const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
|
|
7113
7135
|
if (!perfectDrawEnabled) {
|
|
7114
7136
|
return false;
|
|
7115
7137
|
}
|
|
@@ -7213,8 +7235,8 @@
|
|
|
7213
7235
|
// 2 - when we are caching current
|
|
7214
7236
|
// 3 - when node is cached and we need to draw it into layer
|
|
7215
7237
|
const layer = this.getLayer();
|
|
7216
|
-
|
|
7217
|
-
|
|
7238
|
+
const canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow();
|
|
7239
|
+
let stage;
|
|
7218
7240
|
const cachingSelf = top === this;
|
|
7219
7241
|
if (!this.isVisible() && !cachingSelf) {
|
|
7220
7242
|
return this;
|
|
@@ -7233,15 +7255,15 @@
|
|
|
7233
7255
|
}
|
|
7234
7256
|
context.save();
|
|
7235
7257
|
// if buffer canvas is needed
|
|
7236
|
-
if (this._useBufferCanvas() &&
|
|
7258
|
+
if (this._useBufferCanvas() && true) {
|
|
7237
7259
|
stage = this.getStage();
|
|
7238
7260
|
const bc = bufferCanvas || stage.bufferCanvas;
|
|
7239
|
-
bufferContext = bc.getContext();
|
|
7261
|
+
const bufferContext = bc.getContext();
|
|
7240
7262
|
bufferContext.clear();
|
|
7241
7263
|
bufferContext.save();
|
|
7242
7264
|
bufferContext._applyLineJoin(this);
|
|
7243
7265
|
// layer might be undefined if we are using cache before adding to layer
|
|
7244
|
-
|
|
7266
|
+
const o = this.getAbsoluteTransform(top).getMatrix();
|
|
7245
7267
|
bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
7246
7268
|
drawFunc.call(this, bufferContext, this);
|
|
7247
7269
|
bufferContext.restore();
|
|
@@ -7251,12 +7273,12 @@
|
|
|
7251
7273
|
}
|
|
7252
7274
|
context._applyOpacity(this);
|
|
7253
7275
|
context._applyGlobalCompositeOperation(this);
|
|
7254
|
-
context.drawImage(bc._canvas, 0, 0, bc.width / ratio, bc.height / ratio);
|
|
7276
|
+
context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
|
|
7255
7277
|
}
|
|
7256
7278
|
else {
|
|
7257
7279
|
context._applyLineJoin(this);
|
|
7258
7280
|
if (!cachingSelf) {
|
|
7259
|
-
|
|
7281
|
+
const o = this.getAbsoluteTransform(top).getMatrix();
|
|
7260
7282
|
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
7261
7283
|
context._applyOpacity(this);
|
|
7262
7284
|
context._applyGlobalCompositeOperation(this);
|
|
@@ -8734,7 +8756,7 @@
|
|
|
8734
8756
|
// empty pixel
|
|
8735
8757
|
return {};
|
|
8736
8758
|
}
|
|
8737
|
-
drawScene(can, top) {
|
|
8759
|
+
drawScene(can, top, bufferCanvas) {
|
|
8738
8760
|
const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
|
|
8739
8761
|
this._fire(BEFORE_DRAW, {
|
|
8740
8762
|
node: this,
|
|
@@ -8742,7 +8764,7 @@
|
|
|
8742
8764
|
if (this.clearBeforeDraw()) {
|
|
8743
8765
|
canvas.getContext().clear();
|
|
8744
8766
|
}
|
|
8745
|
-
Container.prototype.drawScene.call(this, canvas, top);
|
|
8767
|
+
Container.prototype.drawScene.call(this, canvas, top, bufferCanvas);
|
|
8746
8768
|
this._fire(DRAW, {
|
|
8747
8769
|
node: this,
|
|
8748
8770
|
});
|
|
@@ -9589,10 +9611,23 @@
|
|
|
9589
9611
|
destroy() {
|
|
9590
9612
|
const nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId];
|
|
9591
9613
|
this.pause();
|
|
9614
|
+
// Clean up animation
|
|
9615
|
+
if (this.anim) {
|
|
9616
|
+
this.anim.stop();
|
|
9617
|
+
}
|
|
9618
|
+
// Clean up tween entries
|
|
9592
9619
|
for (const key in attrs) {
|
|
9593
9620
|
delete Tween.tweens[nodeId][key];
|
|
9594
9621
|
}
|
|
9622
|
+
// Clean up attrs entry
|
|
9595
9623
|
delete Tween.attrs[nodeId][thisId];
|
|
9624
|
+
// Clean up parent objects if empty
|
|
9625
|
+
if (Object.keys(Tween.tweens[nodeId]).length === 0) {
|
|
9626
|
+
delete Tween.tweens[nodeId];
|
|
9627
|
+
}
|
|
9628
|
+
if (Object.keys(Tween.attrs[nodeId]).length === 0) {
|
|
9629
|
+
delete Tween.attrs[nodeId];
|
|
9630
|
+
}
|
|
9596
9631
|
}
|
|
9597
9632
|
}
|
|
9598
9633
|
Tween.attrs = {};
|
|
@@ -10212,16 +10247,17 @@
|
|
|
10212
10247
|
});
|
|
10213
10248
|
}
|
|
10214
10249
|
_sceneFunc(context) {
|
|
10215
|
-
|
|
10250
|
+
const points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier();
|
|
10216
10251
|
if (!length) {
|
|
10217
10252
|
return;
|
|
10218
10253
|
}
|
|
10254
|
+
let n = 0;
|
|
10219
10255
|
context.beginPath();
|
|
10220
10256
|
context.moveTo(points[0], points[1]);
|
|
10221
10257
|
// tension
|
|
10222
10258
|
if (tension !== 0 && length > 4) {
|
|
10223
|
-
tp = this.getTensionPoints();
|
|
10224
|
-
len = tp.length;
|
|
10259
|
+
const tp = this.getTensionPoints();
|
|
10260
|
+
const len = tp.length;
|
|
10225
10261
|
n = closed ? 0 : 4;
|
|
10226
10262
|
if (!closed) {
|
|
10227
10263
|
context.quadraticCurveTo(tp[0], tp[1], tp[2], tp[3]);
|
|
@@ -11328,10 +11364,10 @@
|
|
|
11328
11364
|
context.quadraticCurveTo(p[0], p[1], p[2], p[3]);
|
|
11329
11365
|
break;
|
|
11330
11366
|
case 'A':
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11367
|
+
const cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];
|
|
11368
|
+
const r = rx > ry ? rx : ry;
|
|
11369
|
+
const scaleX = rx > ry ? 1 : rx / ry;
|
|
11370
|
+
const scaleY = rx > ry ? ry / rx : 1;
|
|
11335
11371
|
context.translate(cx, cy);
|
|
11336
11372
|
context.rotate(psi);
|
|
11337
11373
|
context.scale(scaleX, scaleY);
|
|
@@ -11470,11 +11506,20 @@
|
|
|
11470
11506
|
};
|
|
11471
11507
|
}
|
|
11472
11508
|
if (length < 0.01) {
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11509
|
+
const cmd = dataArray[i].command;
|
|
11510
|
+
if (cmd === 'M') {
|
|
11511
|
+
points = dataArray[i].points.slice(0, 2);
|
|
11512
|
+
return {
|
|
11513
|
+
x: points[0],
|
|
11514
|
+
y: points[1],
|
|
11515
|
+
};
|
|
11516
|
+
}
|
|
11517
|
+
else {
|
|
11518
|
+
return {
|
|
11519
|
+
x: dataArray[i].start.x,
|
|
11520
|
+
y: dataArray[i].start.y,
|
|
11521
|
+
};
|
|
11522
|
+
}
|
|
11478
11523
|
}
|
|
11479
11524
|
const cp = dataArray[i];
|
|
11480
11525
|
const p = cp.points;
|
|
@@ -11490,15 +11535,16 @@
|
|
|
11490
11535
|
return getQuadraticArcLength([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);
|
|
11491
11536
|
}), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);
|
|
11492
11537
|
case 'A':
|
|
11493
|
-
|
|
11538
|
+
const cx = p[0], cy = p[1], rx = p[2], ry = p[3], dTheta = p[5], psi = p[6];
|
|
11539
|
+
let theta = p[4];
|
|
11494
11540
|
theta += (dTheta * length) / cp.pathLength;
|
|
11495
11541
|
return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);
|
|
11496
11542
|
}
|
|
11497
11543
|
return null;
|
|
11498
11544
|
}
|
|
11499
11545
|
static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
|
|
11500
|
-
fromX = fromX !== null && fromX !==
|
|
11501
|
-
fromY = fromY !== null && fromY !==
|
|
11546
|
+
fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;
|
|
11547
|
+
fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;
|
|
11502
11548
|
const len = this.getLineLength(P1x, P1y, P2x, P2y);
|
|
11503
11549
|
if (len < 1e-10) {
|
|
11504
11550
|
return { x: P1x, y: P1y };
|
|
@@ -11537,10 +11583,7 @@
|
|
|
11537
11583
|
}
|
|
11538
11584
|
const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
|
|
11539
11585
|
const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
|
|
11540
|
-
return {
|
|
11541
|
-
x: x,
|
|
11542
|
-
y: y,
|
|
11543
|
-
};
|
|
11586
|
+
return { x, y };
|
|
11544
11587
|
}
|
|
11545
11588
|
static getPointOnQuadraticBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y) {
|
|
11546
11589
|
function QB1(t) {
|
|
@@ -11554,10 +11597,7 @@
|
|
|
11554
11597
|
}
|
|
11555
11598
|
const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
|
|
11556
11599
|
const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
|
|
11557
|
-
return {
|
|
11558
|
-
x: x,
|
|
11559
|
-
y: y,
|
|
11560
|
-
};
|
|
11600
|
+
return { x, y };
|
|
11561
11601
|
}
|
|
11562
11602
|
static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {
|
|
11563
11603
|
const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
|
|
@@ -11630,7 +11670,7 @@
|
|
|
11630
11670
|
// convert white spaces to commas
|
|
11631
11671
|
cs = cs.replace(new RegExp(' ', 'g'), ',');
|
|
11632
11672
|
// create pipes so that we can split the data
|
|
11633
|
-
for (
|
|
11673
|
+
for (let n = 0; n < cc.length; n++) {
|
|
11634
11674
|
cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
|
|
11635
11675
|
}
|
|
11636
11676
|
// create array
|
|
@@ -11642,7 +11682,7 @@
|
|
|
11642
11682
|
let cpy = 0;
|
|
11643
11683
|
const re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
|
|
11644
11684
|
let match;
|
|
11645
|
-
for (n = 1; n < arr.length; n++) {
|
|
11685
|
+
for (let n = 1; n < arr.length; n++) {
|
|
11646
11686
|
let str = arr[n];
|
|
11647
11687
|
let c = str.charAt(0);
|
|
11648
11688
|
str = str.slice(1);
|
|
@@ -11677,8 +11717,8 @@
|
|
|
11677
11717
|
let points = [];
|
|
11678
11718
|
const startX = cpx, startY = cpy;
|
|
11679
11719
|
// Move var from within the switch to up here (jshint)
|
|
11680
|
-
|
|
11681
|
-
|
|
11720
|
+
let prevCmd, ctlPtx, ctlPty; // Ss, Tt
|
|
11721
|
+
let rx, ry, psi, fa, fs, x1, y1; // Aa
|
|
11682
11722
|
// convert l, H, h, V, and v to L
|
|
11683
11723
|
switch (c) {
|
|
11684
11724
|
// Note: Keep the lineTo's above the moveTo's in this switch
|
|
@@ -11695,8 +11735,8 @@
|
|
|
11695
11735
|
break;
|
|
11696
11736
|
// Note: lineTo handlers need to be above this point
|
|
11697
11737
|
case 'm':
|
|
11698
|
-
|
|
11699
|
-
|
|
11738
|
+
const dx = p.shift();
|
|
11739
|
+
const dy = p.shift();
|
|
11700
11740
|
cpx += dx;
|
|
11701
11741
|
cpy += dy;
|
|
11702
11742
|
cmd = 'M';
|
|
@@ -11884,12 +11924,12 @@
|
|
|
11884
11924
|
case 'A':
|
|
11885
11925
|
// Approximates by breaking curve into line segments
|
|
11886
11926
|
len = 0.0;
|
|
11887
|
-
|
|
11927
|
+
const start = points[4];
|
|
11888
11928
|
// 4 = theta
|
|
11889
|
-
|
|
11929
|
+
const dTheta = points[5];
|
|
11890
11930
|
// 5 = dTheta
|
|
11891
|
-
|
|
11892
|
-
|
|
11931
|
+
const end = points[4] + dTheta;
|
|
11932
|
+
let inc = Math.PI / 180.0;
|
|
11893
11933
|
// 1 degree resolution
|
|
11894
11934
|
if (Math.abs(start - end) < inc) {
|
|
11895
11935
|
inc = Math.abs(start - end);
|
|
@@ -12737,11 +12777,11 @@
|
|
|
12737
12777
|
}
|
|
12738
12778
|
getWidth() {
|
|
12739
12779
|
var _a, _b;
|
|
12740
|
-
return (_a = this.attrs.width) !== null && _a !==
|
|
12780
|
+
return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
|
|
12741
12781
|
}
|
|
12742
12782
|
getHeight() {
|
|
12743
12783
|
var _a, _b;
|
|
12744
|
-
return (_a = this.attrs.height) !== null && _a !==
|
|
12784
|
+
return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
|
|
12745
12785
|
}
|
|
12746
12786
|
/**
|
|
12747
12787
|
* load image from given url and create `Konva.Image` instance
|
|
@@ -12754,7 +12794,6 @@
|
|
|
12754
12794
|
* Konva.Image.fromURL(imageURL, function(image){
|
|
12755
12795
|
* // image is Konva.Image instance
|
|
12756
12796
|
* layer.add(image);
|
|
12757
|
-
* layer.draw();
|
|
12758
12797
|
* });
|
|
12759
12798
|
*/
|
|
12760
12799
|
static fromURL(url, callback, onError = null) {
|
|
@@ -14279,7 +14318,7 @@
|
|
|
14279
14318
|
* @param {String} [config.fontVariant] can be normal or small-caps. Default is normal
|
|
14280
14319
|
* @param {String} [config.textDecoration] can be line-through, underline or empty string. Default is empty string.
|
|
14281
14320
|
* @param {String} config.text
|
|
14282
|
-
* @param {String} [config.align] can be left, center, or
|
|
14321
|
+
* @param {String} [config.align] can be left, center, right or justify
|
|
14283
14322
|
* @param {String} [config.verticalAlign] can be top, middle or bottom
|
|
14284
14323
|
* @param {Number} [config.padding]
|
|
14285
14324
|
* @param {Number} [config.lineHeight] default is 1
|
|
@@ -14396,8 +14435,6 @@
|
|
|
14396
14435
|
(metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
|
|
14397
14436
|
lineHeightPx / 2;
|
|
14398
14437
|
}
|
|
14399
|
-
var lineTranslateX = 0;
|
|
14400
|
-
var lineTranslateY = 0;
|
|
14401
14438
|
if (direction === RTL) {
|
|
14402
14439
|
context.setAttr('direction', direction);
|
|
14403
14440
|
}
|
|
@@ -14414,9 +14451,9 @@
|
|
|
14414
14451
|
context.translate(padding, alignY + padding);
|
|
14415
14452
|
// draw text lines
|
|
14416
14453
|
for (n = 0; n < textArrLen; n++) {
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14454
|
+
let lineTranslateX = 0;
|
|
14455
|
+
let lineTranslateY = 0;
|
|
14456
|
+
const obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph;
|
|
14420
14457
|
// horizontal alignment
|
|
14421
14458
|
context.save();
|
|
14422
14459
|
if (align === RIGHT) {
|
|
@@ -14434,9 +14471,7 @@
|
|
|
14434
14471
|
const x = lineTranslateX;
|
|
14435
14472
|
const y = translateY + lineTranslateY + yOffset;
|
|
14436
14473
|
context.moveTo(x, y);
|
|
14437
|
-
|
|
14438
|
-
lineWidth =
|
|
14439
|
-
align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
|
|
14474
|
+
const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
|
|
14440
14475
|
context.lineTo(x + Math.round(lineWidth), y);
|
|
14441
14476
|
// I have no idea what is real ratio
|
|
14442
14477
|
// just /15 looks good enough
|
|
@@ -14451,9 +14486,7 @@
|
|
|
14451
14486
|
context.beginPath();
|
|
14452
14487
|
const yOffset = Konva$2._fixTextRendering ? -Math.round(fontSize / 4) : 0;
|
|
14453
14488
|
context.moveTo(lineTranslateX, translateY + lineTranslateY + yOffset);
|
|
14454
|
-
|
|
14455
|
-
lineWidth =
|
|
14456
|
-
align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
|
|
14489
|
+
const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
|
|
14457
14490
|
context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
|
|
14458
14491
|
context.lineWidth = fontSize / 15;
|
|
14459
14492
|
const gradient = this._getLinearGradient();
|
|
@@ -14466,7 +14499,7 @@
|
|
|
14466
14499
|
// be supported otherwise.
|
|
14467
14500
|
if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) {
|
|
14468
14501
|
// var words = text.split(' ');
|
|
14469
|
-
spacesNumber = text.split(' ').length - 1;
|
|
14502
|
+
const spacesNumber = text.split(' ').length - 1;
|
|
14470
14503
|
const array = stringToArray(text);
|
|
14471
14504
|
for (let li = 0; li < array.length; li++) {
|
|
14472
14505
|
const letter = array[li];
|
|
@@ -14559,17 +14592,17 @@
|
|
|
14559
14592
|
const scaleFactor = fontSize / 100;
|
|
14560
14593
|
// Note, fallback values are from chrome browser with 100px font size and font-family "Arial"
|
|
14561
14594
|
return {
|
|
14562
|
-
actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !==
|
|
14563
|
-
actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !==
|
|
14564
|
-
actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !==
|
|
14565
|
-
actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !==
|
|
14566
|
-
alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !==
|
|
14567
|
-
emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !==
|
|
14568
|
-
emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !==
|
|
14569
|
-
fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !==
|
|
14570
|
-
fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !==
|
|
14571
|
-
hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !==
|
|
14572
|
-
ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !==
|
|
14595
|
+
actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== void 0 ? _a : 71.58203125 * scaleFactor,
|
|
14596
|
+
actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== void 0 ? _b : 0, // Remains zero as there is no descent in the provided metrics
|
|
14597
|
+
actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== void 0 ? _c : -7.421875 * scaleFactor,
|
|
14598
|
+
actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== void 0 ? _d : 75.732421875 * scaleFactor,
|
|
14599
|
+
alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== void 0 ? _e : 0, // Remains zero as it's typically relative to the baseline itself
|
|
14600
|
+
emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== void 0 ? _f : 100 * scaleFactor,
|
|
14601
|
+
emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== void 0 ? _g : -20 * scaleFactor,
|
|
14602
|
+
fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== void 0 ? _h : 91 * scaleFactor,
|
|
14603
|
+
fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== void 0 ? _j : 21 * scaleFactor,
|
|
14604
|
+
hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== void 0 ? _k : 72.80000305175781 * scaleFactor,
|
|
14605
|
+
ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== void 0 ? _l : -21 * scaleFactor,
|
|
14573
14606
|
width: metrics.width,
|
|
14574
14607
|
height: fontSize, // Typically set to the font size
|
|
14575
14608
|
};
|
|
@@ -14629,11 +14662,19 @@
|
|
|
14629
14662
|
while (low < high) {
|
|
14630
14663
|
const mid = (low + high) >>> 1,
|
|
14631
14664
|
// Convert array indices to string
|
|
14632
|
-
lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr)
|
|
14633
|
-
|
|
14665
|
+
lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr);
|
|
14666
|
+
// Only add ellipsis width when we need to consider truncation
|
|
14667
|
+
// for the current line (when it might be the last visible line)
|
|
14668
|
+
const shouldConsiderEllipsis = shouldAddEllipsis &&
|
|
14669
|
+
fixedHeight &&
|
|
14670
|
+
currentHeightPx + lineHeightPx > maxHeightPx;
|
|
14671
|
+
const effectiveWidth = shouldConsiderEllipsis
|
|
14672
|
+
? substrWidth + additionalWidth
|
|
14673
|
+
: substrWidth;
|
|
14674
|
+
if (effectiveWidth <= maxWidth) {
|
|
14634
14675
|
low = mid + 1;
|
|
14635
14676
|
match = substr;
|
|
14636
|
-
matchWidth = substrWidth;
|
|
14677
|
+
matchWidth = substrWidth; // Store actual text width without ellipsis
|
|
14637
14678
|
}
|
|
14638
14679
|
else {
|
|
14639
14680
|
high = mid;
|
|
@@ -14915,6 +14956,8 @@
|
|
|
14915
14956
|
*
|
|
14916
14957
|
* // align text to right
|
|
14917
14958
|
* text.align('right');
|
|
14959
|
+
*
|
|
14960
|
+
* // justify text
|
|
14918
14961
|
*/
|
|
14919
14962
|
Factory.addGetterSetter(Text, 'align', LEFT);
|
|
14920
14963
|
/**
|
|
@@ -16170,10 +16213,10 @@
|
|
|
16170
16213
|
else {
|
|
16171
16214
|
keepProportion = this.keepRatio() || e.shiftKey;
|
|
16172
16215
|
}
|
|
16173
|
-
|
|
16216
|
+
let centeredScaling = this.centeredScaling() || e.altKey;
|
|
16174
16217
|
if (this._movingAnchorName === 'top-left') {
|
|
16175
16218
|
if (keepProportion) {
|
|
16176
|
-
|
|
16219
|
+
const comparePoint = centeredScaling
|
|
16177
16220
|
? {
|
|
16178
16221
|
x: this.width() / 2,
|
|
16179
16222
|
y: this.height() / 2,
|
|
@@ -16184,8 +16227,8 @@
|
|
|
16184
16227
|
};
|
|
16185
16228
|
newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
|
|
16186
16229
|
Math.pow(comparePoint.y - anchorNode.y(), 2));
|
|
16187
|
-
|
|
16188
|
-
|
|
16230
|
+
const reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;
|
|
16231
|
+
const reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;
|
|
16189
16232
|
x = newHypotenuse * this.cos * reverseX;
|
|
16190
16233
|
y = newHypotenuse * this.sin * reverseY;
|
|
16191
16234
|
this.findOne('.top-left').x(comparePoint.x - x);
|
|
@@ -16197,7 +16240,7 @@
|
|
|
16197
16240
|
}
|
|
16198
16241
|
else if (this._movingAnchorName === 'top-right') {
|
|
16199
16242
|
if (keepProportion) {
|
|
16200
|
-
|
|
16243
|
+
const comparePoint = centeredScaling
|
|
16201
16244
|
? {
|
|
16202
16245
|
x: this.width() / 2,
|
|
16203
16246
|
y: this.height() / 2,
|
|
@@ -16208,8 +16251,8 @@
|
|
|
16208
16251
|
};
|
|
16209
16252
|
newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
|
|
16210
16253
|
Math.pow(comparePoint.y - anchorNode.y(), 2));
|
|
16211
|
-
|
|
16212
|
-
|
|
16254
|
+
const reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;
|
|
16255
|
+
const reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;
|
|
16213
16256
|
x = newHypotenuse * this.cos * reverseX;
|
|
16214
16257
|
y = newHypotenuse * this.sin * reverseY;
|
|
16215
16258
|
this.findOne('.top-right').x(comparePoint.x + x);
|
|
@@ -16227,7 +16270,7 @@
|
|
|
16227
16270
|
}
|
|
16228
16271
|
else if (this._movingAnchorName === 'bottom-left') {
|
|
16229
16272
|
if (keepProportion) {
|
|
16230
|
-
|
|
16273
|
+
const comparePoint = centeredScaling
|
|
16231
16274
|
? {
|
|
16232
16275
|
x: this.width() / 2,
|
|
16233
16276
|
y: this.height() / 2,
|
|
@@ -16238,8 +16281,8 @@
|
|
|
16238
16281
|
};
|
|
16239
16282
|
newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
|
|
16240
16283
|
Math.pow(anchorNode.y() - comparePoint.y, 2));
|
|
16241
|
-
|
|
16242
|
-
|
|
16284
|
+
const reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;
|
|
16285
|
+
const reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;
|
|
16243
16286
|
x = newHypotenuse * this.cos * reverseX;
|
|
16244
16287
|
y = newHypotenuse * this.sin * reverseY;
|
|
16245
16288
|
anchorNode.x(comparePoint.x - x);
|
|
@@ -16254,7 +16297,7 @@
|
|
|
16254
16297
|
}
|
|
16255
16298
|
else if (this._movingAnchorName === 'bottom-right') {
|
|
16256
16299
|
if (keepProportion) {
|
|
16257
|
-
|
|
16300
|
+
const comparePoint = centeredScaling
|
|
16258
16301
|
? {
|
|
16259
16302
|
x: this.width() / 2,
|
|
16260
16303
|
y: this.height() / 2,
|
|
@@ -16265,8 +16308,8 @@
|
|
|
16265
16308
|
};
|
|
16266
16309
|
newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
|
|
16267
16310
|
Math.pow(anchorNode.y() - comparePoint.y, 2));
|
|
16268
|
-
|
|
16269
|
-
|
|
16311
|
+
const reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;
|
|
16312
|
+
const reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;
|
|
16270
16313
|
x = newHypotenuse * this.cos * reverseX;
|
|
16271
16314
|
y = newHypotenuse * this.sin * reverseY;
|
|
16272
16315
|
this.findOne('.bottom-right').x(comparePoint.x + x);
|
|
@@ -16277,7 +16320,7 @@
|
|
|
16277
16320
|
console.error(new Error('Wrong position argument of selection resizer: ' +
|
|
16278
16321
|
this._movingAnchorName));
|
|
16279
16322
|
}
|
|
16280
|
-
|
|
16323
|
+
centeredScaling = this.centeredScaling() || e.altKey;
|
|
16281
16324
|
if (centeredScaling) {
|
|
16282
16325
|
const topLeft = this.findOne('.top-left');
|
|
16283
16326
|
const bottomRight = this.findOne('.bottom-right');
|
|
@@ -16327,13 +16370,13 @@
|
|
|
16327
16370
|
activeTransformersCount--;
|
|
16328
16371
|
this._fire('transformend', { evt: e, target: node });
|
|
16329
16372
|
// redraw layer to restore hit graph
|
|
16330
|
-
(_a = this.getLayer()) === null || _a ===
|
|
16373
|
+
(_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
|
|
16331
16374
|
if (node) {
|
|
16332
16375
|
this._nodes.forEach((target) => {
|
|
16333
16376
|
var _a;
|
|
16334
16377
|
target._fire('transformend', { evt: e, target });
|
|
16335
16378
|
// redraw layer to restore hit graph
|
|
16336
|
-
(_a = target.getLayer()) === null || _a ===
|
|
16379
|
+
(_a = target.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
|
|
16337
16380
|
});
|
|
16338
16381
|
}
|
|
16339
16382
|
this._movingAnchorName = null;
|
|
@@ -16462,7 +16505,7 @@
|
|
|
16462
16505
|
.multiply(localTransform);
|
|
16463
16506
|
const attrs = newLocalTransform.decompose();
|
|
16464
16507
|
node.setAttrs(attrs);
|
|
16465
|
-
(_a = node.getLayer()) === null || _a ===
|
|
16508
|
+
(_a = node.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
|
|
16466
16509
|
});
|
|
16467
16510
|
this.rotation(Util._getRotation(newAttrs.rotation));
|
|
16468
16511
|
// trigger transform event AFTER we update rotation
|
|
@@ -16584,7 +16627,7 @@
|
|
|
16584
16627
|
styleFunc(node);
|
|
16585
16628
|
});
|
|
16586
16629
|
}
|
|
16587
|
-
(_a = this.getLayer()) === null || _a ===
|
|
16630
|
+
(_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
|
|
16588
16631
|
}
|
|
16589
16632
|
/**
|
|
16590
16633
|
* determine if transformer is in active transform
|
|
@@ -17363,10 +17406,10 @@
|
|
|
17363
17406
|
];
|
|
17364
17407
|
function filterGaussBlurRGBA(imageData, radius) {
|
|
17365
17408
|
const pixels = imageData.data, width = imageData.width, height = imageData.height;
|
|
17366
|
-
let
|
|
17409
|
+
let p, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
|
|
17367
17410
|
const div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), mul_sum = mul_table[radius], shg_sum = shg_table[radius];
|
|
17368
17411
|
let stackEnd = null, stack = stackStart, stackIn = null, stackOut = null;
|
|
17369
|
-
for (i = 1; i < div; i++) {
|
|
17412
|
+
for (let i = 1; i < div; i++) {
|
|
17370
17413
|
stack = stack.next = new BlurStack();
|
|
17371
17414
|
if (i === radiusPlus1) {
|
|
17372
17415
|
stackEnd = stack;
|
|
@@ -17374,7 +17417,7 @@
|
|
|
17374
17417
|
}
|
|
17375
17418
|
stack.next = stackStart;
|
|
17376
17419
|
yw = yi = 0;
|
|
17377
|
-
for (y = 0; y < height; y++) {
|
|
17420
|
+
for (let y = 0; y < height; y++) {
|
|
17378
17421
|
r_in_sum =
|
|
17379
17422
|
g_in_sum =
|
|
17380
17423
|
b_in_sum =
|
|
@@ -17393,14 +17436,14 @@
|
|
|
17393
17436
|
b_sum += sumFactor * pb;
|
|
17394
17437
|
a_sum += sumFactor * pa;
|
|
17395
17438
|
stack = stackStart;
|
|
17396
|
-
for (i = 0; i < radiusPlus1; i++) {
|
|
17439
|
+
for (let i = 0; i < radiusPlus1; i++) {
|
|
17397
17440
|
stack.r = pr;
|
|
17398
17441
|
stack.g = pg;
|
|
17399
17442
|
stack.b = pb;
|
|
17400
17443
|
stack.a = pa;
|
|
17401
17444
|
stack = stack.next;
|
|
17402
17445
|
}
|
|
17403
|
-
for (i = 1; i < radiusPlus1; i++) {
|
|
17446
|
+
for (let i = 1; i < radiusPlus1; i++) {
|
|
17404
17447
|
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
|
17405
17448
|
r_sum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
|
|
17406
17449
|
g_sum += (stack.g = pg = pixels[p + 1]) * rbs;
|
|
@@ -17414,7 +17457,7 @@
|
|
|
17414
17457
|
}
|
|
17415
17458
|
stackIn = stackStart;
|
|
17416
17459
|
stackOut = stackEnd;
|
|
17417
|
-
for (x = 0; x < width; x++) {
|
|
17460
|
+
for (let x = 0; x < width; x++) {
|
|
17418
17461
|
pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
|
|
17419
17462
|
if (pa !== 0) {
|
|
17420
17463
|
pa = 255 / pa;
|
|
@@ -17456,7 +17499,7 @@
|
|
|
17456
17499
|
}
|
|
17457
17500
|
yw += width;
|
|
17458
17501
|
}
|
|
17459
|
-
for (x = 0; x < width; x++) {
|
|
17502
|
+
for (let x = 0; x < width; x++) {
|
|
17460
17503
|
g_in_sum =
|
|
17461
17504
|
b_in_sum =
|
|
17462
17505
|
a_in_sum =
|
|
@@ -17476,15 +17519,15 @@
|
|
|
17476
17519
|
b_sum += sumFactor * pb;
|
|
17477
17520
|
a_sum += sumFactor * pa;
|
|
17478
17521
|
stack = stackStart;
|
|
17479
|
-
for (i = 0; i < radiusPlus1; i++) {
|
|
17522
|
+
for (let i = 0; i < radiusPlus1; i++) {
|
|
17480
17523
|
stack.r = pr;
|
|
17481
17524
|
stack.g = pg;
|
|
17482
17525
|
stack.b = pb;
|
|
17483
17526
|
stack.a = pa;
|
|
17484
17527
|
stack = stack.next;
|
|
17485
17528
|
}
|
|
17486
|
-
yp = width;
|
|
17487
|
-
for (i = 1; i <= radius; i++) {
|
|
17529
|
+
let yp = width;
|
|
17530
|
+
for (let i = 1; i <= radius; i++) {
|
|
17488
17531
|
yi = (yp + x) << 2;
|
|
17489
17532
|
r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
|
|
17490
17533
|
g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;
|
|
@@ -17502,7 +17545,7 @@
|
|
|
17502
17545
|
yi = x;
|
|
17503
17546
|
stackIn = stackStart;
|
|
17504
17547
|
stackOut = stackEnd;
|
|
17505
|
-
for (y = 0; y < height; y++) {
|
|
17548
|
+
for (let y = 0; y < height; y++) {
|
|
17506
17549
|
p = yi << 2;
|
|
17507
17550
|
pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
|
|
17508
17551
|
if (pa > 0) {
|
|
@@ -17882,7 +17925,7 @@
|
|
|
17882
17925
|
bMax = 255;
|
|
17883
17926
|
bMin = 0;
|
|
17884
17927
|
}
|
|
17885
|
-
let
|
|
17928
|
+
let rGoalMax, rGoalMin, gGoalMax, gGoalMin, bGoalMax, bGoalMin;
|
|
17886
17929
|
// If the enhancement is positive - stretch the histogram
|
|
17887
17930
|
if (enhanceAmount > 0) {
|
|
17888
17931
|
rGoalMax = rMax + enhanceAmount * (255 - rMax);
|
|
@@ -17894,13 +17937,13 @@
|
|
|
17894
17937
|
// If the enhancement is negative - compress the histogram
|
|
17895
17938
|
}
|
|
17896
17939
|
else {
|
|
17897
|
-
rMid = (rMax + rMin) * 0.5;
|
|
17940
|
+
const rMid = (rMax + rMin) * 0.5;
|
|
17898
17941
|
rGoalMax = rMax + enhanceAmount * (rMax - rMid);
|
|
17899
17942
|
rGoalMin = rMin + enhanceAmount * (rMin - rMid);
|
|
17900
|
-
gMid = (gMax + gMin) * 0.5;
|
|
17943
|
+
const gMid = (gMax + gMin) * 0.5;
|
|
17901
17944
|
gGoalMax = gMax + enhanceAmount * (gMax - gMid);
|
|
17902
17945
|
gGoalMin = gMin + enhanceAmount * (gMin - gMid);
|
|
17903
|
-
bMid = (bMax + bMin) * 0.5;
|
|
17946
|
+
const bMid = (bMax + bMin) * 0.5;
|
|
17904
17947
|
bGoalMax = bMax + enhanceAmount * (bMax - bMid);
|
|
17905
17948
|
bGoalMin = bMin + enhanceAmount * (bMin - bMid);
|
|
17906
17949
|
}
|
|
@@ -18037,12 +18080,11 @@
|
|
|
18037
18080
|
const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
|
|
18038
18081
|
const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
|
|
18039
18082
|
const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
|
|
18040
|
-
let r, g, b, a;
|
|
18041
18083
|
for (let i = 0; i < nPixels; i += 4) {
|
|
18042
|
-
r = data[i + 0];
|
|
18043
|
-
g = data[i + 1];
|
|
18044
|
-
b = data[i + 2];
|
|
18045
|
-
a = data[i + 3];
|
|
18084
|
+
const r = data[i + 0];
|
|
18085
|
+
const g = data[i + 1];
|
|
18086
|
+
const b = data[i + 2];
|
|
18087
|
+
const a = data[i + 3];
|
|
18046
18088
|
data[i + 0] = rr * r + rg * g + rb * b;
|
|
18047
18089
|
data[i + 1] = gr * r + gg * g + gb * b;
|
|
18048
18090
|
data[i + 2] = br * r + bg * g + bb * b;
|
|
@@ -18289,7 +18331,7 @@
|
|
|
18289
18331
|
}
|
|
18290
18332
|
}
|
|
18291
18333
|
// Convert back from polar coordinates
|
|
18292
|
-
FromPolar(scratchData, imageData, {
|
|
18334
|
+
FromPolar(scratchData, imageData, { });
|
|
18293
18335
|
};
|
|
18294
18336
|
/**
|
|
18295
18337
|
* get/set kaleidoscope power. Use with {@link Konva.Filters.Kaleidoscope} filter.
|
|
@@ -18508,36 +18550,36 @@
|
|
|
18508
18550
|
* node.pixelSize(10);
|
|
18509
18551
|
*/
|
|
18510
18552
|
const Pixelate = function (imageData) {
|
|
18511
|
-
let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height,
|
|
18553
|
+
let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height,
|
|
18512
18554
|
//pixelsPerBin = pixelSize * pixelSize,
|
|
18513
|
-
|
|
18555
|
+
nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), data = imageData.data;
|
|
18514
18556
|
if (pixelSize <= 0) {
|
|
18515
18557
|
Util.error('pixelSize value can not be <= 0');
|
|
18516
18558
|
return;
|
|
18517
18559
|
}
|
|
18518
|
-
for (xBin = 0; xBin < nBinsX; xBin += 1) {
|
|
18519
|
-
for (yBin = 0; yBin < nBinsY; yBin += 1) {
|
|
18560
|
+
for (let xBin = 0; xBin < nBinsX; xBin += 1) {
|
|
18561
|
+
for (let yBin = 0; yBin < nBinsY; yBin += 1) {
|
|
18520
18562
|
// Initialize the color accumlators to 0
|
|
18521
|
-
red = 0;
|
|
18522
|
-
green = 0;
|
|
18523
|
-
blue = 0;
|
|
18524
|
-
alpha = 0;
|
|
18563
|
+
let red = 0;
|
|
18564
|
+
let green = 0;
|
|
18565
|
+
let blue = 0;
|
|
18566
|
+
let alpha = 0;
|
|
18525
18567
|
// Determine which pixels are included in this bin
|
|
18526
|
-
xBinStart = xBin * pixelSize;
|
|
18527
|
-
xBinEnd = xBinStart + pixelSize;
|
|
18528
|
-
yBinStart = yBin * pixelSize;
|
|
18529
|
-
yBinEnd = yBinStart + pixelSize;
|
|
18568
|
+
const xBinStart = xBin * pixelSize;
|
|
18569
|
+
const xBinEnd = xBinStart + pixelSize;
|
|
18570
|
+
const yBinStart = yBin * pixelSize;
|
|
18571
|
+
const yBinEnd = yBinStart + pixelSize;
|
|
18530
18572
|
// Add all of the pixels to this bin!
|
|
18531
|
-
pixelsInBin = 0;
|
|
18532
|
-
for (x = xBinStart; x < xBinEnd; x += 1) {
|
|
18573
|
+
let pixelsInBin = 0;
|
|
18574
|
+
for (let x = xBinStart; x < xBinEnd; x += 1) {
|
|
18533
18575
|
if (x >= width) {
|
|
18534
18576
|
continue;
|
|
18535
18577
|
}
|
|
18536
|
-
for (y = yBinStart; y < yBinEnd; y += 1) {
|
|
18578
|
+
for (let y = yBinStart; y < yBinEnd; y += 1) {
|
|
18537
18579
|
if (y >= height) {
|
|
18538
18580
|
continue;
|
|
18539
18581
|
}
|
|
18540
|
-
i = (width * y + x) * 4;
|
|
18582
|
+
const i = (width * y + x) * 4;
|
|
18541
18583
|
red += data[i + 0];
|
|
18542
18584
|
green += data[i + 1];
|
|
18543
18585
|
blue += data[i + 2];
|
|
@@ -18551,15 +18593,15 @@
|
|
|
18551
18593
|
blue = blue / pixelsInBin;
|
|
18552
18594
|
alpha = alpha / pixelsInBin;
|
|
18553
18595
|
// Draw this bin
|
|
18554
|
-
for (x = xBinStart; x < xBinEnd; x += 1) {
|
|
18596
|
+
for (let x = xBinStart; x < xBinEnd; x += 1) {
|
|
18555
18597
|
if (x >= width) {
|
|
18556
18598
|
continue;
|
|
18557
18599
|
}
|
|
18558
|
-
for (y = yBinStart; y < yBinEnd; y += 1) {
|
|
18600
|
+
for (let y = yBinStart; y < yBinEnd; y += 1) {
|
|
18559
18601
|
if (y >= height) {
|
|
18560
18602
|
continue;
|
|
18561
18603
|
}
|
|
18562
|
-
i = (width * y + x) * 4;
|
|
18604
|
+
const i = (width * y + x) * 4;
|
|
18563
18605
|
data[i + 0] = red;
|
|
18564
18606
|
data[i + 1] = green;
|
|
18565
18607
|
data[i + 2] = blue;
|