ziko 0.0.24 → 0.0.26

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/ziko.cjs +50 -8
  3. package/dist/ziko.js +53 -11
  4. package/dist/ziko.min.js +2 -2
  5. package/dist/ziko.mjs +53 -11
  6. package/package.json +1 -1
  7. package/src/data/parser/index.js +1 -1
  8. package/src/reactivity/events/click.js +43 -1
  9. package/src/ui/elements/ZikoUIElement.js +6 -6
  10. package/src/ui/elements/text/__ZikoUIText__.js +3 -3
  11. package/src/graphics/canvas/elements ( To Be Moved )/Basic/arc.js +0 -43
  12. package/src/graphics/canvas/elements ( To Be Moved )/Basic/image.js +0 -0
  13. package/src/graphics/canvas/elements ( To Be Moved )/Basic/line.js +0 -26
  14. package/src/graphics/canvas/elements ( To Be Moved )/Basic/path.js +0 -0
  15. package/src/graphics/canvas/elements ( To Be Moved )/Basic/points.js +0 -48
  16. package/src/graphics/canvas/elements ( To Be Moved )/Basic/polygon.js +0 -7
  17. package/src/graphics/canvas/elements ( To Be Moved )/Basic/polyline.js +0 -0
  18. package/src/graphics/canvas/elements ( To Be Moved )/Basic/rect.js +0 -46
  19. package/src/graphics/canvas/elements ( To Be Moved )/Basic/text.js +0 -0
  20. package/src/graphics/canvas/elements ( To Be Moved )/Chart/histogram.js +0 -0
  21. package/src/graphics/canvas/elements ( To Be Moved )/Chart/plot.js +0 -0
  22. package/src/graphics/canvas/elements ( To Be Moved )/Chart/scatter.js +0 -2
  23. package/src/graphics/canvas/elements ( To Be Moved )/Chart/stem.js +0 -0
  24. package/src/graphics/canvas/elements ( To Be Moved )/Element.js +0 -115
  25. package/src/graphics/canvas/elements ( To Be Moved )/index.js +0 -13
  26. package/src/graphics/svg/Elements ( To Be Moved )/Basic/circle.js +0 -29
  27. package/src/graphics/svg/Elements ( To Be Moved )/Basic/ellipse.js +0 -24
  28. package/src/graphics/svg/Elements ( To Be Moved )/Basic/foreign-object.js +0 -36
  29. package/src/graphics/svg/Elements ( To Be Moved )/Basic/groupe.js +0 -32
  30. package/src/graphics/svg/Elements ( To Be Moved )/Basic/image.js +0 -36
  31. package/src/graphics/svg/Elements ( To Be Moved )/Basic/index.js +0 -11
  32. package/src/graphics/svg/Elements ( To Be Moved )/Basic/line.js +0 -32
  33. package/src/graphics/svg/Elements ( To Be Moved )/Basic/link.js +0 -33
  34. package/src/graphics/svg/Elements ( To Be Moved )/Basic/path.js +0 -62
  35. package/src/graphics/svg/Elements ( To Be Moved )/Basic/polygon.js +0 -32
  36. package/src/graphics/svg/Elements ( To Be Moved )/Basic/polyline.js +0 -7
  37. package/src/graphics/svg/Elements ( To Be Moved )/Basic/rect.js +0 -46
  38. package/src/graphics/svg/Elements ( To Be Moved )/Basic/text.js +0 -29
  39. package/src/graphics/svg/Elements ( To Be Moved )/Derived/grid.js +0 -9
  40. package/src/graphics/svg/Elements ( To Be Moved )/Derived/index.js +0 -1
  41. package/src/graphics/svg/Elements ( To Be Moved )/index.js +0 -2
  42. package/src/graphics/svg/Elements ( To Be Moved )/ziko-svg-element.js +0 -48
  43. package/src/ui/elements/derived ( To Be Moved)/accordion/accordion.js +0 -42
  44. package/src/ui/elements/derived ( To Be Moved)/accordion/collapsible.js +0 -82
  45. package/src/ui/elements/derived ( To Be Moved)/accordion/index.js +0 -2
  46. package/src/ui/elements/derived ( To Be Moved)/alert/alert.js +0 -80
  47. package/src/ui/elements/derived ( To Be Moved)/alert/index.js +0 -1
  48. package/src/ui/elements/derived ( To Be Moved)/alert/palette.js +0 -52
  49. package/src/ui/elements/derived ( To Be Moved)/carousel/index.js +0 -51
  50. package/src/ui/elements/derived ( To Be Moved)/code-note/SubElements.js.txt +0 -105
  51. package/src/ui/elements/derived ( To Be Moved)/code-note/code-cell.js +0 -195
  52. package/src/ui/elements/derived ( To Be Moved)/code-note/code-note.js +0 -72
  53. package/src/ui/elements/derived ( To Be Moved)/code-note/index.js +0 -2
  54. package/src/ui/elements/derived ( To Be Moved)/code-note/sub-elements.js +0 -67
  55. package/src/ui/elements/derived ( To Be Moved)/index.js +0 -12
  56. package/src/ui/elements/derived ( To Be Moved)/menu/index.js +0 -1
  57. package/src/ui/elements/derived ( To Be Moved)/menu/menu3d.js +0 -260
  58. package/src/ui/elements/derived ( To Be Moved)/modal/index.js +0 -92
  59. package/src/ui/elements/derived ( To Be Moved)/pagination/breadcrumbs.js +0 -54
  60. package/src/ui/elements/derived ( To Be Moved)/pagination/index.js +0 -1
  61. package/src/ui/elements/derived ( To Be Moved)/slider/__ZikoUISlider__.js +0 -112
  62. package/src/ui/elements/derived ( To Be Moved)/slider/hSlider.js +0 -34
  63. package/src/ui/elements/derived ( To Be Moved)/slider/index.js +0 -12
  64. package/src/ui/elements/derived ( To Be Moved)/slider/vSlider.js +0 -27
  65. package/src/ui/elements/derived ( To Be Moved)/splitter/__ZikoUISplitter__.js +0 -62
  66. package/src/ui/elements/derived ( To Be Moved)/splitter/hsplitter.js +0 -40
  67. package/src/ui/elements/derived ( To Be Moved)/splitter/index.js +0 -12
  68. package/src/ui/elements/derived ( To Be Moved)/splitter/vsplitter.js +0 -40
  69. package/src/ui/elements/derived ( To Be Moved)/tabs/index.js +0 -180
  70. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/_themes/dark.js +0 -0
  71. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/_themes/index.js +0 -0
  72. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/_themes/light.js +0 -0
  73. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/app/index.js +0 -0
  74. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/component/index.js +0 -0
  75. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/globals/index.js +0 -0
  76. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/index.js +0 -0
  77. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/params/index.js +0 -0
  78. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/router/index.js +0 -0
  79. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/seo/index.js +0 -0
  80. /package/src/{_global (To Be Replaced ) → _global (To Be Removed )}/style/index.js +0 -0
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Jan 24 2025 23:58:20 GMT+0100 (UTC+01:00)
5
+ Date : Sat Mar 08 2025 13:43:10 GMT+0000 (UTC)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -1943,7 +1943,49 @@ class ZikoEventClick extends ZikoEvent{
1943
1943
  return this;
1944
1944
  }
1945
1945
  }
1946
- const useClickEvent=target=>new ZikoEventClick(target);
1946
+ const useClickEvent=target=>new ZikoEventClick(target);
1947
+
1948
+
1949
+ //
1950
+
1951
+
1952
+ // import { ZikoEvent, EVENT_CONTROLLER } from "./ZikoEvent.js";
1953
+
1954
+ // class ZikoEventClick extends ZikoEvent {
1955
+ // constructor(target) {
1956
+ // super(target);
1957
+ // this.event = null;
1958
+ // this.cache = {
1959
+ // prefixe: "",
1960
+ // preventDefault: { click: false, dbclick: false },
1961
+ // paused: { click: false, dbclick: false },
1962
+ // stream: {
1963
+ // enabled: { click: false, dbclick: false },
1964
+ // clear: { click: false, dbclick: false },
1965
+ // history: { click: [], dbclick: [] }
1966
+ // },
1967
+ // callbacks: { click: [], dbclick: [] }
1968
+ // };
1969
+
1970
+ // this.__controller = {};
1971
+ // ["click", "dbclick"].forEach(evt => {
1972
+ // this.__controller[evt] = (e) => EVENT_CONTROLLER.call(this, e, evt, null, null);
1973
+ // });
1974
+ // }
1975
+
1976
+ // onClick(...callbacks) {
1977
+ // return this.__onEvent("click", {}, ...callbacks);
1978
+ // }
1979
+
1980
+ // onDbClick(...callbacks) {
1981
+ // return this.__onEvent("dbclick", {}, ...callbacks);
1982
+ // }
1983
+ // }
1984
+
1985
+ // const useClickEvent = (target) => new ZikoEventClick(target);
1986
+
1987
+ // export default useClickEvent;
1988
+ // export { useClickEvent, ZikoEventClick };
1947
1989
 
1948
1990
  function pointerdown_controller(e){
1949
1991
  EVENT_CONTROLLER.call(
@@ -4707,7 +4749,7 @@ class ZikoUIElement {
4707
4749
  }
4708
4750
  for (let i = 0; i < ele.length; i++) {
4709
4751
  if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
4710
- if (ele[i] instanceof ZikoUIElement) {
4752
+ if (ele[i]?.isZikoUIElement) {
4711
4753
  ele[i].cache.parent = this;
4712
4754
  this.element[adder](ele[i].element);
4713
4755
  ele[i].target = this.element;
@@ -4745,7 +4787,7 @@ class ZikoUIElement {
4745
4787
  remove(...ele) {
4746
4788
  const remove = (ele) => {
4747
4789
  if (typeof ele === "number") ele = this.items[ele];
4748
- if (ele instanceof ZikoUIElement) this.element?.removeChild(ele.element);
4790
+ if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
4749
4791
  this.items = this.items.filter((n) => n !== ele);
4750
4792
  };
4751
4793
  for (let i = 0; i < ele.length; i++) remove(ele[i]);
@@ -4846,7 +4888,7 @@ class ZikoUIElement {
4846
4888
  }
4847
4889
  setTarget(tg) {
4848
4890
  if(this.isBody) return ;
4849
- if (tg instanceof ZikoUIElement) tg = tg.element;
4891
+ if (tg?.isZikoUIElement) tg = tg.element;
4850
4892
  this.unrender();
4851
4893
  this.target = tg;
4852
4894
  this.render();
@@ -4862,7 +4904,7 @@ class ZikoUIElement {
4862
4904
  }
4863
4905
  render(target = this.target) {
4864
4906
  if(this.isBody)return ;
4865
- if(target instanceof ZikoUIElement)target=target.element;
4907
+ if(target?.isZikoUIElement)target=target.element;
4866
4908
  this.target=target;
4867
4909
  this.target?.appendChild(this.element);
4868
4910
  return this;
@@ -4881,12 +4923,12 @@ class ZikoUIElement {
4881
4923
  return this;
4882
4924
  }
4883
4925
  after(ui){
4884
- if(ui instanceof ZikoUIElement) ui=ui.element;
4926
+ if(ui?.isZikoUIElement) ui=ui.element;
4885
4927
  this.element?.after(ui);
4886
4928
  return this;
4887
4929
  }
4888
4930
  before(ui){
4889
- if(ui instanceof ZikoUIElement) ui=ui.element;
4931
+ if(ui?.isZikoUIElement) ui=ui.element;
4890
4932
  this.element?.before(ui);
4891
4933
  return this;
4892
4934
  }
@@ -5191,9 +5233,9 @@ class __ZikoUIText__ extends ZikoUIElement {
5191
5233
 
5192
5234
  if(this.cache.lineBreak)this.element?.appendChild(globalThis.document?.createElement("br"));
5193
5235
  });
5194
- if(this.element?.innerHTML){
5195
- this.element.innerHTML = this.element.innerHTML.replace(/\n/g, '<br>').replace(/(?<!<[^>]+) /g, '&nbsp;');
5196
- }
5236
+ // if(this.element?.innerHTML){
5237
+ // this.element.innerHTML = this.element.innerHTML.replace(/\n/g, '<br>').replace(/(?<!<[^>]+) /g, '&nbsp;');
5238
+ // }
5197
5239
  return this
5198
5240
  }
5199
5241
  setValue(...value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "a versatile javaScript framework offering a rich set of UI components, advanced mathematical utilities, reactivity, animations, client side routing and graphics capabilities",
5
5
  "keywords": [
6
6
  "front-end",
@@ -1 +1 @@
1
- export * from "./markdown"
1
+ export * from "./xml"
@@ -57,4 +57,46 @@ export default useClickEvent;
57
57
  export {
58
58
  useClickEvent,
59
59
  ZikoEventClick
60
- }
60
+ }
61
+
62
+
63
+ //
64
+
65
+
66
+ // import { ZikoEvent, EVENT_CONTROLLER } from "./ZikoEvent.js";
67
+
68
+ // class ZikoEventClick extends ZikoEvent {
69
+ // constructor(target) {
70
+ // super(target);
71
+ // this.event = null;
72
+ // this.cache = {
73
+ // prefixe: "",
74
+ // preventDefault: { click: false, dbclick: false },
75
+ // paused: { click: false, dbclick: false },
76
+ // stream: {
77
+ // enabled: { click: false, dbclick: false },
78
+ // clear: { click: false, dbclick: false },
79
+ // history: { click: [], dbclick: [] }
80
+ // },
81
+ // callbacks: { click: [], dbclick: [] }
82
+ // };
83
+
84
+ // this.__controller = {};
85
+ // ["click", "dbclick"].forEach(evt => {
86
+ // this.__controller[evt] = (e) => EVENT_CONTROLLER.call(this, e, evt, null, null);
87
+ // });
88
+ // }
89
+
90
+ // onClick(...callbacks) {
91
+ // return this.__onEvent("click", {}, ...callbacks);
92
+ // }
93
+
94
+ // onDbClick(...callbacks) {
95
+ // return this.__onEvent("dbclick", {}, ...callbacks);
96
+ // }
97
+ // }
98
+
99
+ // const useClickEvent = (target) => new ZikoEventClick(target);
100
+
101
+ // export default useClickEvent;
102
+ // export { useClickEvent, ZikoEventClick };
@@ -161,7 +161,7 @@ class ZikoUIElement {
161
161
  }
162
162
  for (let i = 0; i < ele.length; i++) {
163
163
  if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
164
- if (ele[i] instanceof ZikoUIElement) {
164
+ if (ele[i]?.isZikoUIElement) {
165
165
  ele[i].cache.parent = this;
166
166
  this.element[adder](ele[i].element);
167
167
  ele[i].target = this.element;
@@ -199,7 +199,7 @@ class ZikoUIElement {
199
199
  remove(...ele) {
200
200
  const remove = (ele) => {
201
201
  if (typeof ele === "number") ele = this.items[ele];
202
- if (ele instanceof ZikoUIElement) this.element?.removeChild(ele.element);
202
+ if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
203
203
  this.items = this.items.filter((n) => n !== ele);
204
204
  };
205
205
  for (let i = 0; i < ele.length; i++) remove(ele[i]);
@@ -300,7 +300,7 @@ class ZikoUIElement {
300
300
  }
301
301
  setTarget(tg) {
302
302
  if(this.isBody) return ;
303
- if (tg instanceof ZikoUIElement) tg = tg.element;
303
+ if (tg?.isZikoUIElement) tg = tg.element;
304
304
  this.unrender();
305
305
  this.target = tg;
306
306
  this.render();
@@ -316,7 +316,7 @@ class ZikoUIElement {
316
316
  }
317
317
  render(target = this.target) {
318
318
  if(this.isBody)return ;
319
- if(target instanceof ZikoUIElement)target=target.element;
319
+ if(target?.isZikoUIElement)target=target.element;
320
320
  this.target=target;
321
321
  this.target?.appendChild(this.element);
322
322
  return this;
@@ -335,12 +335,12 @@ class ZikoUIElement {
335
335
  return this;
336
336
  }
337
337
  after(ui){
338
- if(ui instanceof ZikoUIElement) ui=ui.element;
338
+ if(ui?.isZikoUIElement) ui=ui.element;
339
339
  this.element?.after(ui)
340
340
  return this;
341
341
  }
342
342
  before(ui){
343
- if(ui instanceof ZikoUIElement) ui=ui.element;
343
+ if(ui?.isZikoUIElement) ui=ui.element;
344
344
  this.element?.before(ui)
345
345
  return this;
346
346
  }
@@ -47,9 +47,9 @@ class __ZikoUIText__ extends ZikoUIElement {
47
47
 
48
48
  if(this.cache.lineBreak)this.element?.appendChild(globalThis.document?.createElement("br"));
49
49
  });
50
- if(this.element?.innerHTML){
51
- this.element.innerHTML = this.element.innerHTML.replace(/\n/g, '<br>').replace(/(?<!<[^>]+) /g, '&nbsp;');
52
- }
50
+ // if(this.element?.innerHTML){
51
+ // this.element.innerHTML = this.element.innerHTML.replace(/\n/g, '<br>').replace(/(?<!<[^>]+) /g, '&nbsp;');
52
+ // }
53
53
  return this
54
54
  }
55
55
  setValue(...value) {
@@ -1,43 +0,0 @@
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}
@@ -1,26 +0,0 @@
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}
@@ -1,48 +0,0 @@
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};
@@ -1,7 +0,0 @@
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
- }
@@ -1,46 +0,0 @@
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}
@@ -1,2 +0,0 @@
1
- // Scatter = Circle[]
2
-
@@ -1,115 +0,0 @@
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;
@@ -1,13 +0,0 @@
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"
@@ -1,29 +0,0 @@
1
- import ZikoSvgElement from "../ziko-svg-element.js";
2
- class ZikoSvgCircle extends ZikoSvgElement{
3
- constructor(cx,cy,r){
4
- super("circle")
5
- this.element=document.createElementNS(
6
- "http://www.w3.org/2000/svg",
7
- "circle",
8
- );
9
- this.pos(cx,cy).setR(r);
10
- }
11
- setR(r){
12
- this.element.r.baseVal.value=r;
13
- return this;
14
- }
15
- get r(){
16
- return this.element.baseVal.value;
17
- }
18
- get cx(){
19
- return this.element.baseVal.value;
20
- }
21
- get cy(){
22
- return this.element.baseVal.value;
23
- }
24
- }
25
- const svgCircle=(x,y,r)=>new ZikoSvgCircle(x,y,r);
26
- export {
27
- svgCircle,
28
- ZikoSvgCircle
29
- }
@@ -1,24 +0,0 @@
1
- import ZikoSvgElement from "../ziko-svg-element.js";
2
- class ZikoSvgEllipse extends ZikoSvgElement{
3
- constructor(cx,cy,rx,ry){
4
- super("ellipse")
5
- this.element=document?.createElementNS(
6
- "http://www.w3.org/2000/svg",
7
- "ellipse",
8
- );
9
- this.pos(cx,cy).setRx(rx).setRy(ry);
10
- }
11
- setRx(rx){
12
- this.element.rx.baseVal.value=rx;
13
- return this;
14
- }
15
- setRy(ry){
16
- this.element.ry.baseVal.value=ry;
17
- return this;
18
- }
19
- }
20
- const svgEllipse=(x,y,rx,ry)=>new ZikoSvgEllipse(x,y,rx,ry);
21
- export{
22
- svgEllipse,
23
- ZikoSvgEllipse
24
- }
@@ -1,36 +0,0 @@
1
- import ZikoSvgElement from "../ziko-svg-element.js";
2
- import { Flex } from "../../../../ui/index.js"
3
- class ZikoSvgForeignObject extends ZikoSvgElement{
4
- constructor(x=0,y=0,w="100%",h="100%",...ZikoUIElement){
5
- super("foreignObject")
6
- this.items=[];
7
- this.element=document?.createElementNS(
8
- "http://www.w3.org/2000/svg",
9
- "foreignObject",
10
- );
11
- this.container=Flex().setTarget(this.element).vertical(0,0).size("auto","auto");
12
- this.container.st.scaleY(-1);
13
- this.posX(x).posY(y).width(w).height(h);
14
- }
15
- width(w){
16
- this.element.etAttribute("width",w)
17
- return this;
18
- }
19
- height(h){
20
- this.element.etAttribute("height",h)
21
- return this;
22
- }
23
- add(...ZikoUIElement){
24
- this.container.append(...ZikoUIElement);
25
- return this;
26
- }
27
- remove(...ZikoUIElement){
28
- this.container.append(...ZikoUIElement);
29
- return this;
30
- }
31
- }
32
- const svgObject=(x, y, w, h)=>new ZikoSvgForeignObject(x, y, w, h);
33
- export {
34
- svgObject,
35
- ZikoSvgForeignObject
36
- }