ziko 0.0.1

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.
Files changed (226) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +316 -0
  3. package/dist/ziko.cjs +9786 -0
  4. package/dist/ziko.js +9792 -0
  5. package/dist/ziko.min.js +9 -0
  6. package/dist/ziko.mjs +9567 -0
  7. package/package.json +55 -0
  8. package/src/App/Accessibility/index.js +0 -0
  9. package/src/App/Globals/__Target__.js +3 -0
  10. package/src/App/Globals/__UI__.js +38 -0
  11. package/src/App/Globals/__init__.js +8 -0
  12. package/src/App/Globals/index.js +3 -0
  13. package/src/App/Router/index.js +40 -0
  14. package/src/App/Seo/index.js +43 -0
  15. package/src/App/Themes/dark.js +885 -0
  16. package/src/App/Themes/index.js +11 -0
  17. package/src/App/Themes/light.js +255 -0
  18. package/src/App/app.js +37 -0
  19. package/src/App/index.js +11 -0
  20. package/src/Data/Api/fetchdom.js +14 -0
  21. package/src/Data/Api/index.js +4 -0
  22. package/src/Data/Api/preload.js +11 -0
  23. package/src/Data/Converter/canvas.js +25 -0
  24. package/src/Data/Converter/csv.js +33 -0
  25. package/src/Data/Converter/index.js +25 -0
  26. package/src/Data/Converter/json.js +80 -0
  27. package/src/Data/Converter/markdown.js +83 -0
  28. package/src/Data/Converter/svg.js +11 -0
  29. package/src/Data/Parser/markdown.js +0 -0
  30. package/src/Data/Parser/xml.js +47 -0
  31. package/src/Data/Strings/index.js +26 -0
  32. package/src/Data/decorators.js +0 -0
  33. package/src/Data/index.js +64 -0
  34. package/src/Graphics/Canvas/Elements/Basic/arc.js +43 -0
  35. package/src/Graphics/Canvas/Elements/Basic/image.js +0 -0
  36. package/src/Graphics/Canvas/Elements/Basic/line.js +26 -0
  37. package/src/Graphics/Canvas/Elements/Basic/path.js +0 -0
  38. package/src/Graphics/Canvas/Elements/Basic/points.js +48 -0
  39. package/src/Graphics/Canvas/Elements/Basic/polygon.js +7 -0
  40. package/src/Graphics/Canvas/Elements/Basic/polyline.js +0 -0
  41. package/src/Graphics/Canvas/Elements/Basic/rect.js +46 -0
  42. package/src/Graphics/Canvas/Elements/Basic/text.js +0 -0
  43. package/src/Graphics/Canvas/Elements/Chart/histogram.js +0 -0
  44. package/src/Graphics/Canvas/Elements/Chart/plot.js +0 -0
  45. package/src/Graphics/Canvas/Elements/Chart/scatter.js +2 -0
  46. package/src/Graphics/Canvas/Elements/Chart/stem.js +0 -0
  47. package/src/Graphics/Canvas/Elements/Element.js +115 -0
  48. package/src/Graphics/Canvas/Elements/Groupe.js +0 -0
  49. package/src/Graphics/Canvas/Elements/grid.js +0 -0
  50. package/src/Graphics/Canvas/Elements/index.js +13 -0
  51. package/src/Graphics/Canvas/Filter/index.js +0 -0
  52. package/src/Graphics/Canvas/Paint/index.js +0 -0
  53. package/src/Graphics/Canvas/Utils/color.js +8 -0
  54. package/src/Graphics/Canvas/Utils/floodFill.js +58 -0
  55. package/src/Graphics/Canvas/_canvas_offscreen +0 -0
  56. package/src/Graphics/Canvas/canvas.js +189 -0
  57. package/src/Graphics/Canvas/index.js +15 -0
  58. package/src/Graphics/Svg/Elements/ZikoSvgElement.js +28 -0
  59. package/src/Graphics/Svg/Elements/circle.js +34 -0
  60. package/src/Graphics/Svg/Elements/ellipse.js +29 -0
  61. package/src/Graphics/Svg/Elements/foreignObject.js +46 -0
  62. package/src/Graphics/Svg/Elements/grid.js +9 -0
  63. package/src/Graphics/Svg/Elements/groupe.js +29 -0
  64. package/src/Graphics/Svg/Elements/image.js +33 -0
  65. package/src/Graphics/Svg/Elements/line.js +29 -0
  66. package/src/Graphics/Svg/Elements/path.js +59 -0
  67. package/src/Graphics/Svg/Elements/polygon.js +31 -0
  68. package/src/Graphics/Svg/Elements/polyline.js +4 -0
  69. package/src/Graphics/Svg/Elements/rect.js +43 -0
  70. package/src/Graphics/Svg/Elements/text.js +26 -0
  71. package/src/Graphics/Svg/index.js +1 -0
  72. package/src/Graphics/Svg/svg.js +117 -0
  73. package/src/Graphics/index.js +61 -0
  74. package/src/Math/Calculus/Special Functions/bessel.js +31 -0
  75. package/src/Math/Calculus/Special Functions/beta.js +38 -0
  76. package/src/Math/Calculus/Special Functions/gamma.js +30 -0
  77. package/src/Math/Calculus/Special Functions/index.js +4 -0
  78. package/src/Math/Calculus/index.js +1 -0
  79. package/src/Math/Complex/Fractals/julia.js +0 -0
  80. package/src/Math/Complex/index.js +191 -0
  81. package/src/Math/Discret/Combinaison/index.js +34 -0
  82. package/src/Math/Discret/Conversion/index.js +86 -0
  83. package/src/Math/Discret/Logic/index.js +46 -0
  84. package/src/Math/Discret/Permutation/index.js +31 -0
  85. package/src/Math/Discret/Set/index.js +2 -0
  86. package/src/Math/Discret/Set/powerSet.js +15 -0
  87. package/src/Math/Discret/Set/subSet.js +10 -0
  88. package/src/Math/Discret/index.js +23 -0
  89. package/src/Math/Functions/index.js +182 -0
  90. package/src/Math/Matrix/Decomposition.js +90 -0
  91. package/src/Math/Matrix/LinearSystem.js +10 -0
  92. package/src/Math/Matrix/Matrix.js +712 -0
  93. package/src/Math/Matrix/index.js +3 -0
  94. package/src/Math/Numeric/index.js +0 -0
  95. package/src/Math/Random/index.js +173 -0
  96. package/src/Math/Signal/__np.py.txt +40 -0
  97. package/src/Math/Signal/conv.js +175 -0
  98. package/src/Math/Signal/fft.js +55 -0
  99. package/src/Math/Signal/filter.js +39 -0
  100. package/src/Math/Signal/functions.js +146 -0
  101. package/src/Math/Signal/index.js +110 -0
  102. package/src/Math/Statistics/Functions/index.js +100 -0
  103. package/src/Math/Statistics/index.js +16 -0
  104. package/src/Math/Utils/arithmetic.js +139 -0
  105. package/src/Math/Utils/checkers.js +11 -0
  106. package/src/Math/Utils/comparaison.js +1 -0
  107. package/src/Math/Utils/conversions.js +7 -0
  108. package/src/Math/Utils/discret.js +28 -0
  109. package/src/Math/Utils/index.js +102 -0
  110. package/src/Math/Utils/mapfun.js +43 -0
  111. package/src/Math/absract.js +1 -0
  112. package/src/Math/const.js +3 -0
  113. package/src/Math/index.js +193 -0
  114. package/src/Reactivity/Events/Global/Click.js +56 -0
  115. package/src/Reactivity/Events/Global/Clipboard.js +84 -0
  116. package/src/Reactivity/Events/Global/CustomEvent.js +53 -0
  117. package/src/Reactivity/Events/Global/Drag.js +137 -0
  118. package/src/Reactivity/Events/Global/Focus.js +56 -0
  119. package/src/Reactivity/Events/Global/Key.js +104 -0
  120. package/src/Reactivity/Events/Global/Pointer.js +214 -0
  121. package/src/Reactivity/Events/Partiel/Input.js +59 -0
  122. package/src/Reactivity/Events/ZikoEvent.js +91 -0
  123. package/src/Reactivity/Events/index.js +51 -0
  124. package/src/Reactivity/Observer/index.js +3 -0
  125. package/src/Reactivity/Observer/intersection.js +40 -0
  126. package/src/Reactivity/Observer/mutation.js +90 -0
  127. package/src/Reactivity/Observer/resize.js +47 -0
  128. package/src/Reactivity/Use/Contexte/index.js +1 -0
  129. package/src/Reactivity/Use/Contexte/useSuccesifKeys.js +14 -0
  130. package/src/Reactivity/Use/Decorators/index.js +4 -0
  131. package/src/Reactivity/Use/Interactions/index.js +4 -0
  132. package/src/Reactivity/Use/Interactions/useBluetooth.js +48 -0
  133. package/src/Reactivity/Use/Interactions/useChannel.js +50 -0
  134. package/src/Reactivity/Use/Interactions/useEventEmmiter.js +64 -0
  135. package/src/Reactivity/Use/Interactions/useSerial.js +0 -0
  136. package/src/Reactivity/Use/Interactions/useThread.js +44 -0
  137. package/src/Reactivity/Use/Interactions/useUsb.js +0 -0
  138. package/src/Reactivity/Use/Sensors/index.js +2 -0
  139. package/src/Reactivity/Use/Sensors/useBattery.js +36 -0
  140. package/src/Reactivity/Use/Sensors/useCamera.js +0 -0
  141. package/src/Reactivity/Use/Sensors/useGeolocation.js +17 -0
  142. package/src/Reactivity/Use/Sensors/useMicro.js +0 -0
  143. package/src/Reactivity/Use/Sensors/useOrientation.js +0 -0
  144. package/src/Reactivity/Use/Storage/index.js +1 -0
  145. package/src/Reactivity/Use/Storage/useCookie.js +0 -0
  146. package/src/Reactivity/Use/Storage/useIndexedDb.js +0 -0
  147. package/src/Reactivity/Use/Storage/useStorage.js +74 -0
  148. package/src/Reactivity/Use/UI/index.js +4 -0
  149. package/src/Reactivity/Use/UI/useCssLink.js +0 -0
  150. package/src/Reactivity/Use/UI/useCssText.js +21 -0
  151. package/src/Reactivity/Use/UI/useFavIcon.js +38 -0
  152. package/src/Reactivity/Use/UI/useLinearGradient.js +0 -0
  153. package/src/Reactivity/Use/UI/useMediaQuery.js +1 -0
  154. package/src/Reactivity/Use/UI/useRadialGradient.js +0 -0
  155. package/src/Reactivity/Use/UI/useStyle.js +54 -0
  156. package/src/Reactivity/Use/UI/useTheme.js +62 -0
  157. package/src/Reactivity/Use/UI/useTitle.js +30 -0
  158. package/src/Reactivity/Use/index.js +82 -0
  159. package/src/Reactivity/Use/todo.md +26 -0
  160. package/src/Reactivity/index.js +3 -0
  161. package/src/Time/animation.js +76 -0
  162. package/src/Time/index.js +54 -0
  163. package/src/Time/loop.js +83 -0
  164. package/src/Time/utils/decorators.js +17 -0
  165. package/src/Time/utils/ease.js +144 -0
  166. package/src/Time/utils/index.js +18 -0
  167. package/src/Time/utils/performance.js +16 -0
  168. package/src/Time/utils/ui.js +26 -0
  169. package/src/UI/CustomElement/Elements/Accordion/index.js +62 -0
  170. package/src/UI/CustomElement/Elements/Carousel/index.js +47 -0
  171. package/src/UI/CustomElement/Elements/CodeNote/CodeCell.js +176 -0
  172. package/src/UI/CustomElement/Elements/CodeNote/CodeNote.js +69 -0
  173. package/src/UI/CustomElement/Elements/CodeNote/SubElements.js +64 -0
  174. package/src/UI/CustomElement/Elements/CodeNote/index.js +2 -0
  175. package/src/UI/CustomElement/Elements/Columns.js +1 -0
  176. package/src/UI/CustomElement/Elements/FAB.js +0 -0
  177. package/src/UI/CustomElement/Elements/Menu.js +0 -0
  178. package/src/UI/CustomElement/Elements/Notification.js +0 -0
  179. package/src/UI/CustomElement/Elements/Popover.js +0 -0
  180. package/src/UI/CustomElement/Elements/Popup.js +0 -0
  181. package/src/UI/CustomElement/Elements/Swipper.js +4 -0
  182. package/src/UI/CustomElement/Elements/Tabs/index.js +111 -0
  183. package/src/UI/CustomElement/Elements/Timeline.js +0 -0
  184. package/src/UI/CustomElement/Elements/Toast.js +0 -0
  185. package/src/UI/CustomElement/Elements/Treeview.js +0 -0
  186. package/src/UI/CustomElement/Elements/index.js +4 -0
  187. package/src/UI/CustomElement/Flex.js +97 -0
  188. package/src/UI/CustomElement/Grid.js +30 -0
  189. package/src/UI/CustomElement/index.js +3 -0
  190. package/src/UI/Embaded/index.js +1 -0
  191. package/src/UI/Inputs/Primitives/btn.js +31 -0
  192. package/src/UI/Inputs/Primitives/elements.js +28 -0
  193. package/src/UI/Inputs/Primitives/inputs.js +334 -0
  194. package/src/UI/Inputs/Primitives/select.js +15 -0
  195. package/src/UI/Inputs/Primitives/textarea.js +16 -0
  196. package/src/UI/Inputs/camera.js +23 -0
  197. package/src/UI/Inputs/index.js +20 -0
  198. package/src/UI/List/elements.js +0 -0
  199. package/src/UI/List/index.js +130 -0
  200. package/src/UI/Media/Audio/index.js +26 -0
  201. package/src/UI/Media/Image/figure.js +17 -0
  202. package/src/UI/Media/Image/image.js +34 -0
  203. package/src/UI/Media/Image/index.js +2 -0
  204. package/src/UI/Media/Video/index.js +37 -0
  205. package/src/UI/Media/index.js +3 -0
  206. package/src/UI/Misc/index.js +49 -0
  207. package/src/UI/Semantic/index.js +68 -0
  208. package/src/UI/Style/index.js +499 -0
  209. package/src/UI/Table/elements.js +94 -0
  210. package/src/UI/Table/index.js +3 -0
  211. package/src/UI/Table/table.js +113 -0
  212. package/src/UI/Table/utils.js +12 -0
  213. package/src/UI/Text/heading.js +35 -0
  214. package/src/UI/Text/index.js +3 -0
  215. package/src/UI/Text/p.js +37 -0
  216. package/src/UI/Text/pre.js +0 -0
  217. package/src/UI/Text/text.js +66 -0
  218. package/src/UI/Utils/index.js +70 -0
  219. package/src/UI/ZikoUIElement.js +478 -0
  220. package/src/UI/index.js +154 -0
  221. package/src/__proto__/Array.js +74 -0
  222. package/src/__proto__/Function.js +0 -0
  223. package/src/__proto__/Number.js +76 -0
  224. package/src/__proto__/Object.js +0 -0
  225. package/src/__proto__/String.js +0 -0
  226. package/src/index.js +69 -0
@@ -0,0 +1,64 @@
1
+ import {
2
+ markdown2html,
3
+ csv2arr,
4
+ csv2matrix,
5
+ csv2object,
6
+ csv2json,
7
+ csv2sql,
8
+ json2arr,
9
+ json2csv,
10
+ json2csvFile,
11
+ json2yml,
12
+ json2ymlFile,
13
+ json2xml,
14
+ json2xmlFile,
15
+ svg2str,
16
+ svg2ascii,
17
+ svg2imgUrl,
18
+ svg2img
19
+ } from "./Converter";
20
+ import parseXML from "./Parser/xml";
21
+ import { preload } from "./Api";
22
+ const Data={
23
+ parseXML,
24
+ preload,
25
+ markdown2html,
26
+ csv2arr,
27
+ csv2matrix,
28
+ csv2object,
29
+ csv2json,
30
+ csv2sql,
31
+ json2arr,
32
+ json2csv,
33
+ json2csvFile,
34
+ json2yml,
35
+ json2ymlFile,
36
+ json2xml,
37
+ json2xmlFile,
38
+ svg2str,
39
+ svg2ascii,
40
+ svg2imgUrl,
41
+ svg2img,
42
+ ExtractAll: function () {
43
+ const keys = Object.keys(this);
44
+ for (let i = 0; i < keys.length; i++) {
45
+ const key = keys[i];
46
+ if (key !== 'ExtractAll' && key !== 'RemoveAll') {
47
+ globalThis[key] = this[key];
48
+ }
49
+ }
50
+ return this;
51
+ },
52
+ RemoveAll: function () {
53
+ const keys = Object.keys(this);
54
+ for (let i = 0; i < keys.length; i++) {
55
+ const key = keys[i];
56
+ if (key !== 'RemoveAll') {
57
+ delete globalThis[key];
58
+ }
59
+ }
60
+ return this;
61
+ }
62
+ }
63
+ export * from "./Converter"
64
+ export default Data
@@ -0,0 +1,43 @@
1
+ import ZikoCanvasElement from "../Element.js";
2
+ class CanvasArc extends ZikoCanvasElement{
3
+ constructor(x,y,r,angle){
4
+ super(x,y);
5
+ this.r=r;
6
+ this.angle=angle;
7
+ this.path=null;
8
+ }
9
+ draw(ctx){
10
+ if(this.cache.config.rendered){
11
+ ctx.save();
12
+ this.applyNormalStyle(ctx);
13
+ ctx.beginPath();
14
+ this.path=new Path2D();
15
+ this.path.arc(this.px, this.py, this.r, 0, this.angle);
16
+ const{strokeEnabled,fillEnabled}=this.cache.style.normal;
17
+ if(strokeEnabled)ctx.stroke(this.path);
18
+ if(fillEnabled)ctx.fill(this.path);
19
+ ctx.closePath();
20
+ ctx.restore();
21
+ }
22
+ return this;
23
+ }
24
+ radius(r){
25
+ this.r=r;
26
+ if(this.parent)this.parent.draw();
27
+ return this;
28
+ }
29
+ // distanceFromCenter(x,y){
30
+ // return Math.sqrt(
31
+ // (this._x-x)**2-(this._y-y)**2
32
+ // )
33
+ // }
34
+ // isIn(x,y,strict=false){
35
+ // return strict?this.distanceFromCenter(x,y)<this.r:this.distanceFromCenter(x,y)<=this.r;
36
+ // }
37
+ // isInEdges(x,y){
38
+ // return this.distanceFromCenter(x,y)===this.r;
39
+ // }
40
+ }
41
+ const canvasArc=(x,y,r,phi)=>new CanvasArc(x,y,r,phi);
42
+ const canvasCircle=(x,y,r)=>new CanvasArc(x,y,r,2*Math.PI);
43
+ export{canvasArc,canvasCircle}
File without changes
@@ -0,0 +1,26 @@
1
+ import ZikoCanvasElement from "../Element.js";
2
+ class CanvasLine extends ZikoCanvasElement{
3
+ constructor(x0,y0,x1,y1){
4
+ super();
5
+ this.x0=x0;
6
+ this.x1=x1;
7
+ this.y0=y0;
8
+ this.y1=y1;
9
+ delete this.fill;
10
+ }
11
+ draw(ctx){
12
+ if(this.cache.config.rendered){
13
+ ctx.save();
14
+ this.applyNormalStyle(ctx);
15
+ ctx.beginPath();
16
+ ctx.moveTo(this.x0+this._x,this.y0+this._y_);
17
+ ctx.lineTo(this.x1+this._x,this.y1+this._y);
18
+ ctx.stroke();
19
+ if(this.cache.style.normal.strokeEnabled)ctx.stroke();
20
+ ctx.restore();
21
+ }
22
+ return this;
23
+ }
24
+ }
25
+ const canvasLine=(x0,y0,x1,y1)=>new CanvasLine(x0,y0,x1,y1)
26
+ export{canvasLine}
File without changes
@@ -0,0 +1,48 @@
1
+ import ZikoCanvasElement from "../Element.js";
2
+ import { matrix } from "../../../../Math/Matrix/index.js";
3
+ class CanvasPoints extends ZikoCanvasElement{
4
+ constructor(ptsX,ptsY){
5
+ super();
6
+ this.pointsMatrix=null;
7
+ this.path=new Path2D();
8
+ this.fromXY(ptsX,ptsY);
9
+ }
10
+ get points(){
11
+ return this.pointsMatrix.T.arr;
12
+ }
13
+ draw(ctx){
14
+ if(this.cache.config.rendered){
15
+ ctx.save();
16
+ this.applyNormalStyle(ctx);
17
+ ctx.beginPath();
18
+ this.path.moveTo(this.points[1][0]+this._x,this.points[1][1]+this._y);
19
+ for(let i=1;i<this.points.length;i++){
20
+ this.path.lineTo(this.points[i][0]+this._x,this.points[i][1]+this._y)
21
+ }
22
+ ctx.stroke(this.path);
23
+ ctx.restore();
24
+ }
25
+ return this;
26
+ }
27
+ fromXY(X,Y){
28
+ this.pointsMatrix=matrix([X,Y]);
29
+ return this;
30
+ }
31
+ push(ptsX,ptsY){
32
+ this.pointsMatrix.hstack(matrix([ptsX,ptsY]))
33
+ if(this.parent)this.parent.draw();
34
+ return this;
35
+ }
36
+ isIn(x,y){
37
+ let is;
38
+ if(this.parent){
39
+ this.parent.ctx.setTransform(1,0,0,1,0,0);
40
+ is=this.parent.ctx.isPointInPath(this.path,x,y);
41
+ this.parent.applyTransformMatrix();
42
+ }
43
+ return is;
44
+ }
45
+ }
46
+
47
+ const canvasPoints=(ptsX=[],ptsY=[])=>new CanvasPoints(ptsX,ptsY);
48
+ export{canvasPoints};
@@ -0,0 +1,7 @@
1
+ import ZikoCanvasElement from "../_element.js";
2
+ import { matrix } from "../../../../Math/Matrix/index.js";
3
+ class ZikoCanvasPolygon extends ZikoCanvasElement{
4
+ constructor(ptsX,ptsY){
5
+ super()
6
+ }
7
+ }
File without changes
@@ -0,0 +1,46 @@
1
+ import ZikoCanvasElement from "../Element.js";
2
+ class CanvasRect extends ZikoCanvasElement{
3
+ constructor(x,y,w,h){
4
+ super(x,y);
5
+ this.w=w;
6
+ this.h=h;
7
+ this.path=new Path2D();
8
+ }
9
+ draw(ctx){
10
+ if(this.cache.config.rendered){
11
+ ctx.save();
12
+ this.applyNormalStyle(ctx);
13
+ ctx.beginPath();
14
+ this.path.rect(this.px, this.py,this.w,this.h);
15
+ const{strokeEnabled,fillEnabled}=this.cache.style.normal;
16
+ if(strokeEnabled)ctx.stroke(this.path);
17
+ if(fillEnabled)ctx.fill(this.path);
18
+ ctx.closePath();
19
+ ctx.restore();
20
+ }
21
+ return this;
22
+ }
23
+ width(w){
24
+ this.w=w;
25
+ if(this.parent)this.parent.draw();
26
+ return this;
27
+ }
28
+ height(h){
29
+ this.h=h;
30
+ if(this.parent)this.parent.draw();
31
+ return this;
32
+ }
33
+ // distanceFromCenter(x,y){
34
+ // return Math.sqrt(
35
+ // (this.position.x-x)**2-(this.position.y-y)**2
36
+ // )
37
+ // }
38
+ // isIn(x,y,strict=false){
39
+ // return strict?this.distanceFromCenter(x,y)<this.r:this.distanceFromCenter(x,y)<=this.r;
40
+ // }
41
+ // isInEdges(x,y){
42
+ // return this.distanceFromCenter(x,y)===this.r;
43
+ // }
44
+ }
45
+ const canvasRect=(x,y,w,h)=>new CanvasRect(x,y,w,h)
46
+ export{canvasRect}
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ // Scatter = Circle[]
2
+
File without changes
@@ -0,0 +1,115 @@
1
+ class ZikoCanvasElement{
2
+ constructor(x,y){
3
+ this.parent=null;
4
+ this.position={
5
+ x,
6
+ y
7
+ }
8
+ this.cache={
9
+ interact:null/*avoid redraw*/,
10
+ config:{
11
+ draggable:false,
12
+ selected:false,
13
+ highlighted:false,
14
+ rendered:false
15
+ },
16
+ style:{
17
+ normal:{
18
+ strokeEnabled:true,
19
+ fillEnabled:false,
20
+ strokeColor:"#111111",
21
+ fillColor:"#777777",
22
+ },
23
+ highlighted:{
24
+ strokeEnabled:true,
25
+ fillEnabled:false,
26
+ strokeColor:null,
27
+ fillColor:null,
28
+ }
29
+ },
30
+ }
31
+ this.history={
32
+ position:[],
33
+ styles:[]
34
+ }
35
+ this.render();
36
+ }
37
+ get px(){
38
+ //_x=====>px
39
+ return (this.position.x??0)+(this.parent?.position?.x??0);
40
+ }
41
+ get py(){
42
+ //_y=====>py
43
+ return (this.position.y??0)+(this.parent?.position?.y??0);
44
+ }
45
+ isIntersectedWith(){
46
+
47
+ }
48
+ isInStroke(x,y){
49
+ let is;
50
+ if(this.parent){
51
+ this.parent.ctx.setTransform(1,0,0,1,0,0);
52
+ is=this.parent.ctx.isPointInStroke(this.path,x,y);
53
+ this.parent.applyTransformMatrix();
54
+ }
55
+ return is;
56
+ }
57
+ isInPath(x,y){
58
+ let is;
59
+ if(this.parent){
60
+ this.parent.ctx.setTransform(1,0,0,1,0,0);
61
+ is=this.parent.ctx.isPointInPath(this.path,x,y);
62
+ this.parent.applyTransformMatrix();
63
+ }
64
+ return is;
65
+ }
66
+ posX(x){
67
+ this.position.x=x;
68
+ if(this.parent)this.parent.draw()
69
+ return this;
70
+ }
71
+ posY(y){
72
+ this.position.y=y;
73
+ if(this.parent)this.parent.draw()
74
+ return this;
75
+ }
76
+ color({stroke=this.cache.style.normal.strokeColor,fill=this.cache.style.normal.fillColor}={stroke,fill}){
77
+ this.cache.style.normal.strokeColor=stroke;
78
+ this.cache.style.normal.fillColor=fill;
79
+ if(this.parent)this.parent.draw()
80
+ return this;
81
+ }
82
+ translate(dx=0,dy=0){
83
+ this.position.x+=dx;
84
+ this.position.y+=dy;
85
+ if(this.parent)this.parent.draw();
86
+ return;
87
+ }
88
+ applyNormalStyle(ctx){
89
+ ctx.strokeStyle=this.cache.style.normal.strokeColor;
90
+ ctx.fillStyle=this.cache.style.normal.fillColor;
91
+ return this;
92
+ }
93
+ applyHighlightedStyle(ctx){
94
+ ctx.strokeStyle=this.cache.style.highlighted.strokeColor;
95
+ ctx.fillStyle=this.cache.style.highlighted.fillColor;
96
+ return this;
97
+ }
98
+ stroke(color=this.cache.style.normal.strokeColor,enabled=true){
99
+ this.cache.style.normal.strokeEnabled=enabled;
100
+ this.cache.style.normal.strokeColor=color;
101
+ if(this.parent)this.parent.draw();
102
+ return this
103
+ }
104
+ fill(color=this.cache.style.normal.fillColor,enabled=true){
105
+ this.cache.style.normal.fillEnabled=enabled;
106
+ this.cache.style.normal.filleColor=color;
107
+ if(this.parent)this.parent.draw();
108
+ return this;
109
+ }
110
+ render(render=true){
111
+ this.cache.config.rendered=render;
112
+ return this;
113
+ }
114
+ }
115
+ export default ZikoCanvasElement;
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ export {
2
+ canvasArc,
3
+ canvasCircle
4
+ } from "./Basic/arc.js";
5
+ export {
6
+ canvasPoints
7
+ } from "./Basic/points.js";
8
+ export {
9
+ canvasLine
10
+ }from "./Basic/line.js"
11
+ export {
12
+ canvasRect
13
+ } from "./Basic/rect.js"
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ const hex2rgba = (hex) => {
2
+ return {
3
+ r: parseInt(hex.slice(1, 3), 16),
4
+ g: parseInt(hex.slice(3, 5), 16),
5
+ b: parseInt(hex.slice(5, 7), 16),
6
+ a: 255,
7
+ };
8
+ };
@@ -0,0 +1,58 @@
1
+ const floodFill=(parent, imageData, newColor, x, y)=>{
2
+ const { width, height, data } = imageData;
3
+ const stack = [];
4
+ const baseColor = parent.getColorAtPixel(imageData, x, y);
5
+ let operator = { x, y };
6
+
7
+ // Check if base color and new color are the same
8
+ if (parent.colorMatch(baseColor, newColor)) {
9
+ return;
10
+ }
11
+
12
+ // Add the clicked location to stack
13
+ stack.push({ x: operator.x, y: operator.y });
14
+
15
+ while (stack.length) {
16
+ operator = stack.pop();
17
+ let contiguousDown = true; // Vertical is assumed to be true
18
+ let contiguousUp = true; // Vertical is assumed to be true
19
+ let contiguousLeft = false;
20
+ let contiguousRight = false;
21
+
22
+ // Move to top most contiguousDown pixel
23
+ while (contiguousUp && operator.y >= 0) {
24
+ operator.y--;
25
+ contiguousUp = parent.colorMatch(parent.getColorAtPixel(imageData, operator.x, operator.y), baseColor);
26
+ }
27
+
28
+ // Move downward
29
+ while (contiguousDown && operator.y < height) {
30
+ parent.setColorAtPixel(imageData, newColor, operator.x, operator.y);
31
+
32
+ // Check left
33
+ if (operator.x - 1 >= 0 && parent.colorMatch(parent.getColorAtPixel(imageData, operator.x - 1, operator.y), baseColor)) {
34
+ if (!contiguousLeft) {
35
+ contiguousLeft = true;
36
+ stack.push({ x: operator.x - 1, y: operator.y });
37
+ }
38
+ } else {
39
+ contiguousLeft = false;
40
+ }
41
+
42
+ // Check right
43
+ if (operator.x + 1 < width && parent.colorMatch(parent.getColorAtPixel(imageData, operator.x + 1, operator.y), baseColor)) {
44
+ if (!contiguousRight) {
45
+ stack.push({ x: operator.x + 1, y: operator.y });
46
+ contiguousRight = true;
47
+ }
48
+ } else {
49
+ contiguousRight = false;
50
+ }
51
+
52
+ operator.y++;
53
+ contiguousDown = parent.colorMatch(parent.getColorAtPixel(imageData, operator.x, operator.y), baseColor);
54
+ }
55
+ }
56
+ return imageData;
57
+ }
58
+ export default floodFill;
File without changes
@@ -0,0 +1,189 @@
1
+ import ZikoUIElement from "../../UI/ZikoUIElement.js";
2
+ import {Matrix} from "../../Math/Matrix/index.js"
3
+ import { convolute } from "../../Math/Signal/conv.js";
4
+ class ZikoUICanvas extends ZikoUIElement{
5
+ constructor(w,h){
6
+ super();
7
+ this.element=document.createElement("canvas");
8
+ this.ctx = this.element.getContext("2d");
9
+ this.style({
10
+ border:"1px red solid",
11
+ //width:"300px",
12
+ //height:"300px"
13
+ })
14
+ this.transformMatrix=new Matrix([
15
+ [1,0,0],
16
+ [0,1,0],
17
+ [0,0,1]
18
+ ])
19
+ this.axisMatrix=new Matrix([
20
+ [-10,-10],
21
+ [10,10]
22
+ ])
23
+ this.render();
24
+ setTimeout(()=>this.resize(w,h),0);
25
+ this.on("sizeupdated",()=>this.adjust())
26
+ }
27
+ get Width(){
28
+ return this.element.width;
29
+ }
30
+ get Height(){
31
+ return this.element.height;
32
+ }
33
+ get Xmin(){
34
+ return this.axisMatrix[0][0];
35
+ }
36
+ get Ymin(){
37
+ return this.axisMatrix[0][1];
38
+ }
39
+ get Xmax(){
40
+ return this.axisMatrix[1][0];
41
+ }
42
+ get Ymax(){
43
+ return this.axisMatrix[1][1];
44
+ }
45
+ get ImageData(){
46
+ return this.ctx.getImageData(0,0,c.Width,c.Height);
47
+ }
48
+ draw(all=true){
49
+ if(all){
50
+ this.clear();
51
+ this.items.forEach(element => {
52
+ element.parent=this;
53
+ element.draw(this.ctx)
54
+ });
55
+ }
56
+ else {
57
+ this.items.at(-1).parent=this;
58
+ this.items.at(-1).draw(this.ctx);
59
+ }
60
+ this.maintain();
61
+ return this;
62
+ }
63
+ applyTransformMatrix(){
64
+ this.ctx.setTransform(
65
+ this.transformMatrix[0][0],
66
+ this.transformMatrix[1][0],
67
+ this.transformMatrix[0][1],
68
+ this.transformMatrix[1][1],
69
+ this.transformMatrix[0][2],
70
+ this.transformMatrix[1][2],
71
+ );
72
+ return this;
73
+ }
74
+ resize(w,h){
75
+ // this.style({
76
+ // width:w,
77
+ // height:h
78
+ // })
79
+ this.size(w,h)
80
+ this.lineWidth();
81
+ this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
82
+ this.emit("sizeupdated");
83
+ return this;
84
+ }
85
+ adjust(){
86
+ this.element.width=this.element.getBoundingClientRect().width;
87
+ this.element.height=this.element.getBoundingClientRect().height;
88
+ this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
89
+ return this;
90
+ }
91
+ view(xMin,yMin,xMax,yMax){
92
+ this.transformMatrix[0][0]=this.Width/(xMax-xMin); // scaleX
93
+ this.transformMatrix[1][1]=-this.Height/(yMax-yMin); // scaleY
94
+ this.transformMatrix[0][2]=this.Width/2;
95
+ this.transformMatrix[1][2]=this.Height/2;
96
+ this.axisMatrix=new Matrix([
97
+ [xMin,yMin],
98
+ [xMax,yMax]
99
+ ])
100
+
101
+ this.applyTransformMatrix();
102
+ this.clear();
103
+ this.lineWidth(1);
104
+ this.draw();
105
+ return this;
106
+ }
107
+ reset(){
108
+ this.ctx.setTransform(1,0,0,0,0,0);
109
+ return this;
110
+ }
111
+ append(element){
112
+ this.items.push(element);
113
+ this.draw(false);
114
+ return this;
115
+ }
116
+ background(color){
117
+ this.ctx.fillStyle = color;
118
+ this.ctx.setTransform(1, 0, 0, 1, 0, 0);
119
+ this.ctx.fillRect(0, 0, this.Width, this.Height);
120
+ this.applyTransformMatrix();
121
+ this.draw();
122
+ }
123
+ lineWidth(w){
124
+ this.ctx.lineWidth=w/this.transformMatrix[0][0];;
125
+ return this
126
+ }
127
+ ImageData(x=0,y=0,w=this.Width,h=this.Height){
128
+ return this.ctx.getImageData(x,y,w,h);
129
+ }
130
+ clear(){
131
+ this.ctx.setTransform(1, 0, 0, 1, 0, 0);
132
+ this.ctx.clearRect(0, 0, this.Width, this.Height);
133
+ this.applyTransformMatrix();
134
+ return this;
135
+ }
136
+ clone(){
137
+ console.log(this.Width)
138
+ const canvas=new ZikoUICanvas();
139
+ canvas.items=this.items;
140
+ canvas.transformMatrix=this.transformMatrix;
141
+ canvas.axisMatrix=this.axisMatrix;
142
+ Object.assign(canvas.cache,{...this.cache});
143
+ //waitForUIElm(this)
144
+ //console.log(element)
145
+ this.size(element.style.width,element.style.width);
146
+ this.applyTransformMatrix();
147
+ this.draw();
148
+ this.adjust();
149
+ return canvas;
150
+ }
151
+ toImage() {
152
+ this.img = document.createElement("img");
153
+ this.img.src = this.element.toDataURL("image/png");
154
+ return this;
155
+ }
156
+ toBlob() {
157
+ var canvas = this.element;
158
+ canvas.toBlob(function (blob) {
159
+ var newImg = document.createElement("img"),
160
+ url = URL.createObjectURL(blob);
161
+ newImg.onload = function () {
162
+ URL.revokeObjectURL(url);
163
+ };
164
+ newImg.src = url;
165
+ console.log(newImg);
166
+ });
167
+ }
168
+ zoomIn(){
169
+
170
+ }
171
+ zoomOut(){
172
+
173
+ }
174
+ undo(n){
175
+
176
+ }
177
+ redo(n){
178
+
179
+ }
180
+ stream(){
181
+
182
+ }
183
+ }
184
+
185
+ const Canvas=(w,h)=>new ZikoUICanvas(w,h);
186
+ export{
187
+ ZikoUICanvas
188
+ }
189
+ export default Canvas;
@@ -0,0 +1,15 @@
1
+ import Canvas from "./canvas.js";
2
+ import {
3
+ ZikoUICanvas
4
+ } from "./canvas.js";
5
+ export {
6
+ canvasArc,
7
+ canvasCircle,
8
+ canvasPoints,
9
+ canvasLine,
10
+ canvasRect,
11
+ } from "./Elements/index.js";
12
+ export {
13
+ ZikoUICanvas,
14
+ Canvas,
15
+ }