canvas-editor-engine 2.3.22 → 2.3.24
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/dist/index.mjs +84 -10
- package/dist/services/draw-accumulator.service.d.ts +6 -2
- package/dist/services/draw-layers.service.d.ts +4 -2
- package/dist/types/draw-layers.d.ts +8 -0
- package/dist/web-component.d.ts +1 -1
- package/package.json +7 -5
- package/dist/components/canvas.component.js +0 -102
- package/dist/components/excretions.component.js +0 -258
- package/dist/components/loading.component.js +0 -71
- package/dist/components/pipette.component.js +0 -120
- package/dist/components/slot.component.js +0 -45
- package/dist/config.js +0 -95
- package/dist/filters/collection/vague.js +0 -168
- package/dist/filters/index.js +0 -2
- package/dist/index.js +0 -75
- package/dist/services/component.service.js +0 -40
- package/dist/services/crop.service.js +0 -60
- package/dist/services/download.service.js +0 -16
- package/dist/services/draw-accumulator.service.js +0 -222
- package/dist/services/draw-layers.service.js +0 -72
- package/dist/services/draw.service.js +0 -259
- package/dist/services/event.service.js +0 -45
- package/dist/services/logger.service.js +0 -57
- package/dist/services/projects.service.js +0 -103
- package/dist/services/pull-project.service.js +0 -40
- package/dist/services/serize.service.js +0 -23
- package/dist/services/store.service.js +0 -14
- package/dist/services/through-history.service.js +0 -51
- package/dist/services/tool-layers.service.js +0 -13
- package/dist/services/tool.service.js +0 -59
- package/dist/store/draw-layers.state.js +0 -85
- package/dist/store/history.state.js +0 -77
- package/dist/store/image.state.js +0 -80
- package/dist/store/store.js +0 -41
- package/dist/store/storeRepository.js +0 -6
- package/dist/types/canvas.js +0 -2
- package/dist/types/cursor.js +0 -2
- package/dist/types/draw-layers.js +0 -3
- package/dist/types/draw-service.js +0 -2
- package/dist/types/excretion.js +0 -4
- package/dist/types/general.js +0 -5
- package/dist/types/history.js +0 -1
- package/dist/types/image.js +0 -9
- package/dist/types/log.js +0 -4
- package/dist/types/pipette.js +0 -1
- package/dist/types/project.js +0 -14
- package/dist/types/temp-canvas.js +0 -2
- package/dist/utils/convert.js +0 -27
- package/dist/utils/filter.js +0 -153
- package/dist/utils/generation.js +0 -7
- package/dist/utils/guid4.js +0 -122
- package/dist/utils/project-file-serializer.js +0 -77
- package/dist/utils/reflect.js +0 -30
- package/dist/utils/temp-canvas.js +0 -19
- package/dist/web-component.js +0 -179
- /package/dist/services/{serize.service.d.ts → resize.service.d.ts} +0 -0
@@ -1,71 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import { reflect } from "../utils/reflect";
|
17
|
-
reflect();
|
18
|
-
import ComponentService from "../services/component.service";
|
19
|
-
var LoadingComponent = /** @class */ (function (_super) {
|
20
|
-
__extends(LoadingComponent, _super);
|
21
|
-
function LoadingComponent(loggerService, eventService) {
|
22
|
-
var _this = _super.call(this) || this;
|
23
|
-
_this.loggerService = loggerService;
|
24
|
-
_this.eventService = eventService;
|
25
|
-
_this.template = "\n <span class=\"loader\"></span>\n ";
|
26
|
-
_this.css = "\n .loading-wrapper {\n display: none; \n justify-content: center;\n align-items: center;\n position: absolute;\n width: 100%;\n height: 100%;\n background: #ffffff30;\n }\n\n .loader {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n position: relative;\n animation: rotate 1s linear infinite\n }\n .loader::before , .loader::after {\n content: \"\";\n box-sizing: border-box;\n position: absolute;\n inset: 0px;\n border-radius: 50%;\n border: 5px solid #FFF;\n animation: prixClipFix 2s linear infinite ;\n }\n .loader::after{\n inset: 8px;\n transform: rotate3d(90, 90, 0, 180deg );\n border-color: #FF3D00;\n }\n\n @keyframes rotate {\n 0% {transform: rotate(0deg)}\n 100% {transform: rotate(360deg)}\n }\n\n @keyframes prixClipFix {\n 0% {clip-path:polygon(50% 50%,0 0,0 0,0 0,0 0,0 0)}\n 50% {clip-path:polygon(50% 50%,0 0,100% 0,100% 0,100% 0,100% 0)}\n 75%, 100% {clip-path:polygon(50% 50%,0 0,100% 0,100% 100%,100% 100%,100% 100%)}\n }\n ";
|
27
|
-
_this.loggerService.components.add({
|
28
|
-
info: {
|
29
|
-
name: 'loading',
|
30
|
-
description: 'loading component',
|
31
|
-
},
|
32
|
-
prototype: _this,
|
33
|
-
});
|
34
|
-
return _this;
|
35
|
-
}
|
36
|
-
LoadingComponent.prototype.getComponent = function () {
|
37
|
-
var wrapOptions = {
|
38
|
-
className: 'loading-wrapper',
|
39
|
-
};
|
40
|
-
var loadingTemplate = this.getTemplate(this.template, wrapOptions);
|
41
|
-
var loadingStyle = this.getStyle(this.css);
|
42
|
-
this.loading = loadingTemplate;
|
43
|
-
this.subscribeLoadingStart();
|
44
|
-
this.subscribeLoadingEnd();
|
45
|
-
return { loadingTemplate: loadingTemplate, loadingStyle: loadingStyle };
|
46
|
-
};
|
47
|
-
LoadingComponent.prototype.hide = function () {
|
48
|
-
this.loading.style.display = 'none';
|
49
|
-
};
|
50
|
-
LoadingComponent.prototype.view = function () {
|
51
|
-
this.loading.style.display = 'flex';
|
52
|
-
};
|
53
|
-
LoadingComponent.prototype.subscribeLoadingStart = function () {
|
54
|
-
var _this = this;
|
55
|
-
var controlEvent = {
|
56
|
-
name: 'loading-start',
|
57
|
-
action: function () { return _this.view(); },
|
58
|
-
};
|
59
|
-
this.eventService.subcribe(controlEvent);
|
60
|
-
};
|
61
|
-
LoadingComponent.prototype.subscribeLoadingEnd = function () {
|
62
|
-
var _this = this;
|
63
|
-
var controlEvent = {
|
64
|
-
name: 'loading-end',
|
65
|
-
action: function () { return _this.hide(); },
|
66
|
-
};
|
67
|
-
this.eventService.subcribe(controlEvent);
|
68
|
-
};
|
69
|
-
return LoadingComponent;
|
70
|
-
}(ComponentService));
|
71
|
-
export default LoadingComponent;
|
@@ -1,120 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import { reflect } from "../utils/reflect";
|
17
|
-
reflect();
|
18
|
-
import { Convert } from "../utils/convert";
|
19
|
-
import ComponentService from "../services/component.service";
|
20
|
-
var PipetteComponent = /** @class */ (function (_super) {
|
21
|
-
__extends(PipetteComponent, _super);
|
22
|
-
function PipetteComponent(toolService, loggerService, canvasComponent) {
|
23
|
-
var _this = _super.call(this) || this;
|
24
|
-
_this.toolService = toolService;
|
25
|
-
_this.loggerService = loggerService;
|
26
|
-
_this.canvasComponent = canvasComponent;
|
27
|
-
_this.template = "\n <div class=\"pipette_border-out\">\n <div class=\"pipette_color\">\n <div class=\"pipette_border-in\">\n <svg width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"><path d=\"M17 12C17 14.7614 14.7614 17 12 17M17 12C17 9.23858 14.7614 7 12 7M17 12H19M12 17C9.23858 17 7 14.7614 7 12M12 17V19M7 12C7 9.23858 9.23858 7 12 7M7 12H5M12 7V5M14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12Z\" stroke=\"#d9d9d9\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></g></svg>\n </div> \n </div>\n </div>\n ";
|
28
|
-
_this.css = "\n .pipette {\n position: absolute;\n display: none;\n justify-content: center;\n align-items: center;\n width: 48px;\n height: 48px;\n }\n\n .pipette_border-out {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 100px;\n border: solid 2px #d9d9d9;\n width: 44px;\n height: 44px;\n }\n\n .pipette_border-in {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 100px;\n border: solid 1px #d9d9d9;\n width: 32px;\n height: 32px;\n }\n\n .pipette_color {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n border-radius: 100px;\n border-color: blue;\n border-style: solid;\n border-width: 5px;\n }\n ";
|
29
|
-
_this._pipetteState = 'abandoned';
|
30
|
-
_this.tool = {
|
31
|
-
id: 0,
|
32
|
-
name: 'pipette',
|
33
|
-
onAction: function () { return _this.setState('taken'); },
|
34
|
-
offAction: function () { return _this.setState('abandoned'); },
|
35
|
-
};
|
36
|
-
_this.toolService.add(_this.tool);
|
37
|
-
_this.loggerService.components.add({
|
38
|
-
info: {
|
39
|
-
name: 'pipette',
|
40
|
-
description: 'pipette component',
|
41
|
-
},
|
42
|
-
prototype: _this,
|
43
|
-
});
|
44
|
-
return _this;
|
45
|
-
}
|
46
|
-
Object.defineProperty(PipetteComponent.prototype, "pipetteColor", {
|
47
|
-
get: function () {
|
48
|
-
return this._pipetteColor;
|
49
|
-
},
|
50
|
-
set: function (color) {
|
51
|
-
this._pipetteColor = color;
|
52
|
-
this._pipetteColorElement.style.borderColor = this._pipetteColor;
|
53
|
-
},
|
54
|
-
enumerable: false,
|
55
|
-
configurable: true
|
56
|
-
});
|
57
|
-
PipetteComponent.prototype.getComponent = function () {
|
58
|
-
var wrapOptions = {
|
59
|
-
className: 'pipette',
|
60
|
-
};
|
61
|
-
var pipetteTemplate = this.getTemplate(this.template, wrapOptions);
|
62
|
-
var pipetteStyle = this.getStyle(this.css);
|
63
|
-
this.pipette = pipetteTemplate;
|
64
|
-
this._pipetteColorElement = pipetteTemplate.querySelector('.pipette_color');
|
65
|
-
this.emmit();
|
66
|
-
return { pipetteTemplate: pipetteTemplate, pipetteStyle: pipetteStyle };
|
67
|
-
};
|
68
|
-
PipetteComponent.prototype.setState = function (state) {
|
69
|
-
this._pipetteState = state;
|
70
|
-
switch (state) {
|
71
|
-
case 'abandoned':
|
72
|
-
return this.hide();
|
73
|
-
case 'taken':
|
74
|
-
return this.show();
|
75
|
-
case 'selected-color':
|
76
|
-
return this.show();
|
77
|
-
default:
|
78
|
-
return this.hide();
|
79
|
-
}
|
80
|
-
};
|
81
|
-
PipetteComponent.prototype.emmit = function () {
|
82
|
-
var _this = this;
|
83
|
-
this.canvasComponent.subscribe('mousemove', function (event, cursorPosition) {
|
84
|
-
var state = _this._pipetteState;
|
85
|
-
if (state === 'taken' || state === 'selected-color') {
|
86
|
-
var x = cursorPosition.x, y = cursorPosition.y;
|
87
|
-
_this.pipette.style.left = "".concat(x + 10, "px");
|
88
|
-
_this.pipette.style.top = "".concat(y + 10, "px");
|
89
|
-
}
|
90
|
-
});
|
91
|
-
this.canvasComponent.subscribe('click', function (event, cursorPosition) {
|
92
|
-
var state = _this._pipetteState;
|
93
|
-
if (state === 'taken' || state === 'selected-color') {
|
94
|
-
if (state === 'taken') {
|
95
|
-
_this.setColorFromChoosenPixel(cursorPosition);
|
96
|
-
_this.setState('selected-color');
|
97
|
-
}
|
98
|
-
if (state === 'selected-color') {
|
99
|
-
_this.setColorFromChoosenPixel(cursorPosition);
|
100
|
-
}
|
101
|
-
}
|
102
|
-
});
|
103
|
-
};
|
104
|
-
PipetteComponent.prototype.setColorFromChoosenPixel = function (cursorPosition) {
|
105
|
-
var x = cursorPosition.x, y = cursorPosition.y;
|
106
|
-
var pixel = this.canvasComponent.ctx.getImageData(x, y, 1, 1).data;
|
107
|
-
var hexPixel = Convert.rgbToHex(pixel[0], pixel[1], pixel[2]);
|
108
|
-
this.pipetteColor = hexPixel;
|
109
|
-
};
|
110
|
-
PipetteComponent.prototype.show = function () {
|
111
|
-
this.pipette.style.display = 'flex';
|
112
|
-
this.canvasComponent.cursorStyle = 'default';
|
113
|
-
};
|
114
|
-
PipetteComponent.prototype.hide = function () {
|
115
|
-
this.pipette.style.display = 'none';
|
116
|
-
this.canvasComponent.cursorStyle = 'default';
|
117
|
-
};
|
118
|
-
return PipetteComponent;
|
119
|
-
}(ComponentService));
|
120
|
-
export default PipetteComponent;
|
@@ -1,45 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import ComponentService from "../services/component.service";
|
17
|
-
var SlotComponent = /** @class */ (function (_super) {
|
18
|
-
__extends(SlotComponent, _super);
|
19
|
-
function SlotComponent(loggerService) {
|
20
|
-
var _this = _super.call(this) || this;
|
21
|
-
_this.loggerService = loggerService;
|
22
|
-
_this.template = "\n <slot class=\"slot\"></slot>\n ";
|
23
|
-
_this.css = "";
|
24
|
-
_this.loggerService.components.add({
|
25
|
-
info: {
|
26
|
-
name: 'slot',
|
27
|
-
description: 'slot component',
|
28
|
-
},
|
29
|
-
prototype: _this,
|
30
|
-
});
|
31
|
-
return _this;
|
32
|
-
}
|
33
|
-
SlotComponent.prototype.getComponent = function (slotName) {
|
34
|
-
var wrapOptions = {
|
35
|
-
className: 'slot-wrapper',
|
36
|
-
};
|
37
|
-
var slotTemplate = this.getTemplate(this.template, wrapOptions);
|
38
|
-
var slotStyle = this.getStyle(this.css);
|
39
|
-
this.slot = slotTemplate.querySelector('slot');
|
40
|
-
this.slot.name = slotName;
|
41
|
-
return { slotTemplate: slotTemplate, slotStyle: slotStyle };
|
42
|
-
};
|
43
|
-
return SlotComponent;
|
44
|
-
}(ComponentService));
|
45
|
-
export default SlotComponent;
|
package/dist/config.js
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
;
|
17
|
-
var ConfigFabric = /** @class */ (function () {
|
18
|
-
function ConfigFabric() {
|
19
|
-
}
|
20
|
-
return ConfigFabric;
|
21
|
-
}());
|
22
|
-
export { ConfigFabric };
|
23
|
-
var AppConfig = /** @class */ (function (_super) {
|
24
|
-
__extends(AppConfig, _super);
|
25
|
-
function AppConfig() {
|
26
|
-
var _this = _super.call(this) || this;
|
27
|
-
_this.canvas = null;
|
28
|
-
_this._CANVAS_SIZE = {
|
29
|
-
width: 300,
|
30
|
-
height: 150,
|
31
|
-
};
|
32
|
-
_this._LAYERS = [
|
33
|
-
{
|
34
|
-
name: 'low',
|
35
|
-
index: 1,
|
36
|
-
},
|
37
|
-
{
|
38
|
-
name: 'normal',
|
39
|
-
index: 2,
|
40
|
-
},
|
41
|
-
{
|
42
|
-
name: 'high',
|
43
|
-
index: 3,
|
44
|
-
}
|
45
|
-
];
|
46
|
-
_this._ZOOM = 1;
|
47
|
-
return _this;
|
48
|
-
}
|
49
|
-
AppConfig.prototype.bindCanvas = function (canvasElement) {
|
50
|
-
this.canvas = canvasElement.querySelector('canvas');
|
51
|
-
};
|
52
|
-
Object.defineProperty(AppConfig.prototype, "CANVAS_SIZE", {
|
53
|
-
get: function () {
|
54
|
-
return this._CANVAS_SIZE;
|
55
|
-
},
|
56
|
-
set: function (value) {
|
57
|
-
if (!!value && !!(value === null || value === void 0 ? void 0 : value.width) && !!(value === null || value === void 0 ? void 0 : value.height)) {
|
58
|
-
this._CANVAS_SIZE = value;
|
59
|
-
if (!!this.canvas) {
|
60
|
-
this.canvas.width = value.width;
|
61
|
-
this.canvas.height = value.height;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
else {
|
65
|
-
console.warn('CANVAS_SIZE denied');
|
66
|
-
}
|
67
|
-
},
|
68
|
-
enumerable: false,
|
69
|
-
configurable: true
|
70
|
-
});
|
71
|
-
Object.defineProperty(AppConfig.prototype, "LAYERS", {
|
72
|
-
get: function () {
|
73
|
-
return this._LAYERS;
|
74
|
-
},
|
75
|
-
set: function (value) {
|
76
|
-
if (!!value && !!(value === null || value === void 0 ? void 0 : value.length)) {
|
77
|
-
this._LAYERS = value;
|
78
|
-
}
|
79
|
-
},
|
80
|
-
enumerable: false,
|
81
|
-
configurable: true
|
82
|
-
});
|
83
|
-
Object.defineProperty(AppConfig.prototype, "ZOOM", {
|
84
|
-
get: function () {
|
85
|
-
return this._ZOOM;
|
86
|
-
},
|
87
|
-
set: function (value) {
|
88
|
-
this._ZOOM = value;
|
89
|
-
},
|
90
|
-
enumerable: false,
|
91
|
-
configurable: true
|
92
|
-
});
|
93
|
-
return AppConfig;
|
94
|
-
}(ConfigFabric));
|
95
|
-
export default AppConfig;
|
@@ -1,168 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import { Filter } from "../../utils/filter";
|
17
|
-
import { Convert } from "../../utils/convert";
|
18
|
-
import { range } from '../../utils/generation';
|
19
|
-
var VagueFilter = /** @class */ (function (_super) {
|
20
|
-
__extends(VagueFilter, _super);
|
21
|
-
function VagueFilter(appConfig, ctx, options) {
|
22
|
-
var _this = _super.call(this, appConfig, ctx) || this;
|
23
|
-
_this.filterList = ['pixel'];
|
24
|
-
_this.options = options;
|
25
|
-
return _this;
|
26
|
-
}
|
27
|
-
VagueFilter.prototype.on = function (action, filterOptions) {
|
28
|
-
var _this = this;
|
29
|
-
return new Promise(function (resolve) {
|
30
|
-
var options = _this.options;
|
31
|
-
var imageData = _this.copy(options);
|
32
|
-
// TODO: rewrite on pattern Strategies
|
33
|
-
var rowImageData = _this[action](imageData, filterOptions);
|
34
|
-
_this.update(rowImageData, options);
|
35
|
-
return resolve({
|
36
|
-
imageData: rowImageData,
|
37
|
-
position: {
|
38
|
-
x: options.x,
|
39
|
-
y: options.y,
|
40
|
-
},
|
41
|
-
size: {
|
42
|
-
width: rowImageData.width,
|
43
|
-
height: rowImageData.height,
|
44
|
-
},
|
45
|
-
quality: filterOptions.quality,
|
46
|
-
});
|
47
|
-
});
|
48
|
-
};
|
49
|
-
VagueFilter.prototype.pixel = function (imageData, filterOptions) {
|
50
|
-
var quality = filterOptions.quality;
|
51
|
-
// expansion strategy
|
52
|
-
var processedImageData = this.getQualityProcessedRemainder(imageData, +quality);
|
53
|
-
// TODO: add compression strategy and use register strategies;
|
54
|
-
var imageSize = {
|
55
|
-
width: processedImageData.width,
|
56
|
-
height: processedImageData.height,
|
57
|
-
};
|
58
|
-
this.setImageSize(imageSize);
|
59
|
-
var _a = this.getBuffCollection(processedImageData), rowRGBABuff = _a.rowRGBABuff, buff = _a.buff;
|
60
|
-
var _b = this.getQualityBuff(buff, +quality), qualityBuff = _b.qualityBuff, rangeCommit = _b.rangeCommit;
|
61
|
-
var qualityBuffWithMostCommonElement = this.getMostCommonQuanlityBuff(qualityBuff, rangeCommit);
|
62
|
-
var rowQualityBuffWithMostCommonElement = qualityBuffWithMostCommonElement.flat();
|
63
|
-
if (rowRGBABuff.length >= rowQualityBuffWithMostCommonElement.length) {
|
64
|
-
var occurrenceRGBAbuff = rowQualityBuffWithMostCommonElement.map(function (hexColor, index) {
|
65
|
-
var _a = Convert.hexToRgb(hexColor), r = _a.r, g = _a.g, b = _a.b;
|
66
|
-
var a = rowRGBABuff[index][3];
|
67
|
-
return [r, g, b, a];
|
68
|
-
});
|
69
|
-
var rowBuff = occurrenceRGBAbuff.flat();
|
70
|
-
rowBuff.forEach(function (color, index) {
|
71
|
-
processedImageData.data[index] = color;
|
72
|
-
});
|
73
|
-
}
|
74
|
-
return processedImageData;
|
75
|
-
};
|
76
|
-
VagueFilter.prototype.getQualityProcessedRemainder = function (imageData, quality) {
|
77
|
-
var rowRGBABuff = this.getRowRGBABuff(imageData);
|
78
|
-
var RGBAMatrix = this.getRGBAMatrix(rowRGBABuff, { width: imageData.width, height: imageData.height });
|
79
|
-
var cqx = quality - (imageData.width % quality);
|
80
|
-
var cqy = quality - (imageData.height % quality);
|
81
|
-
var xCommit = range(0, cqx);
|
82
|
-
var yCommit = range(0, cqy);
|
83
|
-
var tempSize = {
|
84
|
-
width: imageData.width + cqx,
|
85
|
-
height: imageData.height + cqy,
|
86
|
-
};
|
87
|
-
var xLastIndex = RGBAMatrix[0].length - 1;
|
88
|
-
RGBAMatrix.forEach(function (row, y) {
|
89
|
-
var xLastRGBAByte = row[xLastIndex];
|
90
|
-
xCommit.forEach(function () { return RGBAMatrix[y].push(xLastRGBAByte); });
|
91
|
-
});
|
92
|
-
var yLastIndex = RGBAMatrix.length - 1;
|
93
|
-
var yLastRGBARow = RGBAMatrix[yLastIndex];
|
94
|
-
yCommit.forEach(function () { return RGBAMatrix.push(yLastRGBARow); });
|
95
|
-
var buffWithRemainder = RGBAMatrix.flat(2);
|
96
|
-
var tempCanvas = document.createElement('canvas');
|
97
|
-
var tempCtx = tempCanvas.getContext('2d');
|
98
|
-
var tempImageData = tempCtx.createImageData(tempSize.width, tempSize.height);
|
99
|
-
buffWithRemainder.forEach(function (_, i) { return tempImageData.data[i] = buffWithRemainder[i]; });
|
100
|
-
return tempImageData;
|
101
|
-
};
|
102
|
-
VagueFilter.prototype.getQualityBuff = function (buff, quality) {
|
103
|
-
var wq = Math.floor(this.imageSize.width / quality);
|
104
|
-
var hq = Math.floor(this.imageSize.height / quality);
|
105
|
-
var qualityBuff = [];
|
106
|
-
var rangeCommit = [];
|
107
|
-
var i = 0;
|
108
|
-
var xStart = 0;
|
109
|
-
var xEnd = quality;
|
110
|
-
var yStart = 0;
|
111
|
-
var yEnd = quality;
|
112
|
-
range(0, hq).forEach(function (hqi) {
|
113
|
-
range(0, wq).forEach(function (wqi) {
|
114
|
-
var _a, _b;
|
115
|
-
var dy = range(yStart, yEnd);
|
116
|
-
var dx = range(xStart, xEnd);
|
117
|
-
var items = [];
|
118
|
-
var coords = [];
|
119
|
-
dy.forEach(function (y) {
|
120
|
-
dx.forEach(function (x) {
|
121
|
-
items.push(buff[y][x]);
|
122
|
-
coords.push({ y: y, x: x });
|
123
|
-
});
|
124
|
-
});
|
125
|
-
xStart += quality;
|
126
|
-
xEnd += quality;
|
127
|
-
(_a = rangeCommit[i]) !== null && _a !== void 0 ? _a : (rangeCommit[i] = coords);
|
128
|
-
(_b = qualityBuff[i]) !== null && _b !== void 0 ? _b : (qualityBuff[i] = items);
|
129
|
-
i++;
|
130
|
-
});
|
131
|
-
xStart = 0;
|
132
|
-
xEnd = quality;
|
133
|
-
yStart += quality;
|
134
|
-
yEnd += quality;
|
135
|
-
});
|
136
|
-
return { qualityBuff: qualityBuff, rangeCommit: rangeCommit };
|
137
|
-
};
|
138
|
-
VagueFilter.prototype.getMostCommonQuanlityBuff = function (qualityBuff, rangeCommit) {
|
139
|
-
var _this = this;
|
140
|
-
var mostCommonQuanlityBuff = [];
|
141
|
-
var qualityBuffWithMostCommonElement = qualityBuff.map(function (newPixel) {
|
142
|
-
var color = _this.getMostCommonElement(newPixel);
|
143
|
-
return newPixel.map(function () { return color; });
|
144
|
-
});
|
145
|
-
qualityBuffWithMostCommonElement.forEach(function (qPixel, pixelIndex) {
|
146
|
-
qPixel.forEach(function (pixelColor, pixelColorIndex) {
|
147
|
-
var _a, _b;
|
148
|
-
var _c;
|
149
|
-
var _d = rangeCommit[pixelIndex][pixelColorIndex], x = _d.x, y = _d.y;
|
150
|
-
(_a = mostCommonQuanlityBuff[y]) !== null && _a !== void 0 ? _a : (mostCommonQuanlityBuff[y] = []);
|
151
|
-
(_b = (_c = mostCommonQuanlityBuff[y])[x]) !== null && _b !== void 0 ? _b : (_c[x] = pixelColor);
|
152
|
-
});
|
153
|
-
});
|
154
|
-
return mostCommonQuanlityBuff;
|
155
|
-
};
|
156
|
-
VagueFilter.prototype.getMostCommonElement = function (array) {
|
157
|
-
function mostCommon(a, b) {
|
158
|
-
var diffA = array.filter(function (v) { return v === a; }).length;
|
159
|
-
var diffB = array.filter(function (v) { return v === b; }).length;
|
160
|
-
return diffA - diffB;
|
161
|
-
}
|
162
|
-
var arraySorted = array.sort(mostCommon);
|
163
|
-
var mostCommonElement = arraySorted[arraySorted.length - 1];
|
164
|
-
return mostCommonElement;
|
165
|
-
};
|
166
|
-
return VagueFilter;
|
167
|
-
}(Filter));
|
168
|
-
export default VagueFilter;
|
package/dist/filters/index.js
DELETED
package/dist/index.js
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import { reflect } from "./utils/reflect";
|
17
|
-
reflect();
|
18
|
-
import AppConfig from "./config";
|
19
|
-
import WebComponent from "./web-component";
|
20
|
-
import CanvasComponent from "./components/canvas.component";
|
21
|
-
import PipetteComponent from "./components/pipette.component";
|
22
|
-
import ExcretionComponent from "./components/excretions.component";
|
23
|
-
import SlotComponent from "./components/slot.component";
|
24
|
-
import LoadingComponent from "./components/loading.component";
|
25
|
-
import DrawService from "./services/draw.service";
|
26
|
-
import ToolService from "./services/tool.service";
|
27
|
-
import LoggerService from "./services/logger.service";
|
28
|
-
import CropService from "./services/crop.service";
|
29
|
-
import DownloadService from "./services/download.service";
|
30
|
-
import ToolLayerService from "./services/tool-layers.service";
|
31
|
-
import EventService from "./services/event.service";
|
32
|
-
import ThroughHistoryService from "./services/through-history.service";
|
33
|
-
import ProjectsService from "./services/projects.service";
|
34
|
-
import PullProjectService from "./services/pull-project.service";
|
35
|
-
import DrawAccumulatorService from './services/draw-accumulator.service';
|
36
|
-
import AppStore from "./store/store";
|
37
|
-
import AppStoreRepository from "./store/storeRepository";
|
38
|
-
var CanvasEditorEngine = /** @class */ (function () {
|
39
|
-
function CanvasEditorEngine() {
|
40
|
-
}
|
41
|
-
CanvasEditorEngine.prototype.getInitial = function () {
|
42
|
-
return { component: WebComponent };
|
43
|
-
};
|
44
|
-
return CanvasEditorEngine;
|
45
|
-
}());
|
46
|
-
var StaticCanvasEditorEngine = /** @class */ (function (_super) {
|
47
|
-
__extends(StaticCanvasEditorEngine, _super);
|
48
|
-
function StaticCanvasEditorEngine() {
|
49
|
-
return _super.call(this) || this;
|
50
|
-
}
|
51
|
-
StaticCanvasEditorEngine.prototype.init = function () {
|
52
|
-
var customElementRegistry = window.customElements;
|
53
|
-
var component = this.getInitial().component;
|
54
|
-
customElementRegistry.define('canvas-editor-engine', component);
|
55
|
-
};
|
56
|
-
return StaticCanvasEditorEngine;
|
57
|
-
}(CanvasEditorEngine));
|
58
|
-
var VueCanvasEditorEngine = /** @class */ (function (_super) {
|
59
|
-
__extends(VueCanvasEditorEngine, _super);
|
60
|
-
function VueCanvasEditorEngine() {
|
61
|
-
return _super.call(this) || this;
|
62
|
-
}
|
63
|
-
return VueCanvasEditorEngine;
|
64
|
-
}(CanvasEditorEngine));
|
65
|
-
export {
|
66
|
-
// config
|
67
|
-
AppConfig,
|
68
|
-
// components
|
69
|
-
PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, LoadingComponent,
|
70
|
-
// services
|
71
|
-
ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, EventService, ThroughHistoryService, ProjectsService, PullProjectService, DrawAccumulatorService,
|
72
|
-
// general
|
73
|
-
StaticCanvasEditorEngine, VueCanvasEditorEngine,
|
74
|
-
// store
|
75
|
-
AppStore, AppStoreRepository, };
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { reflect } from "../utils/reflect";
|
2
|
-
reflect();
|
3
|
-
var ComponentService = /** @class */ (function () {
|
4
|
-
function ComponentService() {
|
5
|
-
}
|
6
|
-
ComponentService.prototype.getTemplate = function (template, wrapOptions) {
|
7
|
-
var options = {
|
8
|
-
tag: 'div',
|
9
|
-
};
|
10
|
-
if (!!wrapOptions) {
|
11
|
-
Object.keys(wrapOptions).forEach(function (key) {
|
12
|
-
if (!!wrapOptions[key]) {
|
13
|
-
options[key] = wrapOptions[key];
|
14
|
-
}
|
15
|
-
});
|
16
|
-
}
|
17
|
-
var wrap = document.createElement(options.tag);
|
18
|
-
if (!!options) {
|
19
|
-
Object.keys(options).forEach(function (key) {
|
20
|
-
if (!!options[key] && key !== 'tag') {
|
21
|
-
wrap[key] = options[key];
|
22
|
-
}
|
23
|
-
});
|
24
|
-
}
|
25
|
-
if (!!template) {
|
26
|
-
wrap.innerHTML = template;
|
27
|
-
}
|
28
|
-
return wrap;
|
29
|
-
};
|
30
|
-
ComponentService.prototype.getStyle = function (css) {
|
31
|
-
if (!!css === false)
|
32
|
-
return null;
|
33
|
-
var style = document.createElement('style');
|
34
|
-
style.type = 'text/css';
|
35
|
-
style.appendChild(document.createTextNode(css));
|
36
|
-
return style;
|
37
|
-
};
|
38
|
-
return ComponentService;
|
39
|
-
}());
|
40
|
-
export default ComponentService;
|