ziko 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +78 -2817
- package/dist/ziko.js +78 -2817
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +76 -2755
- package/package.json +1 -1
- package/src/app/globals.js +4 -2
- package/src/data/converter/index.js +2 -6
- package/src/data/parser/index.js +1 -1
- package/src/graphics/canvas/index.js +176 -2
- package/src/graphics/canvas/utils/floodFill.js +0 -1
- package/src/graphics/svg/index.js +69 -2
- package/src/reactivity/hooks/index.js +1 -1
- package/src/ui/elements/{primitives/ZikoUIElement.js → ZikoUIElement.js} +8 -9
- package/src/ui/elements/{derived/flex → flex}/index.js +2 -2
- package/src/ui/elements/{derived/grid → grid}/index.js +2 -2
- package/src/ui/elements/{primitives/index.js → index.js} +3 -1
- package/src/ui/elements/{primitives/io → io}/Form/index.js +1 -1
- package/src/ui/elements/{primitives/io → io}/Inputs/__helpers__.js +1 -1
- package/src/ui/elements/{primitives/io → io}/Inputs/input/index.js +1 -1
- package/src/ui/elements/{primitives/list → list}/index.js +2 -3
- package/src/ui/elements/{primitives/misc → misc}/index.js +2 -3
- package/src/ui/elements/{primitives/semantic → semantic}/index.js +8 -8
- package/src/ui/elements/{primitives/table → table}/table.js +1 -1
- package/src/ui/elements/{primitives/text → text}/__ZikoUIText__.js +3 -4
- package/src/ui/index.js +21 -21
- package/src/ui/utils/index.js +1 -1
- package/src/data/parser/markdown.js +0 -0
- package/src/graphics/canvas/canvas.js +0 -176
- package/src/graphics/canvas/elements/Basic/arc.js +0 -43
- package/src/graphics/canvas/elements/Basic/image.js +0 -0
- package/src/graphics/canvas/elements/Basic/line.js +0 -26
- package/src/graphics/canvas/elements/Basic/path.js +0 -0
- package/src/graphics/canvas/elements/Basic/points.js +0 -48
- package/src/graphics/canvas/elements/Basic/polygon.js +0 -7
- package/src/graphics/canvas/elements/Basic/polyline.js +0 -0
- package/src/graphics/canvas/elements/Basic/rect.js +0 -46
- package/src/graphics/canvas/elements/Basic/text.js +0 -0
- package/src/graphics/canvas/elements/Chart/histogram.js +0 -0
- package/src/graphics/canvas/elements/Chart/plot.js +0 -0
- package/src/graphics/canvas/elements/Chart/scatter.js +0 -2
- package/src/graphics/canvas/elements/Chart/stem.js +0 -0
- package/src/graphics/canvas/elements/Element.js +0 -115
- package/src/graphics/canvas/elements/index.js +0 -13
- package/src/graphics/svg/Elements/Basic/circle.js +0 -29
- package/src/graphics/svg/Elements/Basic/ellipse.js +0 -24
- package/src/graphics/svg/Elements/Basic/foreign-object.js +0 -36
- package/src/graphics/svg/Elements/Basic/groupe.js +0 -32
- package/src/graphics/svg/Elements/Basic/image.js +0 -36
- package/src/graphics/svg/Elements/Basic/index.js +0 -11
- package/src/graphics/svg/Elements/Basic/line.js +0 -32
- package/src/graphics/svg/Elements/Basic/link.js +0 -33
- package/src/graphics/svg/Elements/Basic/path.js +0 -62
- package/src/graphics/svg/Elements/Basic/polygon.js +0 -32
- package/src/graphics/svg/Elements/Basic/polyline.js +0 -7
- package/src/graphics/svg/Elements/Basic/rect.js +0 -46
- package/src/graphics/svg/Elements/Basic/text.js +0 -29
- package/src/graphics/svg/Elements/Derived/grid.js +0 -9
- package/src/graphics/svg/Elements/Derived/index.js +0 -1
- package/src/graphics/svg/Elements/index.js +0 -2
- package/src/graphics/svg/Elements/ziko-svg-element.js +0 -48
- package/src/graphics/svg/svg.js +0 -69
- package/src/reactivity/hooks/Interactions/useSerial.js +0 -0
- package/src/types.js +0 -73
- package/src/ui/elements/derived/accordion/accordion.js +0 -42
- package/src/ui/elements/derived/accordion/collapsible.js +0 -82
- package/src/ui/elements/derived/accordion/index.js +0 -2
- package/src/ui/elements/derived/alert/alert.js +0 -80
- package/src/ui/elements/derived/alert/index.js +0 -1
- package/src/ui/elements/derived/alert/palette.js +0 -52
- package/src/ui/elements/derived/carousel/index.js +0 -51
- package/src/ui/elements/derived/code-note/SubElements.js.txt +0 -105
- package/src/ui/elements/derived/code-note/code-cell.js +0 -195
- package/src/ui/elements/derived/code-note/code-note.js +0 -72
- package/src/ui/elements/derived/code-note/index.js +0 -2
- package/src/ui/elements/derived/code-note/sub-elements.js +0 -67
- package/src/ui/elements/derived/index.js +0 -12
- package/src/ui/elements/derived/menu/index.js +0 -1
- package/src/ui/elements/derived/menu/menu3d.js +0 -260
- package/src/ui/elements/derived/modal/index.js +0 -92
- package/src/ui/elements/derived/pagination/breadcrumbs.js +0 -54
- package/src/ui/elements/derived/pagination/index.js +0 -1
- package/src/ui/elements/derived/slider/__ZikoUISlider__.js +0 -112
- package/src/ui/elements/derived/slider/hSlider.js +0 -34
- package/src/ui/elements/derived/slider/index.js +0 -12
- package/src/ui/elements/derived/slider/vSlider.js +0 -27
- package/src/ui/elements/derived/splitter/__ZikoUISplitter__.js +0 -62
- package/src/ui/elements/derived/splitter/hsplitter.js +0 -40
- package/src/ui/elements/derived/splitter/index.js +0 -12
- package/src/ui/elements/derived/splitter/vsplitter.js +0 -40
- package/src/ui/elements/derived/tabs/index.js +0 -180
- package/src/ui/elements/primitives/ZikoUIContainerElement.js +0 -123
- /package/src/{global → _global (To Be Replaced )}/_themes/dark.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/_themes/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/_themes/light.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/app/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/component/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/globals/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/params/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/router/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/seo/index.js +0 -0
- /package/src/{global → _global (To Be Replaced )}/style/index.js +0 -0
- /package/src/data/converter/{adoc.js → __(To Be Moved)adoc.js} +0 -0
- /package/src/data/converter/{markdown.js → __(To Be Moved)markdown.js} +0 -0
- /package/src/reactivity/hooks/{Sensors → Sensors ( To Be Moved )}/index.js +0 -0
- /package/src/reactivity/hooks/{Sensors → Sensors ( To Be Moved )}/useBattery.js +0 -0
- /package/src/reactivity/hooks/{Sensors → Sensors ( To Be Moved )}/useCamera.js +0 -0
- /package/src/reactivity/hooks/{Sensors → Sensors ( To Be Moved )}/useGeolocation.js +0 -0
- /package/src/reactivity/hooks/{Sensors → Sensors ( To Be Moved )}/useMicro.js +0 -0
- /package/src/reactivity/hooks/{Sensors → Sensors ( To Be Moved )}/useOrientation.js +0 -0
- /package/src/ui/elements/{primitives/embaded → embaded}/html.js +0 -0
- /package/src/ui/elements/{primitives/embaded → embaded}/index.js +0 -0
- /package/src/ui/elements/{primitives/embaded → embaded}/pdf.js +0 -0
- /package/src/ui/elements/{primitives/embaded → embaded}/youtube.js +0 -0
- /package/src/ui/elements/{primitives/hydrate.js → hydrate.js} +0 -0
- /package/src/ui/elements/{primitives/io → io}/Form/index.js.txt +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-camera/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-checkbox/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-color/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-date-time/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-date-time/input-date-time.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-date-time/input-date.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-date-time/input-time.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-email-password/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-email-password/input-email.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-email-password/input-password.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-file/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-file/input-file.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-file/input-image.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-number/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-radio/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-search/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Inputs/input-slider/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Select/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/Textarea/index.js +0 -0
- /package/src/ui/elements/{primitives/io → io}/index.js +0 -0
- /package/src/ui/elements/{primitives/list → list}/elements.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/Audio/index.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/Image/figure.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/Image/image.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/Image/index.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/Video/index.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/__ZikoUIDynamicMediaELement__.js +0 -0
- /package/src/ui/elements/{primitives/media → media}/index.js +0 -0
- /package/src/ui/elements/{primitives/misc → misc}/hyperscript.js +0 -0
- /package/src/ui/elements/{primitives/misc → misc}/suspense.js +0 -0
- /package/src/ui/elements/{primitives/misc → misc}/xml-wrapper.js +0 -0
- /package/src/ui/elements/{primitives/table → table}/elements.js +0 -0
- /package/src/ui/elements/{primitives/table → table}/index.js +0 -0
- /package/src/ui/elements/{primitives/table → table}/utils.js +0 -0
- /package/src/ui/elements/{primitives/text → text}/heading.js +0 -0
- /package/src/ui/elements/{primitives/text → text}/index.js +0 -0
- /package/src/ui/elements/{primitives/text → text}/p.js +0 -0
- /package/src/ui/elements/{primitives/text → text}/pre.js +0 -0
- /package/src/ui/elements/{primitives/text → text}/text.js +0 -0
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import ZikoUIContainerElement from "../../ui/elements/primitives/ZikoUIContainerElement.js";
|
|
2
|
-
import {Matrix} from "../../math/matrix/index.js"
|
|
3
|
-
// import { convolute } from "../../math/signal/conv.js";
|
|
4
|
-
class ZikoUICanvas extends ZikoUIContainerElement{
|
|
5
|
-
constructor(w,h){
|
|
6
|
-
super("canvas","canvas");
|
|
7
|
-
this.ctx = this.element?.getContext("2d");
|
|
8
|
-
this.style({
|
|
9
|
-
border:"1px red solid",
|
|
10
|
-
})
|
|
11
|
-
this.transformMatrix=new Matrix([
|
|
12
|
-
[1,0,0],
|
|
13
|
-
[0,1,0],
|
|
14
|
-
[0,0,1]
|
|
15
|
-
])
|
|
16
|
-
this.axisMatrix=new Matrix([
|
|
17
|
-
[-10,-10],
|
|
18
|
-
[10,10]
|
|
19
|
-
])
|
|
20
|
-
// setTimeout(()=>this.resize(w,h),0);
|
|
21
|
-
requestAnimationFrame(()=>this.resize(w,h),0);
|
|
22
|
-
this.on("sizeupdated",()=>this.adjust())
|
|
23
|
-
}
|
|
24
|
-
get Xmin(){
|
|
25
|
-
return this.axisMatrix[0][0];
|
|
26
|
-
}
|
|
27
|
-
get Ymin(){
|
|
28
|
-
return this.axisMatrix[0][1];
|
|
29
|
-
}
|
|
30
|
-
get Xmax(){
|
|
31
|
-
return this.axisMatrix[1][0];
|
|
32
|
-
}
|
|
33
|
-
get Ymax(){
|
|
34
|
-
return this.axisMatrix[1][1];
|
|
35
|
-
}
|
|
36
|
-
get ImageData(){
|
|
37
|
-
return this.ctx.getImageData(0,0,c.Width,c.Height);
|
|
38
|
-
}
|
|
39
|
-
draw(all=true){
|
|
40
|
-
if(all){
|
|
41
|
-
this.clear();
|
|
42
|
-
this.items.forEach(element => {
|
|
43
|
-
element.parent=this;
|
|
44
|
-
element.draw(this.ctx)
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.items.at(-1).parent=this;
|
|
49
|
-
this.items.at(-1).draw(this.ctx);
|
|
50
|
-
}
|
|
51
|
-
this.maintain();
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
applyTransformMatrix(){
|
|
55
|
-
this.ctx.setTransform(
|
|
56
|
-
this.transformMatrix[0][0],
|
|
57
|
-
this.transformMatrix[1][0],
|
|
58
|
-
this.transformMatrix[0][1],
|
|
59
|
-
this.transformMatrix[1][1],
|
|
60
|
-
this.transformMatrix[0][2],
|
|
61
|
-
this.transformMatrix[1][2],
|
|
62
|
-
);
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
resize(w,h){
|
|
66
|
-
this.size(w,h)
|
|
67
|
-
this.lineWidth();
|
|
68
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
69
|
-
this.emit("sizeupdated");
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
adjust(){
|
|
73
|
-
this.element.width =this.element?.getBoundingClientRect().width;
|
|
74
|
-
this.element.height =this.element?.getBoundingClientRect().height;
|
|
75
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
view(xMin,yMin,xMax,yMax){
|
|
79
|
-
this.transformMatrix[0][0]=this.width/(xMax-xMin); // scaleX
|
|
80
|
-
this.transformMatrix[1][1]=-this.height/(yMax-yMin); // scaleY
|
|
81
|
-
this.transformMatrix[0][2]=this.width/2;
|
|
82
|
-
this.transformMatrix[1][2]=this.height/2;
|
|
83
|
-
this.axisMatrix=new Matrix([
|
|
84
|
-
[xMin,yMin],
|
|
85
|
-
[xMax,yMax]
|
|
86
|
-
])
|
|
87
|
-
|
|
88
|
-
this.applyTransformMatrix();
|
|
89
|
-
this.clear();
|
|
90
|
-
this.lineWidth(1);
|
|
91
|
-
this.draw();
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
reset(){
|
|
95
|
-
this.ctx.setTransform(1,0,0,0,0,0);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
append(element){
|
|
99
|
-
this.items.push(element);
|
|
100
|
-
this.draw(false);
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
background(color){
|
|
104
|
-
this.ctx.fillStyle = color;
|
|
105
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
106
|
-
this.ctx.fillRect(0, 0, this.width, this.height);
|
|
107
|
-
this.applyTransformMatrix();
|
|
108
|
-
this.draw();
|
|
109
|
-
}
|
|
110
|
-
lineWidth(w){
|
|
111
|
-
this.ctx.lineWidth=w/this.transformMatrix[0][0];
|
|
112
|
-
return this
|
|
113
|
-
}
|
|
114
|
-
getImageData(x=0,y=0,w=this.width,h=this.height){
|
|
115
|
-
return this.ctx.getImageData(x,y,w,h);
|
|
116
|
-
}
|
|
117
|
-
clear(){
|
|
118
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
119
|
-
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
120
|
-
this.applyTransformMatrix();
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
clone(){
|
|
124
|
-
console.log(this.width)
|
|
125
|
-
const canvas=new ZikoUICanvas();
|
|
126
|
-
canvas.items=this.items;
|
|
127
|
-
canvas.transformMatrix=this.transformMatrix;
|
|
128
|
-
canvas.axisMatrix=this.axisMatrix;
|
|
129
|
-
Object.assign(canvas.cache,{...this.cache});
|
|
130
|
-
//waitForUIElm(this)
|
|
131
|
-
//console.log(element)
|
|
132
|
-
this.size(this.element.style.width,this.element.style.width);
|
|
133
|
-
this.applyTransformMatrix();
|
|
134
|
-
this.draw();
|
|
135
|
-
this.adjust();
|
|
136
|
-
return canvas;
|
|
137
|
-
}
|
|
138
|
-
toImage() {
|
|
139
|
-
this.img = document?.createElement("img");
|
|
140
|
-
this.img.src = this.element?.toDataURL("image/png");
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
toBlob() {
|
|
144
|
-
var canvas = this.element;
|
|
145
|
-
canvas.toBlob(function (blob) {
|
|
146
|
-
var newImg = document?.createElement("img"),
|
|
147
|
-
url = URL.createObjectURL(blob);
|
|
148
|
-
newImg.onload = function () {
|
|
149
|
-
URL.revokeObjectURL(url);
|
|
150
|
-
};
|
|
151
|
-
newImg.src = url;
|
|
152
|
-
console.log(newImg);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
zoomIn(){
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
zoomOut(){
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
undo(n){
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
redo(n){
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
stream(){
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const Canvas=(w,h)=>new ZikoUICanvas(w,h);
|
|
173
|
-
export{
|
|
174
|
-
ZikoUICanvas,
|
|
175
|
-
Canvas
|
|
176
|
-
}
|
|
@@ -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}
|
|
File without changes
|
|
@@ -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}
|
|
File without changes
|
|
@@ -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};
|
|
File without changes
|
|
@@ -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}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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,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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import ZikoSvgElement from "../ziko-svg-element.js";
|
|
2
|
-
class ZikoSvgGroupe extends ZikoSvgElement{
|
|
3
|
-
constructor(...svgElement){
|
|
4
|
-
super();
|
|
5
|
-
this.items=[];
|
|
6
|
-
this.element=document?.createElementNS(
|
|
7
|
-
"http://www.w3.org/2000/svg",
|
|
8
|
-
"g",
|
|
9
|
-
);
|
|
10
|
-
this.add(...svgElement)
|
|
11
|
-
}
|
|
12
|
-
add(...svgElement){
|
|
13
|
-
for(let i=0;i<svgElement.length;i++){
|
|
14
|
-
this.element?.appendChild(svgElement[i].element);
|
|
15
|
-
this.items.push(svgElement[i])
|
|
16
|
-
}
|
|
17
|
-
if(svgElement.length===1)return svgElement[0]
|
|
18
|
-
return svgElement;
|
|
19
|
-
}
|
|
20
|
-
remove(...svgElement){
|
|
21
|
-
for(let i=0;i<svgElement.length;i++){
|
|
22
|
-
this.element?.removeChild(svgElement[i].element);
|
|
23
|
-
this.items=this.items.filter(n=>n!=svgElement)
|
|
24
|
-
}
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const svgGroupe=(...svgElement)=>new ZikoSvgGroupe(...svgElement)
|
|
29
|
-
export {
|
|
30
|
-
svgGroupe,
|
|
31
|
-
ZikoSvgGroupe
|
|
32
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import ZikoSvgElement from "../ziko-svg-element.js";
|
|
2
|
-
class ZikoSvgImage extends ZikoSvgElement{
|
|
3
|
-
constructor(src="",w="100%",h="100%",x=0,y=0){
|
|
4
|
-
super()
|
|
5
|
-
this.element=document?.createElementNS(
|
|
6
|
-
"http://www.w3.org/2000/svg",
|
|
7
|
-
"image",
|
|
8
|
-
);
|
|
9
|
-
this.setSrc(src).width(w).height(h).x(x).y(y);
|
|
10
|
-
}
|
|
11
|
-
x(x){
|
|
12
|
-
this.element.x.baseVal.value=x;
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
y(y){
|
|
16
|
-
this.element.y.baseVal.value=y;
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
width(w){
|
|
20
|
-
this.element?.setAttribute("width",w);
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
height(h){
|
|
24
|
-
this.element?.setAttribute("height",h);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
setSrc(src=""){
|
|
28
|
-
this.element?.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', src)
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const svgImage=(src,w,h,x,y)=>new ZikoSvgImage(src,w,h,x,y);
|
|
33
|
-
export {
|
|
34
|
-
svgImage,
|
|
35
|
-
ZikoSvgImage
|
|
36
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./circle.js";
|
|
2
|
-
export * from "./ellipse.js";
|
|
3
|
-
export * from "./foreign-object.js";
|
|
4
|
-
export * from "./groupe.js";
|
|
5
|
-
export * from "./image.js";
|
|
6
|
-
export * from "./line.js";
|
|
7
|
-
export * from "./link.js";
|
|
8
|
-
export * from "./path.js";
|
|
9
|
-
export * from "./polygon.js";
|
|
10
|
-
export * from "./rect.js";
|
|
11
|
-
export * from "./text.js";
|