MCPcopy Create free account
hub / github.com/devforth/painterro / constructor

Method constructor

js/main.js:27–824  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

25
26class PainterroProc {
27 constructor(params) {
28 const element =document.querySelector(`#${params.id}`) || document.getElementById('app');
29 this.customEvents = new CustomEvents(element);
30 addDocumentObjectHelpers();
31
32 this.getElemByIdSafe = (id) => {
33 if (!id) {
34 throw new Error(`Can't get element with id=${id}, please create an issue here, we will easily fx it: https://github.com/devforth/painterro/issues/`);
35 }
36 return document.getElementById(id);
37 };
38
39 this.tools = [{
40 name: 'select',
41 hotkey: 's',
42 activate: () => {
43 if (this.initText) this.wrapper.click();
44 this.toolContainer.style.cursor = 'crosshair';
45 this.select.activate();
46 this.select.draw();
47 },
48 close: () => {
49 this.select.close();
50 this.toolContainer.style.cursor = 'auto';
51 },
52 eventListner: () => this.select,
53 }, {
54 name: 'crop',
55 hotkey: 'c',
56 activate: () => {
57 if (this.initText) this.wrapper.click();
58 this.select.doCrop();
59 this.closeActiveTool();
60 },
61 }, {
62 name: 'pixelize',
63 hotkey: 'p',
64 activate: () => {
65 if (this.initText) this.wrapper.click();
66 this.select.doPixelize();
67 this.closeActiveTool();
68 },
69 }, {
70 name: 'line',
71 hotkey: 'l',
72 controls: [
73 () => ({
74 type: 'color',
75 title: 'lineColor',
76 target: 'line',
77 titleFull: 'lineColorFull',
78 action: () => {
79 this.colorPicker.open(this.colorWidgetState.line);
80 },
81 }),
82 () => this.controlBuilder.buildLineWidthControl(1),
83 () => this.controlBuilder.buildShadowOnControl(2),
84 ],

Callers

nothing calls this directly

Calls 15

closeActiveToolMethod · 0.95
resizeMethod · 0.95
saveMethod · 0.95
adjustSizeFullMethod · 0.95
elLeftMethod · 0.95
elTopMethod · 0.95
getScaleMethod · 0.95
zoomImageMethod · 0.95
clearMethod · 0.95
openFileMethod · 0.95
setToolEnabledMethod · 0.95
getBtnElMethod · 0.95

Tested by

no test coverage detected