@yorab/react-paint 0.2.2
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 +26 -0
- package/README.md +99 -0
- package/dist/components/App.d.ts +20 -0
- package/dist/components/App.js +533 -0
- package/dist/components/Canvas.d.ts +28 -0
- package/dist/components/Canvas.js +188 -0
- package/dist/components/common/Button.d.ts +14 -0
- package/dist/components/common/Button.js +97 -0
- package/dist/components/common/Loading.d.ts +6 -0
- package/dist/components/common/Loading.js +66 -0
- package/dist/components/common/Modal.d.ts +8 -0
- package/dist/components/common/Modal.js +41 -0
- package/dist/components/common/Panel.d.ts +10 -0
- package/dist/components/common/Panel.js +48 -0
- package/dist/components/common/Snackbar.d.ts +7 -0
- package/dist/components/common/Snackbar.js +75 -0
- package/dist/components/settings/ColorField.d.ts +12 -0
- package/dist/components/settings/ColorField.js +128 -0
- package/dist/components/settings/DeleteButton.d.ts +9 -0
- package/dist/components/settings/DeleteButton.js +36 -0
- package/dist/components/settings/FontFamilyField.d.ts +10 -0
- package/dist/components/settings/FontFamilyField.js +57 -0
- package/dist/components/settings/LayoutButton.d.ts +8 -0
- package/dist/components/settings/LayoutButton.js +37 -0
- package/dist/components/settings/Layouts.d.ts +18 -0
- package/dist/components/settings/Layouts.js +218 -0
- package/dist/components/settings/LineArrowField.d.ts +10 -0
- package/dist/components/settings/LineArrowField.js +59 -0
- package/dist/components/settings/LineTypeField.d.ts +14 -0
- package/dist/components/settings/LineTypeField.js +57 -0
- package/dist/components/settings/PointsNumberField.d.ts +11 -0
- package/dist/components/settings/PointsNumberField.js +51 -0
- package/dist/components/settings/RangeField.d.ts +16 -0
- package/dist/components/settings/RangeField.js +90 -0
- package/dist/components/settings/SelectField.d.ts +16 -0
- package/dist/components/settings/SelectField.js +82 -0
- package/dist/components/settings/SettingsBar.d.ts +16 -0
- package/dist/components/settings/SettingsBar.js +262 -0
- package/dist/components/toolbox/EditTextBox.d.ts +10 -0
- package/dist/components/toolbox/EditTextBox.js +89 -0
- package/dist/components/toolbox/LoadFileTool.d.ts +11 -0
- package/dist/components/toolbox/LoadFileTool.js +58 -0
- package/dist/components/toolbox/MenuGroup.d.ts +23 -0
- package/dist/components/toolbox/MenuGroup.js +173 -0
- package/dist/components/toolbox/PictureUrlInput.d.ts +7 -0
- package/dist/components/toolbox/PictureUrlInput.js +96 -0
- package/dist/components/toolbox/Tool.d.ts +13 -0
- package/dist/components/toolbox/Tool.js +41 -0
- package/dist/components/toolbox/Toolbar.d.ts +20 -0
- package/dist/components/toolbox/Toolbar.js +205 -0
- package/dist/components/toolbox/ToolbarGroup.d.ts +18 -0
- package/dist/components/toolbox/ToolbarGroup.js +139 -0
- package/dist/constants/draw.d.ts +2 -0
- package/dist/constants/draw.js +10 -0
- package/dist/constants/icons.d.ts +36 -0
- package/dist/constants/icons.js +80 -0
- package/dist/constants/shapes.d.ts +5 -0
- package/dist/constants/shapes.js +14 -0
- package/dist/constants/snackbar.d.ts +11 -0
- package/dist/constants/snackbar.js +23 -0
- package/dist/constants/style.d.ts +12 -0
- package/dist/constants/style.js +30 -0
- package/dist/hooks/useComponent.d.ts +9 -0
- package/dist/hooks/useComponent.js +48 -0
- package/dist/hooks/useDrag.d.ts +15 -0
- package/dist/hooks/useDrag.js +100 -0
- package/dist/hooks/useDrawableCanvas.d.ts +30 -0
- package/dist/hooks/useDrawableCanvas.js +250 -0
- package/dist/hooks/useKeyboard.d.ts +15 -0
- package/dist/hooks/useKeyboard.js +123 -0
- package/dist/hooks/useShapes.d.ts +22 -0
- package/dist/hooks/useShapes.js +229 -0
- package/dist/hooks/useSnackbar.d.ts +16 -0
- package/dist/hooks/useSnackbar.js +86 -0
- package/dist/schemas/drawableShape.json +1021 -0
- package/dist/styles.css +88 -0
- package/dist/types/Mode.d.ts +51 -0
- package/dist/types/Mode.js +17 -0
- package/dist/types/Shapes.d.ts +122 -0
- package/dist/types/Shapes.js +35 -0
- package/dist/types/keyboard.d.ts +15 -0
- package/dist/types/keyboard.js +28 -0
- package/dist/utils/data.d.ts +4 -0
- package/dist/utils/data.js +178 -0
- package/dist/utils/draw.d.ts +18 -0
- package/dist/utils/draw.js +422 -0
- package/dist/utils/file.d.ts +33 -0
- package/dist/utils/file.js +220 -0
- package/dist/utils/intersect.d.ts +8 -0
- package/dist/utils/intersect.js +194 -0
- package/dist/utils/selection.d.ts +7 -0
- package/dist/utils/selection.js +88 -0
- package/dist/utils/shapeData.d.ts +5 -0
- package/dist/utils/shapeData.js +178 -0
- package/dist/utils/string.d.ts +3 -0
- package/dist/utils/string.js +42 -0
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/style.js +46 -0
- package/dist/utils/toolbar.d.ts +12 -0
- package/dist/utils/toolbar.js +37 -0
- package/dist/utils/transform.d.ts +271 -0
- package/dist/utils/transform.js +371 -0
- package/package.json +79 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
|
|
4
|
+
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
background: #F3F3F3;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.examples {
|
|
11
|
+
display: flex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.menu {
|
|
15
|
+
width: 250px;
|
|
16
|
+
min-width: 0;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.menu a {
|
|
22
|
+
margin: 8px;
|
|
23
|
+
padding: 4px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.menu a.selected {
|
|
27
|
+
color: green;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.currentApp {
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.s1unz6yq{position:absolute;display:inline-block;outline:none;left:0px;top:0px;-webkit-transform-origin:left top;-ms-transform-origin:left top;transform-origin:left top;-webkit-transform:var(--s1unz6yq-0);-ms-transform:var(--s1unz6yq-0);transform:var(--s1unz6yq-0);color:var(--s1unz6yq-1);font-size:var(--s1unz6yq-2);line-height:var(--s1unz6yq-2);font-family:var(--s1unz6yq-4);}
|
|
36
|
+
.s9czb9p{-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}
|
|
37
|
+
.s1538eht{position:relative;background-color:white;background-repeat:repeat;background-size:16px;overflow:hidden;}.s1538eht[data-grid='true']{background-image:url("data:image/svg+xml,%3Csvg%20id%3D%22svg%22%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%22400%22%20height%3D%22400%22%20viewBox%3D%220%2C%200%2C%20400%2C400%22%3E%3Cg%20id%3D%22svgg%22%3E%3Cpath%20id%3D%22path0%22%20d%3D%22M204.800%2094.600%20C%20204.800%20188.933%2C204.802%20189.200%2C205.600%20189.200%20C%20206.248%20189.200%2C206.400%20189.467%2C206.400%20190.600%20C%20206.400%20191.733%2C206.552%20192.000%2C207.200%20192.000%20C%20207.733%20192.000%2C208.000%20192.267%2C208.000%20192.800%20C%20208.000%20193.244%2C208.267%20193.600%2C208.600%20193.600%20C%20208.933%20193.600%2C209.200%20193.956%2C209.200%20194.400%20C%20209.200%20195.067%2C209.467%20195.200%2C210.800%20195.200%20C%20212.133%20195.200%2C212.400%20195.333%2C212.400%20196.000%20C%20212.400%20196.798%2C212.667%20196.800%2C306.200%20196.800%20L%20400.000%20196.800%20400.000%2098.400%20L%20400.000%200.000%20302.400%200.000%20L%20204.800%200.000%20204.800%2094.600%20M0.000%20302.400%20L%200.000%20400.000%2098.400%20400.000%20L%20196.800%20400.000%20196.800%20306.200%20C%20196.800%20212.667%2C196.798%20212.400%2C196.000%20212.400%20C%20195.333%20212.400%2C195.200%20212.133%2C195.200%20210.800%20C%20195.200%20209.467%2C195.067%20209.200%2C194.400%20209.200%20C%20193.956%20209.200%2C193.600%20208.933%2C193.600%20208.600%20C%20193.600%20208.267%2C193.244%20208.000%2C192.800%20208.000%20C%20192.267%20208.000%2C192.000%20207.733%2C192.000%20207.200%20C%20192.000%20206.552%2C191.733%20206.400%2C190.600%20206.400%20C%20189.467%20206.400%2C189.200%20206.248%2C189.200%20205.600%20C%20189.200%20204.802%2C188.933%20204.800%2C94.600%20204.800%20L%200.000%20204.800%200.000%20302.400%20%22%20stroke%3D%22none%22%20fill%3D%22%23fcfcfc%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path1%22%20d%3D%22M0.000%20100.000%20L%200.000%20200.000%2096.800%20200.000%20C%20193.333%20200.000%2C193.600%20199.998%2C193.600%20199.200%20C%20193.600%20198.533%2C193.867%20198.400%2C195.200%20198.400%20C%20196.533%20198.400%2C196.800%20198.267%2C196.800%20197.600%20C%20196.800%20197.067%2C197.067%20196.800%2C197.600%20196.800%20C%20198.267%20196.800%2C198.400%20196.533%2C198.400%20195.200%20C%20198.400%20193.867%2C198.533%20193.600%2C199.200%20193.600%20C%20199.998%20193.600%2C200.000%20193.333%2C200.000%2096.800%20L%20200.000%200.000%20100.000%200.000%20L%200.000%200.000%200.000%20100.000%20M208.000%20202.400%20C%20208.000%20203.067%2C207.733%20203.200%2C206.400%20203.200%20C%20205.067%20203.200%2C204.800%20203.333%2C204.800%20204.000%20C%20204.800%20204.533%2C204.533%20204.800%2C204.000%20204.800%20C%20203.333%20204.800%2C203.200%20205.067%2C203.200%20206.400%20C%20203.200%20207.733%2C203.067%20208.000%2C202.400%20208.000%20C%20201.602%20208.000%2C201.600%20208.267%2C201.600%20304.000%20L%20201.600%20400.000%20300.800%20400.000%20L%20400.000%20400.000%20400.000%20300.800%20L%20400.000%20201.600%20304.000%20201.600%20C%20208.267%20201.600%2C208.000%20201.602%2C208.000%20202.400%20%22%20stroke%3D%22none%22%20fill%3D%22%23e4e4e4%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path2%22%20d%3D%22%22%20stroke%3D%22none%22%20fill%3D%22%23f4100f0%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path3%22%20d%3D%22%22%20stroke%3D%22none%22%20fill%3D%22%23f4100f0%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path4%22%20d%3D%22%22%20stroke%3D%22none%22%20fill%3D%22%23f4100f0%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3C%2Fg%3E%3C%2Fsvg%3E");}.s1538eht[data-grow='true']{width:100%;height:100%;}
|
|
38
|
+
.s101qxdc{position:absolute;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;max-width:100%;touch-action:none;display:block;}.s101qxdc[data-grow='true']{width:100%;}
|
|
39
|
+
.sa4oq48{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;max-width:100%;touch-action:none;display:block;cursor:var(--sa4oq48-0);}.sa4oq48[data-grow='true']{width:100%;}
|
|
40
|
+
.sq3bzv4{min-width:32px;height:32px;font-size:14px;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle;box-sizing:border-box;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;background:none;border:none;cursor:pointer;border-radius:8px;color:var(--text-color);margin:2px 4px;padding:0;}.sq3bzv4[data-selected='1']{color:var(--text-color-selected);background:var(--bg-color-selected);}.sq3bzv4[data-hidden='1']{visibility:hidden;}.sq3bzv4[data-disabled='1']{opacity:0.25;cursor:default;}.sq3bzv4[data-selected='0'][data-disabled='0']:hover{background:var(--btn-hover);}.sq3bzv4[data-disabled='0']{cursor:pointer;}.sq3bzv4 svg{fill:currentColor;width:20px;height:20px;}.sq3bzv4 input{position:absolute;visibility:hidden;}
|
|
41
|
+
.sst453j{width:100%;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:2px 6px;}
|
|
42
|
+
.s1q5lsc2{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
43
|
+
.s1dis2j8{-webkit-flex:1;-ms-flex:1;flex:1;text-align:left;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.s1dis2j8 + .s1q5lsc2{margin-left:12px;}
|
|
44
|
+
.s1xzg253{position:absolute;z-index:3;background:var(--bg-color);bottom:100%;box-shadow:0 3px 8px rgb(0 0 0 / 24%);padding:4px;border-radius:8px;white-space:nowrap;}.s1xzg253[data-alignment='left']{left:0;margin:4px;}.s1xzg253[data-alignment='center']{left:50%;-webkit-transform:translate3d(-50%,0px,0px);-ms-transform:translate3d(-50%,0px,0px);transform:translate3d(-50%,0px,0px);margin:4px 0px;}.s1xzg253[data-alignment='right']{right:0;margin:4px;}
|
|
45
|
+
.s17qj3jh{margin-bottom:8px;margin-top:4px;font-size:18px;}
|
|
46
|
+
.su3a8bs{display:inline-block;background:var(--bg-color);box-sizing:border-box;overflow-y:auto;min-width:200px;}
|
|
47
|
+
.szboplp{border:3px solid transparent;padding:4px 0px;position:relative;background:var(--bg-color);box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;}.szboplp[data-is-over='1']{border:3px dotted var(--btn-hover);}.szboplp[data-is-dragging='1']{opacity:0.4;}.szboplp[data-selected='1']{color:var(--text-color-selected);border:3px solid var(--bg-color-selected);}.szboplp[data-selected='0'][data-disabled='0']:hover{background:var(--btn-hover);}.szboplp[data-disabled='1']{opacity:0.25;cursor:default;}.szboplp[data-disabled='0']{cursor:move;}.szboplp > span{height:20px;}.szboplp > span > svg{fill:#8a8a8a;width:20px;height:20px;padding:0 16px;}
|
|
48
|
+
.sff5xt[data-visible='false']{opacity:0.2;}
|
|
49
|
+
.sj3bift[data-locked='false']{opacity:0.2;}
|
|
50
|
+
.s10ip0a4[data-grid='false'] svg{opacity:0.2;}
|
|
51
|
+
.s1j9uq9o{-webkit-flex:1;-ms-flex:1;flex:1;}
|
|
52
|
+
.s156ddbb{bottom:0;left:unset;top:unset;max-height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
|
|
53
|
+
.s11gt4hl{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow-y:auto;}.s11gt4hl hr{opacity:0.6;width:100%;border:none;border-top:1px solid var(--text-color);}
|
|
54
|
+
.s13cxqhq{opacity:0.6;text-align:center;padding:12px 0px;}
|
|
55
|
+
.s1bvz4xj{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;bottom:unset;top:100%;}.s1bvz4xj[data-vertical='1']{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
|
|
56
|
+
.siejlch{position:relative;display:inline-block;}
|
|
57
|
+
.s1uphjfh{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;bottom:unset;top:100%;}.s1uphjfh[data-vertical='1']{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}.s1uphjfh hr{width:100%;border:none;border-top:1px solid var(--text-color);opacity:0.6;}
|
|
58
|
+
.s1e5a6k5{position:relative;display:inline-block;}
|
|
59
|
+
.s1c8tp02{z-index:3;position:absolute;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;left:0;right:0;bottom:0;top:0;}
|
|
60
|
+
.svkxpz4{display:grid;background:var(--bg-color);box-shadow:0 3px 8px rgb(0 0 0 / 24%);padding:4px;border-radius:8px;white-space:nowrap;position:relative;}
|
|
61
|
+
.s1s9jyyg{position:absolute;left:0;top:0;right:0;bottom:0;background:#00000073;}
|
|
62
|
+
.s95bkm9 form{grid-template-columns:3fr 1fr 1fr;}.s95bkm9 form input{color:var(--text-color);border:2px solid var(--text-color);outline:none;}
|
|
63
|
+
.so6hnjf{-webkit-flex:1;-ms-flex:1;flex:1;position:relative;height:100%;text-align:center;max-height:72px;}
|
|
64
|
+
.s1c1dllr{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;max-height:36px;background:var(--bg-color);}
|
|
65
|
+
.s1g032mh{display:inline-block;text-align:left;background:var(--bg-color);margin-right:36px;text-align:right;}.s1g032mh + *{position:absolute;right:0;bottom:36px;}
|
|
66
|
+
.s4owjrv{grid-template-columns:1fr 1fr 1fr;}
|
|
67
|
+
.snh2jyk{width:24px;height:24px;box-sizing:border-box;border-radius:50%;border:1px solid gray;background:var(--snh2jyk-0);background-repeat:repeat;background-size:16px;}
|
|
68
|
+
.sfm1cqx{width:36px;height:36px;box-sizing:border-box;border-radius:50%;color:var(--sfm1cqx-0);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:baseline;-webkit-box-align:baseline;-ms-flex-align:baseline;align-items:baseline;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;font-size:48px;line-height:36px;position:relative;bottom:6px;font-weight:bold;}
|
|
69
|
+
.sttf061{border-radius:50%;}
|
|
70
|
+
.layoutPanelOpened .sj7hhjx{color:var(--text-color-selected);background:var(--bg-color-selected);}.sj7hhjx[data-hidden='1']{display:none;}
|
|
71
|
+
.s9mugpt{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
72
|
+
.s1ktxhkr{padding:16px;}
|
|
73
|
+
.smpmxx5{font-family:var(--smpmxx5-0);}
|
|
74
|
+
|
|
75
|
+
.s1qssg4n{display:inline-block;width:6px;height:2px;background:transparent;vertical-align:middle;}
|
|
76
|
+
.se26iq6{display:inline-block;}.se26iq6[data-type='0'] .s1qssg4n{background:black;}.se26iq6[data-type='1']{position:relative;left:3px;}.se26iq6[data-type='1'] .s1qssg4n:nth-child(3n-1){background:black;width:12px;}.se26iq6[data-type='1'] .s1qssg4n:nth-child(n+11){display:none;}.se26iq6[data-type='2'] .s1qssg4n:nth-child(2n+1){background:black;}
|
|
77
|
+
.s1xxj4yl{position:absolute;left:0;top:50%;-webkit-transform:translate3d(-25%,-50%,0px);-ms-transform:translate3d(-25%,-50%,0px);transform:translate3d(-25%,-50%,0px);display:inline-block;width:0;height:0;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:15px solid black;}
|
|
78
|
+
.sbd6jc8{position:absolute;right:0;top:50%;-webkit-transform:translate3d(25%,-50%,0px);-ms-transform:translate3d(25%,-50%,0px);transform:translate3d(25%,-50%,0px);display:inline-block;width:0;height:0;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:15px solid black;}
|
|
79
|
+
.scawaat{position:relative;display:inline-block;width:60px;height:2px;background:black;vertical-align:middle;}.scawaat[data-type='0'] .s1xxj4yl,.scawaat[data-type='1'] .s1xxj4yl{display:none;}.scawaat[data-type='0'] .sbd6jc8,.scawaat[data-type='2'] .sbd6jc8{display:none;}
|
|
80
|
+
.s16z54di{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;background:var(--bg-color);position:relative;}
|
|
81
|
+
.sa7lzh9{-webkit-flex:1;-ms-flex:1;flex:1;}
|
|
82
|
+
.s1xssqat{display:inline-block;padding:12px 48px;margin:4px;max-width:calc(100% - 24px);overflow-wrap:break-word;box-sizing:border-box;-webkit-transition:all 500ms;transition:all 500ms;opacity:0;-webkit-transform:translate3d(0px,40px,0px);-ms-transform:translate3d(0px,40px,0px);transform:translate3d(0px,40px,0px);}.s1xssqat[data-type='0']{background:#646464;color:white;}.s1xssqat[data-type='1']{background:#c3a200;color:black;}.s1xssqat[data-type='2']{background:#911717;color:white;}.s1xssqat[data-type='3']{background:#088900;color:white;}.s1xssqat[data-is-shown='1']{opacity:1;-webkit-transform:translate3d(0px,0px,0px);-ms-transform:translate3d(0px,0px,0px);transform:translate3d(0px,0px,0px);}.s1xssqat[data-is-shown='0']{opacity:0;-webkit-transform:translate3d(0px,40px,0px);-ms-transform:translate3d(0px,40px,0px);transform:translate3d(0px,40px,0px);}
|
|
83
|
+
.s1bgtt22{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;position:absolute;z-index:4;bottom:0;left:0;right:0;height:0px;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
84
|
+
.s9j48u3{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;position:absolute;z-index:2;top:0;bottom:0;left:0;right:0;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:#00000050;-webkit-transition:opacity 300ms linear;transition:opacity 300ms linear;opacity:0;}.s9j48u3[data-loading='visible']{opacity:1;}
|
|
85
|
+
.s4auclc{width:40px;height:40px;position:relative;-webkit-transform:rotate(10deg);-ms-transform:rotate(10deg);transform:rotate(10deg);-webkit-animation:react-paint-editor-rotation-s4auclc 1s infinite;animation:react-paint-editor-rotation-s4auclc 1s infinite;}@-webkit-keyframes react-paint-editor-rotation-s4auclc{from{-webkit-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}@keyframes react-paint-editor-rotation-s4auclc{from{-webkit-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}
|
|
86
|
+
.s1l3fbq{border-radius:50%;position:absolute;width:15px;height:15px;}.s1l3fbq:nth-child(1){left:0;background-color:#5c6bc0;}.s1l3fbq:nth-child(2){right:0;background-color:#8bc34a;}.s1l3fbq:nth-child(3){bottom:0;background-color:#ffb74d;}.s1l3fbq:nth-child(4){bottom:0;right:0;background-color:#f44336;}
|
|
87
|
+
.s1v9piyg{--bg-color:white;--text-color:#364181;--btn-hover:#afd8d8;--bg-color-selected:#364181;--text-color-selected:white;--shrinkedcanvas-bg-color:white;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;color:var(--text-color);position:relative;overflow:hidden;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}.s1v9piyg[data-grow='false']{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;max-width:var(--s1v9piyg-0);}.s1v9piyg[data-shrink='false']{min-width:var(--s1v9piyg-1);}
|
|
88
|
+
.s6o5tmu{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;position:relative;max-width:100%;z-index:1;aspect-ratio:var(--s6o5tmu-2);}.layoutPanelOpened .s6o5tmu{background:var(--shrinkedcanvas-bg-color);}.s6o5tmu[data-grow='true']{width:100%;}.s6o5tmu[data-grow='false']{width:var(--s6o5tmu-1);}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Point, DrawableShape } from './Shapes';
|
|
2
|
+
export declare enum SelectionModeLib {
|
|
3
|
+
'default' = "default",
|
|
4
|
+
'brush' = "brush",
|
|
5
|
+
'resize' = "resize",
|
|
6
|
+
'rotate' = "rotate",
|
|
7
|
+
'translate' = "translate",
|
|
8
|
+
'textedition' = "textedition"
|
|
9
|
+
}
|
|
10
|
+
export declare type SelectionModeDefault = {
|
|
11
|
+
mode: SelectionModeLib.default;
|
|
12
|
+
};
|
|
13
|
+
export declare type SelectionModeBrush = {
|
|
14
|
+
mode: SelectionModeLib.brush;
|
|
15
|
+
};
|
|
16
|
+
export declare type SelectionModeEditText = {
|
|
17
|
+
mode: SelectionModeLib.textedition;
|
|
18
|
+
defaultValue: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare type SelectionModeResize<AnchorType extends Point | number = Point> = {
|
|
21
|
+
mode: SelectionModeLib.resize;
|
|
22
|
+
cursorStartPosition: Point;
|
|
23
|
+
originalShape: DrawableShape;
|
|
24
|
+
anchor: AnchorType;
|
|
25
|
+
};
|
|
26
|
+
export declare type SelectionModeRotate = {
|
|
27
|
+
mode: SelectionModeLib.rotate;
|
|
28
|
+
cursorStartPosition: Point;
|
|
29
|
+
originalShape: DrawableShape;
|
|
30
|
+
center: Point;
|
|
31
|
+
};
|
|
32
|
+
export declare type SelectionModeTranslate = {
|
|
33
|
+
mode: SelectionModeLib.translate;
|
|
34
|
+
cursorStartPosition: Point;
|
|
35
|
+
originalShape: DrawableShape;
|
|
36
|
+
};
|
|
37
|
+
export declare type SelectionModeData<AnchorType extends Point | number> = SelectionModeDefault | SelectionModeBrush | SelectionModeResize<AnchorType> | SelectionModeRotate | SelectionModeTranslate | SelectionModeEditText;
|
|
38
|
+
export declare type HoverModeData = {
|
|
39
|
+
mode: SelectionModeLib.default;
|
|
40
|
+
} | {
|
|
41
|
+
mode: SelectionModeLib.resize;
|
|
42
|
+
anchor: Point | number;
|
|
43
|
+
} | {
|
|
44
|
+
mode: SelectionModeLib.brush;
|
|
45
|
+
} | {
|
|
46
|
+
mode: SelectionModeLib.rotate;
|
|
47
|
+
} | {
|
|
48
|
+
mode: SelectionModeLib.translate;
|
|
49
|
+
} | {
|
|
50
|
+
mode: SelectionModeLib.textedition;
|
|
51
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SelectionModeLib = void 0;
|
|
7
|
+
var SelectionModeLib;
|
|
8
|
+
exports.SelectionModeLib = SelectionModeLib;
|
|
9
|
+
|
|
10
|
+
(function (SelectionModeLib) {
|
|
11
|
+
SelectionModeLib["default"] = "default";
|
|
12
|
+
SelectionModeLib["brush"] = "brush";
|
|
13
|
+
SelectionModeLib["resize"] = "resize";
|
|
14
|
+
SelectionModeLib["rotate"] = "rotate";
|
|
15
|
+
SelectionModeLib["translate"] = "translate";
|
|
16
|
+
SelectionModeLib["textedition"] = "textedition";
|
|
17
|
+
})(SelectionModeLib || (exports.SelectionModeLib = SelectionModeLib = {}));
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export declare enum ShapeEnum {
|
|
2
|
+
'brush' = "brush",
|
|
3
|
+
'rect' = "rect",
|
|
4
|
+
'square' = "square",
|
|
5
|
+
'line' = "line",
|
|
6
|
+
'polygon' = "polygon",
|
|
7
|
+
'circle' = "circle",
|
|
8
|
+
'curve' = "curve",
|
|
9
|
+
'ellipse' = "ellipse",
|
|
10
|
+
'picture' = "picture",
|
|
11
|
+
'text' = "text"
|
|
12
|
+
}
|
|
13
|
+
export declare enum ToolEnum {
|
|
14
|
+
selection = "selection",
|
|
15
|
+
undo = "undo",
|
|
16
|
+
redo = "redo",
|
|
17
|
+
clear = "clear",
|
|
18
|
+
export = "export",
|
|
19
|
+
loadFile = "loadfile",
|
|
20
|
+
saveFile = "savefile",
|
|
21
|
+
move = "move"
|
|
22
|
+
}
|
|
23
|
+
export declare type ToolsType = ShapeEnum | ToolEnum;
|
|
24
|
+
export declare type Point = [number, number];
|
|
25
|
+
export declare type StyledShape = {
|
|
26
|
+
visible?: boolean;
|
|
27
|
+
locked?: boolean;
|
|
28
|
+
style?: {
|
|
29
|
+
fillColor?: string;
|
|
30
|
+
globalAlpha?: number;
|
|
31
|
+
strokeColor?: string;
|
|
32
|
+
lineWidth?: number;
|
|
33
|
+
lineDash?: number;
|
|
34
|
+
lineArrow?: number;
|
|
35
|
+
pointsCount?: number;
|
|
36
|
+
fontFamily?: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
declare type Drawable = {
|
|
40
|
+
id: string;
|
|
41
|
+
translation: Point;
|
|
42
|
+
rotation: number;
|
|
43
|
+
};
|
|
44
|
+
export declare type Rect = StyledShape & {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
export declare type Square = Rect;
|
|
51
|
+
export declare type StoredPicture = Rect & {
|
|
52
|
+
src: string;
|
|
53
|
+
};
|
|
54
|
+
export declare type Picture = StoredPicture & {
|
|
55
|
+
img: HTMLImageElement;
|
|
56
|
+
};
|
|
57
|
+
export declare type Text = Rect & {
|
|
58
|
+
value: string[];
|
|
59
|
+
fontSize: number;
|
|
60
|
+
};
|
|
61
|
+
export declare type Line = StyledShape & {
|
|
62
|
+
points: [Point, Point];
|
|
63
|
+
};
|
|
64
|
+
export declare type Triangle = StyledShape & {
|
|
65
|
+
points: [Point, Point, Point];
|
|
66
|
+
};
|
|
67
|
+
export declare type Polygon = StyledShape & {
|
|
68
|
+
points: Point[];
|
|
69
|
+
};
|
|
70
|
+
export declare type Curve = StyledShape & {
|
|
71
|
+
points: Point[];
|
|
72
|
+
};
|
|
73
|
+
export declare type Brush = StyledShape & {
|
|
74
|
+
points: Point[][];
|
|
75
|
+
};
|
|
76
|
+
export declare type Circle = StyledShape & {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
radius: number;
|
|
80
|
+
};
|
|
81
|
+
export declare type Ellipse = StyledShape & {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
radiusX: number;
|
|
85
|
+
radiusY: number;
|
|
86
|
+
};
|
|
87
|
+
export declare type DrawableRect = Rect & Drawable & {
|
|
88
|
+
type: ShapeEnum.rect;
|
|
89
|
+
};
|
|
90
|
+
export declare type DrawableSquare = Square & Drawable & {
|
|
91
|
+
type: ShapeEnum.square;
|
|
92
|
+
};
|
|
93
|
+
export declare type DrawablePictureJson = StoredPicture & Drawable & {
|
|
94
|
+
type: ShapeEnum.picture;
|
|
95
|
+
};
|
|
96
|
+
export declare type DrawablePicture = Picture & Drawable & {
|
|
97
|
+
type: ShapeEnum.picture;
|
|
98
|
+
};
|
|
99
|
+
export declare type DrawableText = Text & Drawable & {
|
|
100
|
+
type: ShapeEnum.text;
|
|
101
|
+
};
|
|
102
|
+
export declare type DrawableLine = Line & Drawable & {
|
|
103
|
+
type: ShapeEnum.line;
|
|
104
|
+
};
|
|
105
|
+
export declare type DrawablePolygon = Polygon & Drawable & {
|
|
106
|
+
type: ShapeEnum.polygon;
|
|
107
|
+
};
|
|
108
|
+
export declare type DrawableCurve = Curve & Drawable & {
|
|
109
|
+
type: ShapeEnum.curve;
|
|
110
|
+
};
|
|
111
|
+
export declare type DrawableBrush = Brush & Drawable & {
|
|
112
|
+
type: ShapeEnum.brush;
|
|
113
|
+
};
|
|
114
|
+
export declare type DrawableCircle = Circle & Drawable & {
|
|
115
|
+
type: ShapeEnum.circle;
|
|
116
|
+
};
|
|
117
|
+
export declare type DrawableEllipse = Ellipse & Drawable & {
|
|
118
|
+
type: ShapeEnum.ellipse;
|
|
119
|
+
};
|
|
120
|
+
export declare type DrawableShape = DrawableRect | DrawableSquare | DrawablePicture | DrawableText | DrawableLine | DrawablePolygon | DrawableCurve | DrawableBrush | DrawableCircle | DrawableEllipse;
|
|
121
|
+
export declare type DrawableShapeJson = DrawableRect | DrawableSquare | DrawablePictureJson | DrawableText | DrawableLine | DrawableCurve | DrawablePolygon | DrawableBrush | DrawableCircle | DrawableEllipse;
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ToolEnum = exports.ShapeEnum = void 0;
|
|
7
|
+
var ShapeEnum;
|
|
8
|
+
exports.ShapeEnum = ShapeEnum;
|
|
9
|
+
|
|
10
|
+
(function (ShapeEnum) {
|
|
11
|
+
ShapeEnum["brush"] = "brush";
|
|
12
|
+
ShapeEnum["rect"] = "rect";
|
|
13
|
+
ShapeEnum["square"] = "square";
|
|
14
|
+
ShapeEnum["line"] = "line";
|
|
15
|
+
ShapeEnum["polygon"] = "polygon";
|
|
16
|
+
ShapeEnum["circle"] = "circle";
|
|
17
|
+
ShapeEnum["curve"] = "curve";
|
|
18
|
+
ShapeEnum["ellipse"] = "ellipse";
|
|
19
|
+
ShapeEnum["picture"] = "picture";
|
|
20
|
+
ShapeEnum["text"] = "text";
|
|
21
|
+
})(ShapeEnum || (exports.ShapeEnum = ShapeEnum = {}));
|
|
22
|
+
|
|
23
|
+
var ToolEnum;
|
|
24
|
+
exports.ToolEnum = ToolEnum;
|
|
25
|
+
|
|
26
|
+
(function (ToolEnum) {
|
|
27
|
+
ToolEnum["selection"] = "selection";
|
|
28
|
+
ToolEnum["undo"] = "undo";
|
|
29
|
+
ToolEnum["redo"] = "redo";
|
|
30
|
+
ToolEnum["clear"] = "clear";
|
|
31
|
+
ToolEnum["export"] = "export";
|
|
32
|
+
ToolEnum["loadFile"] = "loadfile";
|
|
33
|
+
ToolEnum["saveFile"] = "savefile";
|
|
34
|
+
ToolEnum["move"] = "move";
|
|
35
|
+
})(ToolEnum || (exports.ToolEnum = ToolEnum = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum KeyboardCode {
|
|
2
|
+
ArrowUp = "ArrowUp",
|
|
3
|
+
ArrowDown = "ArrowDown",
|
|
4
|
+
ArrowLeft = "ArrowLeft",
|
|
5
|
+
ArrowRight = "ArrowRight",
|
|
6
|
+
Delete = "Delete",
|
|
7
|
+
Backspace = "Backspace",
|
|
8
|
+
Escape = "Escape",
|
|
9
|
+
Z = "z",
|
|
10
|
+
Y = "y"
|
|
11
|
+
}
|
|
12
|
+
export declare enum KeyboardCommand {
|
|
13
|
+
Copy = "copy",
|
|
14
|
+
Paste = "paste"
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KeyboardCommand = exports.KeyboardCode = void 0;
|
|
7
|
+
var KeyboardCode;
|
|
8
|
+
exports.KeyboardCode = KeyboardCode;
|
|
9
|
+
|
|
10
|
+
(function (KeyboardCode) {
|
|
11
|
+
KeyboardCode["ArrowUp"] = "ArrowUp";
|
|
12
|
+
KeyboardCode["ArrowDown"] = "ArrowDown";
|
|
13
|
+
KeyboardCode["ArrowLeft"] = "ArrowLeft";
|
|
14
|
+
KeyboardCode["ArrowRight"] = "ArrowRight";
|
|
15
|
+
KeyboardCode["Delete"] = "Delete";
|
|
16
|
+
KeyboardCode["Backspace"] = "Backspace";
|
|
17
|
+
KeyboardCode["Escape"] = "Escape";
|
|
18
|
+
KeyboardCode["Z"] = "z";
|
|
19
|
+
KeyboardCode["Y"] = "y";
|
|
20
|
+
})(KeyboardCode || (exports.KeyboardCode = KeyboardCode = {}));
|
|
21
|
+
|
|
22
|
+
var KeyboardCommand;
|
|
23
|
+
exports.KeyboardCommand = KeyboardCommand;
|
|
24
|
+
|
|
25
|
+
(function (KeyboardCommand) {
|
|
26
|
+
KeyboardCommand["Copy"] = "copy";
|
|
27
|
+
KeyboardCommand["Paste"] = "paste";
|
|
28
|
+
})(KeyboardCommand || (exports.KeyboardCommand = KeyboardCommand = {}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DrawablePicture, Point, DrawableShape, ShapeEnum, StyledShape } from 'types/Shapes';
|
|
2
|
+
export declare const createPicture: (fileOrUrl: File | string, maxPictureSize: number) => Promise<DrawablePicture>;
|
|
3
|
+
export declare const createShape: (ctx: CanvasRenderingContext2D, shape: ShapeEnum, cursorPosition: Point, defaultConf: StyledShape) => DrawableShape;
|
|
4
|
+
export declare const copyShape: (shape: DrawableShape) => DrawableShape;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createShape = exports.createPicture = exports.copyShape = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
13
|
+
|
|
14
|
+
var _transform = require("./transform");
|
|
15
|
+
|
|
16
|
+
var _Shapes = require("../types/Shapes");
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
|
|
22
|
+
var createPicture = function createPicture(fileOrUrl, maxPictureSize) {
|
|
23
|
+
return new Promise(function (resolve, reject) {
|
|
24
|
+
var img = new Image();
|
|
25
|
+
|
|
26
|
+
img.onload = function () {
|
|
27
|
+
var maxSize = Math.min(Math.max(img.width, img.height), maxPictureSize);
|
|
28
|
+
var imgRatio = img.width / img.height;
|
|
29
|
+
var pictureShape = {
|
|
30
|
+
type: _Shapes.ShapeEnum.picture,
|
|
31
|
+
id: _fp["default"].uniqueId(_Shapes.ShapeEnum.picture),
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
width: imgRatio < 1 ? imgRatio * maxSize : maxSize,
|
|
35
|
+
height: imgRatio > 1 ? maxSize / imgRatio : maxSize,
|
|
36
|
+
src: img.src,
|
|
37
|
+
img: img,
|
|
38
|
+
translation: [0, 0],
|
|
39
|
+
rotation: 0
|
|
40
|
+
};
|
|
41
|
+
resolve(pictureShape);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (fileOrUrl instanceof File) {
|
|
45
|
+
img.src = URL.createObjectURL(fileOrUrl);
|
|
46
|
+
} else {
|
|
47
|
+
img.src = fileOrUrl;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
img.onerror = function () {
|
|
51
|
+
reject(new Error('Error while loading the src'));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
setTimeout(function () {
|
|
55
|
+
reject(new Error('Timeout while loading the src'));
|
|
56
|
+
}, 4000);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.createPicture = createPicture;
|
|
61
|
+
|
|
62
|
+
var createShape = function createShape(ctx, shape, cursorPosition, defaultConf) {
|
|
63
|
+
var _defaultConf$style$po, _defaultConf$style, _defaultConf$style$po2, _defaultConf$style2, _defaultConf$style3;
|
|
64
|
+
|
|
65
|
+
switch (shape) {
|
|
66
|
+
case _Shapes.ShapeEnum.brush:
|
|
67
|
+
return {
|
|
68
|
+
type: _Shapes.ShapeEnum.brush,
|
|
69
|
+
id: _fp["default"].uniqueId(shape),
|
|
70
|
+
points: [[cursorPosition]],
|
|
71
|
+
translation: [0, 0],
|
|
72
|
+
rotation: 0,
|
|
73
|
+
style: defaultConf.style
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
case _Shapes.ShapeEnum.line:
|
|
77
|
+
return {
|
|
78
|
+
type: _Shapes.ShapeEnum.line,
|
|
79
|
+
id: _fp["default"].uniqueId(shape),
|
|
80
|
+
points: [cursorPosition, cursorPosition],
|
|
81
|
+
translation: [0, 0],
|
|
82
|
+
rotation: 0,
|
|
83
|
+
style: defaultConf.style
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
case _Shapes.ShapeEnum.polygon:
|
|
87
|
+
return {
|
|
88
|
+
type: _Shapes.ShapeEnum.polygon,
|
|
89
|
+
id: _fp["default"].uniqueId(shape),
|
|
90
|
+
points: _fp["default"].flow(_fp["default"].range(0), _fp["default"].map(function () {
|
|
91
|
+
return cursorPosition;
|
|
92
|
+
}))((_defaultConf$style$po = (_defaultConf$style = defaultConf.style) === null || _defaultConf$style === void 0 ? void 0 : _defaultConf$style.pointsCount) !== null && _defaultConf$style$po !== void 0 ? _defaultConf$style$po : 3),
|
|
93
|
+
translation: [0, 0],
|
|
94
|
+
rotation: 0,
|
|
95
|
+
style: defaultConf.style
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
case _Shapes.ShapeEnum.curve:
|
|
99
|
+
return {
|
|
100
|
+
type: _Shapes.ShapeEnum.curve,
|
|
101
|
+
id: _fp["default"].uniqueId(shape),
|
|
102
|
+
points: _fp["default"].flow(_fp["default"].range(0), _fp["default"].map(function () {
|
|
103
|
+
return cursorPosition;
|
|
104
|
+
}))((_defaultConf$style$po2 = (_defaultConf$style2 = defaultConf.style) === null || _defaultConf$style2 === void 0 ? void 0 : _defaultConf$style2.pointsCount) !== null && _defaultConf$style$po2 !== void 0 ? _defaultConf$style$po2 : 3),
|
|
105
|
+
translation: [0, 0],
|
|
106
|
+
rotation: 0,
|
|
107
|
+
style: defaultConf.style
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
case _Shapes.ShapeEnum.rect:
|
|
111
|
+
case _Shapes.ShapeEnum.square:
|
|
112
|
+
return {
|
|
113
|
+
type: shape,
|
|
114
|
+
id: _fp["default"].uniqueId(shape),
|
|
115
|
+
x: cursorPosition[0],
|
|
116
|
+
y: cursorPosition[1],
|
|
117
|
+
width: 1,
|
|
118
|
+
height: 1,
|
|
119
|
+
translation: [0, 0],
|
|
120
|
+
rotation: 0,
|
|
121
|
+
style: defaultConf.style
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
case _Shapes.ShapeEnum.text:
|
|
125
|
+
var defaultValue = [];
|
|
126
|
+
var fontSize = (0, _transform.calculateTextFontSize)(ctx, defaultValue, 50, (_defaultConf$style3 = defaultConf.style) === null || _defaultConf$style3 === void 0 ? void 0 : _defaultConf$style3.fontFamily);
|
|
127
|
+
return {
|
|
128
|
+
type: _Shapes.ShapeEnum.text,
|
|
129
|
+
id: _fp["default"].uniqueId(shape),
|
|
130
|
+
x: cursorPosition[0],
|
|
131
|
+
y: cursorPosition[1],
|
|
132
|
+
value: defaultValue,
|
|
133
|
+
fontSize: fontSize,
|
|
134
|
+
width: 50,
|
|
135
|
+
height: fontSize * (defaultValue.length || 1),
|
|
136
|
+
translation: [0, 0],
|
|
137
|
+
rotation: 0,
|
|
138
|
+
style: defaultConf.style
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
case _Shapes.ShapeEnum.ellipse:
|
|
142
|
+
return {
|
|
143
|
+
type: _Shapes.ShapeEnum.ellipse,
|
|
144
|
+
id: _fp["default"].uniqueId(shape),
|
|
145
|
+
x: cursorPosition[0],
|
|
146
|
+
y: cursorPosition[1],
|
|
147
|
+
radiusX: 0,
|
|
148
|
+
radiusY: 0,
|
|
149
|
+
translation: [0, 0],
|
|
150
|
+
rotation: 0,
|
|
151
|
+
style: defaultConf.style
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
case _Shapes.ShapeEnum.circle:
|
|
155
|
+
default:
|
|
156
|
+
return {
|
|
157
|
+
type: _Shapes.ShapeEnum.circle,
|
|
158
|
+
id: _fp["default"].uniqueId(shape),
|
|
159
|
+
x: cursorPosition[0],
|
|
160
|
+
y: cursorPosition[1],
|
|
161
|
+
radius: 0,
|
|
162
|
+
translation: [0, 0],
|
|
163
|
+
rotation: 0,
|
|
164
|
+
style: defaultConf.style
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
exports.createShape = createShape;
|
|
170
|
+
|
|
171
|
+
var copyShape = function copyShape(shape) {
|
|
172
|
+
return _objectSpread(_objectSpread({}, shape), {}, {
|
|
173
|
+
id: _fp["default"].uniqueId(shape.type),
|
|
174
|
+
translation: [shape.translation[0] + 20, shape.translation[1] + 20]
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
exports.copyShape = copyShape;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Circle, Ellipse, Line, Picture, Polygon, Rect, DrawableShape, Point, Brush, Text, Triangle, Curve } from 'types/Shapes';
|
|
2
|
+
export declare const drawBrush: (ctx: CanvasRenderingContext2D, brush: Brush) => void;
|
|
3
|
+
export declare const drawTriangle: (ctx: CanvasRenderingContext2D, triangle: Triangle) => void;
|
|
4
|
+
export declare const drawLine: (ctx: CanvasRenderingContext2D, line: Line) => void;
|
|
5
|
+
export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: Polygon) => void;
|
|
6
|
+
export declare const drawCurve: (ctx: CanvasRenderingContext2D, curve: Curve) => void;
|
|
7
|
+
export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: Circle) => void;
|
|
8
|
+
export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: Ellipse) => void;
|
|
9
|
+
export declare const drawRect: (ctx: CanvasRenderingContext2D, rect: Rect) => void;
|
|
10
|
+
export declare const drawText: (ctx: CanvasRenderingContext2D, text: Text) => void;
|
|
11
|
+
export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: Picture) => void;
|
|
12
|
+
export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, canvasOffset: Point) => void;
|
|
13
|
+
export declare const drawSelection: ({ ctx, shape, canvasOffset, withAnchors }: {
|
|
14
|
+
ctx: CanvasRenderingContext2D;
|
|
15
|
+
shape: DrawableShape;
|
|
16
|
+
canvasOffset: Point;
|
|
17
|
+
withAnchors?: boolean | undefined;
|
|
18
|
+
}) => void;
|