fabric 6.6.4 → 6.6.6
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 +10 -1
- package/dist/index.js +139 -76
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +139 -76
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +139 -76
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +139 -76
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs +1 -1
- package/dist/src/controls/polyControl.min.mjs +1 -1
- package/dist/src/controls/polyControl.min.mjs.map +1 -1
- package/dist/src/controls/polyControl.mjs +1 -0
- package/dist/src/controls/polyControl.mjs.map +1 -1
- package/dist/src/filters/Blur.d.ts +2 -2
- package/dist/src/filters/Blur.d.ts.map +1 -1
- package/dist/src/filters/Blur.min.mjs +1 -1
- package/dist/src/filters/Blur.min.mjs.map +1 -1
- package/dist/src/filters/Blur.mjs +111 -74
- package/dist/src/filters/Blur.mjs.map +1 -1
- package/dist/src/filters/shaders/blur.d.ts +1 -1
- package/dist/src/filters/shaders/blur.d.ts.map +1 -1
- package/dist/src/filters/shaders/blur.min.mjs +1 -1
- package/dist/src/filters/shaders/blur.min.mjs.map +1 -1
- package/dist/src/filters/shaders/blur.mjs +1 -1
- package/dist/src/filters/shaders/blur.mjs.map +1 -1
- package/dist/src/util/lang_string.d.ts.map +1 -1
- package/dist/src/util/lang_string.min.mjs +1 -1
- package/dist/src/util/lang_string.min.mjs.map +1 -1
- package/dist/src/util/lang_string.mjs +26 -0
- package/dist/src/util/lang_string.mjs.map +1 -1
- package/dist-extensions/src/filters/Blur.d.ts +2 -2
- package/dist-extensions/src/filters/Blur.d.ts.map +1 -1
- package/dist-extensions/src/filters/shaders/blur.d.ts +1 -1
- package/dist-extensions/src/filters/shaders/blur.d.ts.map +1 -1
- package/dist-extensions/src/util/lang_string.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/controls/polyControl.spec.ts +2 -0
- package/src/controls/polyControl.ts +1 -1
- package/src/filters/Blur.ts +104 -72
- package/src/filters/shaders/blur.ts +10 -4
- package/src/util/lang_string.spec.ts +50 -0
- package/src/util/lang_string.ts +29 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.6.6]
|
|
4
|
+
|
|
5
|
+
- fix(): Polygon controls util should invalidate cache [#10628](https://github.com/fabricjs/fabric.js/pull/10628)
|
|
6
|
+
- fix(): Remove black border in blur and also align JS with WEBGL blur filtering [#10623](https://github.com/fabricjs/fabric.js/pull/10623)
|
|
7
|
+
|
|
8
|
+
## [6.6.5]
|
|
9
|
+
|
|
10
|
+
- feat(Text): Support for intl.segmenter in fabric.Text [#10595](https://github.com/fabricjs/fabric.js/pull/10595)
|
|
11
|
+
|
|
3
12
|
## [6.6.4]
|
|
4
13
|
|
|
5
|
-
- chore() properly updated version number
|
|
14
|
+
- chore(): properly updated version number
|
|
6
15
|
|
|
7
16
|
## [6.6.3]
|
|
8
17
|
|
package/dist/index.js
CHANGED
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
}
|
|
412
412
|
const cache = new Cache();
|
|
413
413
|
|
|
414
|
-
var version = "6.6.
|
|
414
|
+
var version = "6.6.6";
|
|
415
415
|
|
|
416
416
|
// use this syntax so babel plugin see this import here
|
|
417
417
|
const VERSION = version;
|
|
@@ -10271,6 +10271,15 @@
|
|
|
10271
10271
|
* @return {String} Escaped version of a string
|
|
10272
10272
|
*/
|
|
10273
10273
|
const escapeXml = string => string.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
|
|
10274
|
+
let segmenter;
|
|
10275
|
+
const getSegmenter = () => {
|
|
10276
|
+
if (!segmenter) {
|
|
10277
|
+
segmenter = 'Intl' in getFabricWindow() && 'Segmenter' in Intl && new Intl.Segmenter(undefined, {
|
|
10278
|
+
granularity: 'grapheme'
|
|
10279
|
+
});
|
|
10280
|
+
}
|
|
10281
|
+
return segmenter;
|
|
10282
|
+
};
|
|
10274
10283
|
|
|
10275
10284
|
/**
|
|
10276
10285
|
* Divide a string in the user perceived single units
|
|
@@ -10278,6 +10287,21 @@
|
|
|
10278
10287
|
* @return {Array} array containing the graphemes
|
|
10279
10288
|
*/
|
|
10280
10289
|
const graphemeSplit = textstring => {
|
|
10290
|
+
segmenter || getSegmenter();
|
|
10291
|
+
if (segmenter) {
|
|
10292
|
+
const segments = segmenter.segment(textstring);
|
|
10293
|
+
return Array.from(segments).map(_ref => {
|
|
10294
|
+
let {
|
|
10295
|
+
segment
|
|
10296
|
+
} = _ref;
|
|
10297
|
+
return segment;
|
|
10298
|
+
});
|
|
10299
|
+
}
|
|
10300
|
+
|
|
10301
|
+
//Fallback
|
|
10302
|
+
return graphemeSplitImpl(textstring);
|
|
10303
|
+
};
|
|
10304
|
+
const graphemeSplitImpl = textstring => {
|
|
10281
10305
|
const graphemes = [];
|
|
10282
10306
|
for (let i = 0, chr; i < textstring.length; i++) {
|
|
10283
10307
|
if ((chr = getWholeChar(textstring, i)) === false) {
|
|
@@ -25493,6 +25517,7 @@
|
|
|
25493
25517
|
const mouseLocalPosition = sendPointToPlane(new Point(x, y), undefined, poly.calcOwnMatrix());
|
|
25494
25518
|
poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);
|
|
25495
25519
|
poly.setDimensions();
|
|
25520
|
+
poly.set('dirty', true);
|
|
25496
25521
|
return true;
|
|
25497
25522
|
};
|
|
25498
25523
|
|
|
@@ -26414,7 +26439,7 @@
|
|
|
26414
26439
|
_defineProperty(BlendImage, "uniformLocations", ['uTransformMatrix', 'uImage']);
|
|
26415
26440
|
classRegistry.setClass(BlendImage);
|
|
26416
26441
|
|
|
26417
|
-
const fragmentSource$b = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n const float nSamples = 15.0;\n vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n float random(vec3 scale) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n }\n void main() {\n vec4 color = vec4(0.0);\n float
|
|
26442
|
+
const fragmentSource$b = "\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n const float nSamples = 15.0;\n vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n float random(vec3 scale) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n }\n void main() {\n vec4 color = vec4(0.0);\n float totalC = 0.0;\n float totalA = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);\n float weight = 1.0 - abs(percent);\n float alpha = weight * sample.a;\n color.rgb += sample.rgb * alpha;\n color.a += alpha;\n totalA += weight;\n totalC += alpha;\n }\n gl_FragColor.rgb = color.rgb / totalC;\n gl_FragColor.a = color.a / totalA;\n }\n ";
|
|
26418
26443
|
|
|
26419
26444
|
const blurDefaultValues = {
|
|
26420
26445
|
blur: 0
|
|
@@ -26451,65 +26476,102 @@
|
|
|
26451
26476
|
this.applyTo2d(options);
|
|
26452
26477
|
}
|
|
26453
26478
|
}
|
|
26454
|
-
applyTo2d(
|
|
26455
|
-
options.imageData = this.simpleBlur(options);
|
|
26456
|
-
}
|
|
26457
|
-
simpleBlur(_ref) {
|
|
26479
|
+
applyTo2d(_ref) {
|
|
26458
26480
|
let {
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26481
|
+
imageData: {
|
|
26482
|
+
data,
|
|
26483
|
+
width,
|
|
26484
|
+
height
|
|
26463
26485
|
}
|
|
26464
26486
|
} = _ref;
|
|
26465
|
-
|
|
26466
|
-
|
|
26467
|
-
|
|
26468
|
-
|
|
26469
|
-
|
|
26470
|
-
|
|
26471
|
-
|
|
26487
|
+
// this code mimic the shader for output consistency
|
|
26488
|
+
// it samples 31 pixels across the image over a distance that depends from the blur value.
|
|
26489
|
+
this.aspectRatio = width / height;
|
|
26490
|
+
this.horizontal = true;
|
|
26491
|
+
let blurValue = this.getBlurValue() * width;
|
|
26492
|
+
const imageData = new Uint8ClampedArray(data);
|
|
26493
|
+
const samples = 15;
|
|
26494
|
+
const bytesInRow = 4 * width;
|
|
26495
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
26496
|
+
let r = 0.0,
|
|
26497
|
+
g = 0.0,
|
|
26498
|
+
b = 0.0,
|
|
26499
|
+
a = 0.0,
|
|
26500
|
+
totalA = 0;
|
|
26501
|
+
const minIRow = i - i % bytesInRow;
|
|
26502
|
+
const maxIRow = minIRow + bytesInRow;
|
|
26503
|
+
// for now let's keep noise out of the way
|
|
26504
|
+
// let pixelOffset = 0;
|
|
26505
|
+
// const offset = Math.random() * 3;
|
|
26506
|
+
// if (offset > 2) {
|
|
26507
|
+
// pixelOffset = 4;
|
|
26508
|
+
// } else if (offset < 1) {
|
|
26509
|
+
// pixelOffset = -4;
|
|
26510
|
+
// }
|
|
26511
|
+
for (let j = -samples + 1; j < samples; j++) {
|
|
26512
|
+
const percent = j / samples;
|
|
26513
|
+
const distance = Math.floor(blurValue * percent) * 4;
|
|
26514
|
+
const weight = 1 - Math.abs(percent);
|
|
26515
|
+
let sampledPixel = i + distance; // + pixelOffset;
|
|
26516
|
+
// try to implement edge mirroring
|
|
26517
|
+
if (sampledPixel < minIRow) {
|
|
26518
|
+
sampledPixel = minIRow;
|
|
26519
|
+
} else if (sampledPixel > maxIRow) {
|
|
26520
|
+
sampledPixel = maxIRow;
|
|
26521
|
+
}
|
|
26522
|
+
const localAlpha = data[sampledPixel + 3] * weight;
|
|
26523
|
+
r += data[sampledPixel] * localAlpha;
|
|
26524
|
+
g += data[sampledPixel + 1] * localAlpha;
|
|
26525
|
+
b += data[sampledPixel + 2] * localAlpha;
|
|
26526
|
+
a += localAlpha;
|
|
26527
|
+
totalA += weight;
|
|
26528
|
+
}
|
|
26529
|
+
imageData[i] = r / a;
|
|
26530
|
+
imageData[i + 1] = g / a;
|
|
26531
|
+
imageData[i + 2] = b / a;
|
|
26532
|
+
imageData[i + 3] = a / totalA;
|
|
26533
|
+
}
|
|
26534
|
+
this.horizontal = false;
|
|
26535
|
+
blurValue = this.getBlurValue() * height;
|
|
26536
|
+
for (let i = 0; i < imageData.length; i += 4) {
|
|
26537
|
+
let r = 0.0,
|
|
26538
|
+
g = 0.0,
|
|
26539
|
+
b = 0.0,
|
|
26540
|
+
a = 0.0,
|
|
26541
|
+
totalA = 0;
|
|
26542
|
+
const minIRow = i % bytesInRow;
|
|
26543
|
+
const maxIRow = imageData.length - bytesInRow + minIRow;
|
|
26544
|
+
// for now let's keep noise out of the way
|
|
26545
|
+
// let pixelOffset = 0;
|
|
26546
|
+
// const offset = Math.random() * 3;
|
|
26547
|
+
// if (offset > 2) {
|
|
26548
|
+
// pixelOffset = bytesInRow;
|
|
26549
|
+
// } else if (offset < 1) {
|
|
26550
|
+
// pixelOffset = -bytesInRow;
|
|
26551
|
+
// }
|
|
26552
|
+
for (let j = -samples + 1; j < samples; j++) {
|
|
26553
|
+
const percent = j / samples;
|
|
26554
|
+
const distance = Math.floor(blurValue * percent) * bytesInRow;
|
|
26555
|
+
const weight = 1 - Math.abs(percent);
|
|
26556
|
+
let sampledPixel = i + distance; // + pixelOffset;
|
|
26557
|
+
// try to implement edge mirroring
|
|
26558
|
+
if (sampledPixel < minIRow) {
|
|
26559
|
+
sampledPixel = minIRow;
|
|
26560
|
+
} else if (sampledPixel > maxIRow) {
|
|
26561
|
+
sampledPixel = maxIRow;
|
|
26562
|
+
}
|
|
26563
|
+
const localAlpha = imageData[sampledPixel + 3] * weight;
|
|
26564
|
+
r += imageData[sampledPixel] * localAlpha;
|
|
26565
|
+
g += imageData[sampledPixel + 1] * localAlpha;
|
|
26566
|
+
b += imageData[sampledPixel + 2] * localAlpha;
|
|
26567
|
+
a += localAlpha;
|
|
26568
|
+
totalA += weight;
|
|
26569
|
+
}
|
|
26570
|
+
data[i] = r / a;
|
|
26571
|
+
data[i + 1] = g / a;
|
|
26572
|
+
data[i + 2] = b / a;
|
|
26573
|
+
data[i + 3] = a / totalA;
|
|
26472
26574
|
}
|
|
26473
|
-
const canvas1 = resources.blurLayer1;
|
|
26474
|
-
const canvas2 = resources.blurLayer2;
|
|
26475
|
-
if (canvas1.width !== width || canvas1.height !== height) {
|
|
26476
|
-
canvas2.width = canvas1.width = width;
|
|
26477
|
-
canvas2.height = canvas1.height = height;
|
|
26478
|
-
}
|
|
26479
|
-
const ctx1 = canvas1.getContext('2d'),
|
|
26480
|
-
ctx2 = canvas2.getContext('2d'),
|
|
26481
|
-
nSamples = 15,
|
|
26482
|
-
blur = this.blur * 0.06 * 0.5;
|
|
26483
|
-
let random, percent, j, i;
|
|
26484
|
-
|
|
26485
|
-
// load first canvas
|
|
26486
|
-
ctx1.putImageData(imageData, 0, 0);
|
|
26487
|
-
ctx2.clearRect(0, 0, width, height);
|
|
26488
|
-
for (i = -nSamples; i <= nSamples; i++) {
|
|
26489
|
-
random = (Math.random() - 0.5) / 4;
|
|
26490
|
-
percent = i / nSamples;
|
|
26491
|
-
j = blur * percent * width + random;
|
|
26492
|
-
ctx2.globalAlpha = 1 - Math.abs(percent);
|
|
26493
|
-
ctx2.drawImage(canvas1, j, random);
|
|
26494
|
-
ctx1.drawImage(canvas2, 0, 0);
|
|
26495
|
-
ctx2.globalAlpha = 1;
|
|
26496
|
-
ctx2.clearRect(0, 0, canvas2.width, canvas2.height);
|
|
26497
|
-
}
|
|
26498
|
-
for (i = -nSamples; i <= nSamples; i++) {
|
|
26499
|
-
random = (Math.random() - 0.5) / 4;
|
|
26500
|
-
percent = i / nSamples;
|
|
26501
|
-
j = blur * percent * height + random;
|
|
26502
|
-
ctx2.globalAlpha = 1 - Math.abs(percent);
|
|
26503
|
-
ctx2.drawImage(canvas1, random, j);
|
|
26504
|
-
ctx1.drawImage(canvas2, 0, 0);
|
|
26505
|
-
ctx2.globalAlpha = 1;
|
|
26506
|
-
ctx2.clearRect(0, 0, canvas2.width, canvas2.height);
|
|
26507
|
-
}
|
|
26508
|
-
ctx.drawImage(canvas1, 0, 0);
|
|
26509
|
-
const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);
|
|
26510
|
-
ctx1.globalAlpha = 1;
|
|
26511
|
-
ctx1.clearRect(0, 0, canvas1.width, canvas1.height);
|
|
26512
|
-
return newImageData;
|
|
26513
26575
|
}
|
|
26514
26576
|
|
|
26515
26577
|
/**
|
|
@@ -26525,32 +26587,33 @@
|
|
|
26525
26587
|
isNeutralState() {
|
|
26526
26588
|
return this.blur === 0;
|
|
26527
26589
|
}
|
|
26528
|
-
|
|
26529
|
-
/**
|
|
26530
|
-
* choose right value of image percentage to blur with
|
|
26531
|
-
* @returns {Array} a numeric array with delta values
|
|
26532
|
-
*/
|
|
26533
|
-
chooseRightDelta() {
|
|
26590
|
+
getBlurValue() {
|
|
26534
26591
|
let blurScale = 1;
|
|
26535
|
-
const
|
|
26536
|
-
|
|
26537
|
-
|
|
26592
|
+
const {
|
|
26593
|
+
horizontal,
|
|
26594
|
+
aspectRatio
|
|
26595
|
+
} = this;
|
|
26596
|
+
if (horizontal) {
|
|
26597
|
+
if (aspectRatio > 1) {
|
|
26538
26598
|
// image is wide, i want to shrink radius horizontal
|
|
26539
|
-
blurScale = 1 /
|
|
26599
|
+
blurScale = 1 / aspectRatio;
|
|
26540
26600
|
}
|
|
26541
26601
|
} else {
|
|
26542
|
-
if (
|
|
26602
|
+
if (aspectRatio < 1) {
|
|
26543
26603
|
// image is tall, i want to shrink radius vertical
|
|
26544
|
-
blurScale =
|
|
26604
|
+
blurScale = aspectRatio;
|
|
26545
26605
|
}
|
|
26546
26606
|
}
|
|
26547
|
-
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
|
|
26551
|
-
|
|
26552
|
-
|
|
26553
|
-
|
|
26607
|
+
return blurScale * this.blur * 0.12;
|
|
26608
|
+
}
|
|
26609
|
+
|
|
26610
|
+
/**
|
|
26611
|
+
* choose right value of image percentage to blur with
|
|
26612
|
+
* @returns {Array} a numeric array with delta values
|
|
26613
|
+
*/
|
|
26614
|
+
chooseRightDelta() {
|
|
26615
|
+
const blur = this.getBlurValue();
|
|
26616
|
+
return this.horizontal ? [blur, 0] : [0, blur];
|
|
26554
26617
|
}
|
|
26555
26618
|
}
|
|
26556
26619
|
/**
|