ziko 0.0.11 → 0.0.13
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/README.md +6 -3
- package/dist/ziko.cjs +5640 -4532
- package/dist/ziko.js +5640 -4532
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +5602 -4532
- package/package.json +39 -12
- package/src/__helpers__/index.js +41 -0
- package/src/app/accessibility/index.js +0 -0
- package/src/app/app.js +46 -0
- package/src/app/component/index.js +38 -0
- package/src/app/globals/index.js +20 -0
- package/src/app/index.js +12 -0
- package/src/app/params/index.js +40 -0
- package/src/app/router/index.js +67 -0
- package/src/app/seo/index.js +43 -0
- package/src/app/themes/dark.js +885 -0
- package/src/app/themes/index.js +11 -0
- package/src/app/themes/light.js +255 -0
- package/src/data/api/fetchdom.js +14 -0
- package/src/data/api/index.js +4 -0
- package/src/data/api/preload.js +11 -0
- package/src/data/converter/adoc.js +130 -0
- package/src/data/converter/array.js +43 -0
- package/src/data/converter/canvas.js +25 -0
- package/src/data/converter/csv.js +33 -0
- package/src/data/converter/idea.txt +10 -0
- package/src/data/converter/index.js +34 -0
- package/src/data/converter/json.js +80 -0
- package/src/data/converter/markdown.js +95 -0
- package/src/data/converter/object.js +70 -0
- package/src/data/converter/svg.js +11 -0
- package/src/data/decorators.js +0 -0
- package/src/data/index.js +74 -0
- package/src/data/parser/markdown.js +0 -0
- package/src/data/parser/xml.js +47 -0
- package/src/data/string/index.js +1 -0
- package/src/data/string/patterns.js +12 -0
- package/src/data/string/string.js +170 -0
- package/src/graphics/canvas/_canvas_offscreen +0 -0
- package/src/graphics/canvas/canvas.js +189 -0
- package/src/graphics/canvas/elements/Basic/arc.js +43 -0
- package/src/graphics/canvas/elements/Basic/image.js +0 -0
- package/src/graphics/canvas/elements/Basic/line.js +26 -0
- package/src/graphics/canvas/elements/Basic/path.js +0 -0
- package/src/graphics/canvas/elements/Basic/points.js +48 -0
- package/src/graphics/canvas/elements/Basic/polygon.js +7 -0
- package/src/graphics/canvas/elements/Basic/polyline.js +0 -0
- package/src/graphics/canvas/elements/Basic/rect.js +46 -0
- 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 +2 -0
- package/src/graphics/canvas/elements/Chart/stem.js +0 -0
- package/src/graphics/canvas/elements/Element.js +115 -0
- package/src/graphics/canvas/elements/Groupe.js +0 -0
- package/src/graphics/canvas/elements/grid.js +0 -0
- package/src/graphics/canvas/elements/index.js +13 -0
- package/src/graphics/canvas/filter/index.js +0 -0
- package/src/graphics/canvas/index.js +15 -0
- package/src/graphics/canvas/paint/index.js +0 -0
- package/src/graphics/canvas/utils/color.js +8 -0
- package/src/graphics/canvas/utils/floodFill.js +58 -0
- package/src/graphics/index.js +69 -0
- package/src/graphics/svg/Elements/Basic/circle.js +26 -0
- package/src/graphics/svg/Elements/Basic/ellipse.js +21 -0
- package/src/graphics/svg/Elements/Basic/foreignObject.js +33 -0
- package/src/graphics/svg/Elements/Basic/groupe.js +29 -0
- package/src/graphics/svg/Elements/Basic/image.js +33 -0
- package/src/graphics/svg/Elements/Basic/line.js +29 -0
- package/src/graphics/svg/Elements/Basic/link.js +30 -0
- package/src/graphics/svg/Elements/Basic/path.js +59 -0
- package/src/graphics/svg/Elements/Basic/polygon.js +32 -0
- package/src/graphics/svg/Elements/Basic/polyline.js +4 -0
- package/src/graphics/svg/Elements/Basic/rect.js +43 -0
- package/src/graphics/svg/Elements/Basic/text.js +26 -0
- package/src/graphics/svg/Elements/Derived/grid.js +9 -0
- package/src/graphics/svg/Elements/ZikoSvgElement.js +46 -0
- package/src/graphics/svg/Elements/index.js +14 -0
- package/src/graphics/svg/index.js +2 -0
- package/src/graphics/svg/svg.js +115 -0
- package/src/index.js +88 -0
- package/src/math/absract.js +1 -0
- package/src/math/calculus/index.js +1 -0
- package/src/math/calculus/special-functions/bessel.js +31 -0
- package/src/math/calculus/special-functions/beta.js +38 -0
- package/src/math/calculus/special-functions/gamma.js +30 -0
- package/src/math/calculus/special-functions/index.js +4 -0
- package/src/math/complex/Fractals/julia.js +0 -0
- package/src/math/complex/index.js +203 -0
- package/src/math/const.js +3 -0
- package/src/math/discret/Combinaison/index.js +34 -0
- package/src/math/discret/Conversion/index.js +86 -0
- package/src/math/discret/Logic/index.js +46 -0
- package/src/math/discret/Permutation/index.js +31 -0
- package/src/math/discret/Set/index.js +2 -0
- package/src/math/discret/Set/power-set.js +15 -0
- package/src/math/discret/Set/sub-set.js +10 -0
- package/src/math/discret/index.js +23 -0
- package/src/math/functions/index.js +182 -0
- package/src/math/index.js +189 -0
- package/src/math/matrix/Decomposition.js +90 -0
- package/src/math/matrix/LinearSystem.js +10 -0
- package/src/math/matrix/Matrix.js +717 -0
- package/src/math/matrix/index.js +3 -0
- package/src/math/numeric/index.js +0 -0
- package/src/math/random/index.js +173 -0
- package/src/math/signal/__np.py.txt +40 -0
- package/src/math/signal/conv.js +175 -0
- package/src/math/signal/fft.js +55 -0
- package/src/math/signal/filter.js +39 -0
- package/src/math/signal/functions.js +146 -0
- package/src/math/signal/index.js +110 -0
- package/src/math/statistics/Functions/index.js +100 -0
- package/src/math/statistics/index.js +16 -0
- package/src/math/utils/arithmetic.js +139 -0
- package/src/math/utils/checkers.js +29 -0
- package/src/math/utils/comparaison.js +1 -0
- package/src/math/utils/conversions.js +19 -0
- package/src/math/utils/discret.js +51 -0
- package/src/math/utils/index.js +102 -0
- package/src/math/utils/mapfun.js +50 -0
- package/src/reactivity/events/Global/Click.js +56 -0
- package/src/reactivity/events/Global/Clipboard.js +84 -0
- package/src/reactivity/events/Global/CustomEvent.js +53 -0
- package/src/reactivity/events/Global/Drag.js +137 -0
- package/src/reactivity/events/Global/Focus.js +56 -0
- package/src/reactivity/events/Global/Key.js +104 -0
- package/src/reactivity/events/Global/Mouse.js +230 -0
- package/src/reactivity/events/Global/Pointer.js +234 -0
- package/src/reactivity/events/Global/Swipe.js +147 -0
- package/src/reactivity/events/Global/Touch.js +0 -0
- package/src/reactivity/events/Global/Wheel.js +44 -0
- package/src/reactivity/events/Partiel/Hash.js +44 -0
- package/src/reactivity/events/Partiel/Input.js +59 -0
- package/src/reactivity/events/Partiel/Media.js +1 -0
- package/src/reactivity/events/ZikoEvent.js +91 -0
- package/src/reactivity/events/index.js +63 -0
- package/src/reactivity/hooks/Contexte/index.js +1 -0
- package/src/reactivity/hooks/Contexte/useSuccesifKeys.js +14 -0
- package/src/reactivity/hooks/Decorators/index.js +6 -0
- package/src/reactivity/hooks/Decorators/time.js +17 -0
- package/src/reactivity/hooks/Decorators/type.js +88 -0
- package/src/reactivity/hooks/Interactions/index.js +4 -0
- package/src/reactivity/hooks/Interactions/useBluetooth.js +48 -0
- package/src/reactivity/hooks/Interactions/useChannel.js +50 -0
- package/src/reactivity/hooks/Interactions/useEventEmmiter.js +64 -0
- package/src/reactivity/hooks/Interactions/useSerial.js +0 -0
- package/src/reactivity/hooks/Interactions/useThread.js +44 -0
- package/src/reactivity/hooks/Interactions/useUsb.js +0 -0
- package/src/reactivity/hooks/Sensors/index.js +2 -0
- package/src/reactivity/hooks/Sensors/useBattery.js +36 -0
- package/src/reactivity/hooks/Sensors/useCamera.js +0 -0
- package/src/reactivity/hooks/Sensors/useGeolocation.js +17 -0
- package/src/reactivity/hooks/Sensors/useMicro.js +0 -0
- package/src/reactivity/hooks/Sensors/useOrientation.js +0 -0
- package/src/reactivity/hooks/Storage/index.js +1 -0
- package/src/reactivity/hooks/Storage/useCookie.js +0 -0
- package/src/reactivity/hooks/Storage/useIndexedDb.js +0 -0
- package/src/reactivity/hooks/Storage/useStorage.js +73 -0
- package/src/reactivity/hooks/UI/index.js +5 -0
- package/src/reactivity/hooks/UI/useCssLink.js +0 -0
- package/src/reactivity/hooks/UI/useCssText.js +21 -0
- package/src/reactivity/hooks/UI/useFavIcon.js +38 -0
- package/src/reactivity/hooks/UI/useLinearGradient.js +0 -0
- package/src/reactivity/hooks/UI/useMediaQuery.js +43 -0
- package/src/reactivity/hooks/UI/useRadialGradient.js +0 -0
- package/src/reactivity/hooks/UI/useStyle.js +79 -0
- package/src/reactivity/hooks/UI/useTheme.js +62 -0
- package/src/reactivity/hooks/UI/useTitle.js +30 -0
- package/src/reactivity/hooks/index.js +85 -0
- package/src/reactivity/hooks/todo.md +26 -0
- package/src/reactivity/idea +2 -0
- package/src/reactivity/index.js +22 -0
- package/src/reactivity/observer/attributes.js +28 -0
- package/src/reactivity/observer/children.js +37 -0
- package/src/reactivity/observer/index.js +44 -0
- package/src/reactivity/observer/intersection.js +44 -0
- package/src/reactivity/observer/mutation.js +113 -0
- package/src/reactivity/observer/resize.js +47 -0
- package/src/reactivity/observer/screen.js +45 -0
- package/src/reactivity/observer/screen.js.txt +84 -0
- package/src/reactivity/observer/screen.txt +13 -0
- package/src/time/animation.js +76 -0
- package/src/time/index.js +54 -0
- package/src/time/loop.js +87 -0
- package/src/time/utils/decorators.js +17 -0
- package/src/time/utils/ease.js +144 -0
- package/src/time/utils/index.js +18 -0
- package/src/time/utils/performance.js +16 -0
- package/src/time/utils/ui.js +26 -0
- package/src/user-interface/elements/derived/Flex.js +103 -0
- package/src/user-interface/elements/derived/Grid.js +33 -0
- package/src/user-interface/elements/derived/elements/Notification.js +0 -0
- package/src/user-interface/elements/derived/elements/Popover.js +0 -0
- package/src/user-interface/elements/derived/elements/Popup.js +0 -0
- package/src/user-interface/elements/derived/elements/Swipper.js +4 -0
- package/src/user-interface/elements/derived/elements/Timeline.js +0 -0
- package/src/user-interface/elements/derived/elements/Toast.js +0 -0
- package/src/user-interface/elements/derived/elements/Treeview.js +0 -0
- package/src/user-interface/elements/derived/elements/accordion/accordion.js +45 -0
- package/src/user-interface/elements/derived/elements/accordion/collapsible.js +82 -0
- package/src/user-interface/elements/derived/elements/accordion/index.js +2 -0
- package/src/user-interface/elements/derived/elements/alert/alert.js +80 -0
- package/src/user-interface/elements/derived/elements/alert/index.js +1 -0
- package/src/user-interface/elements/derived/elements/alert/palette.js +52 -0
- package/src/user-interface/elements/derived/elements/carousel/index.js +50 -0
- package/src/user-interface/elements/derived/elements/code-note/SubElements.js.txt +105 -0
- package/src/user-interface/elements/derived/elements/code-note/code-cell.js +195 -0
- package/src/user-interface/elements/derived/elements/code-note/code-note.js +72 -0
- package/src/user-interface/elements/derived/elements/code-note/index.js +2 -0
- package/src/user-interface/elements/derived/elements/code-note/sub-elements.js +67 -0
- package/src/user-interface/elements/derived/elements/columns.js +1 -0
- package/src/user-interface/elements/derived/elements/fab.js +0 -0
- package/src/user-interface/elements/derived/elements/index.js +9 -0
- package/src/user-interface/elements/derived/elements/menu/index.js +1 -0
- package/src/user-interface/elements/derived/elements/menu/menu3d.js +260 -0
- package/src/user-interface/elements/derived/elements/modal/index.js +92 -0
- package/src/user-interface/elements/derived/elements/pagination/breadcrumbs.js +54 -0
- package/src/user-interface/elements/derived/elements/pagination/index.js +1 -0
- package/src/user-interface/elements/derived/elements/splitter/__ZikoUISplitter__.js +62 -0
- package/src/user-interface/elements/derived/elements/splitter/hsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/splitter/index.js +2 -0
- package/src/user-interface/elements/derived/elements/splitter/vsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/tabs/index.js +180 -0
- package/src/user-interface/elements/derived/index.js +3 -0
- package/src/user-interface/elements/primitives/ZikoUIContainerElement.js +127 -0
- package/src/user-interface/elements/primitives/ZikoUIElement.js +478 -0
- package/src/user-interface/elements/primitives/embaded/index.js +1 -0
- package/src/user-interface/elements/primitives/index.js +8 -0
- package/src/user-interface/elements/primitives/io/Form/index.js +42 -0
- package/src/user-interface/elements/primitives/io/Form/index.js.txt +104 -0
- package/src/user-interface/elements/primitives/io/Inputs/__helpers__.js +52 -0
- package/src/user-interface/elements/primitives/io/Inputs/index.js +12 -0
- package/src/user-interface/elements/primitives/io/Inputs/input/index.js +98 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-camera/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-checkbox/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-color/index.js +16 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/index.js +3 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/index.js +2 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-email.js +15 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-password.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/index.js +1 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-file.js +0 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-image.js +43 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-number/index.js +37 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-radio/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-search/index.js +45 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-slider/index.js +34 -0
- package/src/user-interface/elements/primitives/io/Select/index.js +20 -0
- package/src/user-interface/elements/primitives/io/Textarea/index.js +18 -0
- package/src/user-interface/elements/primitives/io/index.js +4 -0
- package/src/user-interface/elements/primitives/list/elements.js +0 -0
- package/src/user-interface/elements/primitives/list/index.js +139 -0
- package/src/user-interface/elements/primitives/media/Audio/index.js +17 -0
- package/src/user-interface/elements/primitives/media/Image/figure.js +19 -0
- package/src/user-interface/elements/primitives/media/Image/image.js +36 -0
- package/src/user-interface/elements/primitives/media/Image/index.js +2 -0
- package/src/user-interface/elements/primitives/media/Video/index.js +27 -0
- package/src/user-interface/elements/primitives/media/__ZikoUIDynamicMediaELement__.js +47 -0
- package/src/user-interface/elements/primitives/media/index.js +3 -0
- package/src/user-interface/elements/primitives/misc/index.js +99 -0
- package/src/user-interface/elements/primitives/semantic/index.js +82 -0
- package/src/user-interface/elements/primitives/table/elements.js +94 -0
- package/src/user-interface/elements/primitives/table/index.js +3 -0
- package/src/user-interface/elements/primitives/table/table.js +115 -0
- package/src/user-interface/elements/primitives/table/utils.js +12 -0
- package/src/user-interface/elements/primitives/text/__ZikoUIText__.js +71 -0
- package/src/user-interface/elements/primitives/text/heading.js +36 -0
- package/src/user-interface/elements/primitives/text/index.js +3 -0
- package/src/user-interface/elements/primitives/text/p.js +26 -0
- package/src/user-interface/elements/primitives/text/pre.js +0 -0
- package/src/user-interface/elements/primitives/text/text.js +81 -0
- package/src/user-interface/index.js +188 -0
- package/src/user-interface/style/index.js +510 -0
- package/src/user-interface/utils/index.js +70 -0
|
@@ -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};
|
|
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
|
|
File without changes
|
|
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
|
|
File without changes
|
|
File without changes
|
|
@@ -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;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import{
|
|
2
|
+
Svg,
|
|
3
|
+
ZikoUISvg,
|
|
4
|
+
svgCircle,
|
|
5
|
+
svgEllipse,
|
|
6
|
+
svgImage,
|
|
7
|
+
svgLine,
|
|
8
|
+
svgPolygon,
|
|
9
|
+
svgRect,
|
|
10
|
+
svgText,
|
|
11
|
+
svgGroupe,
|
|
12
|
+
svgLink,
|
|
13
|
+
svgGrid,
|
|
14
|
+
svgObject,
|
|
15
|
+
svgPath
|
|
16
|
+
} from "./svg/index.js";
|
|
17
|
+
import {
|
|
18
|
+
Canvas,
|
|
19
|
+
canvasArc,
|
|
20
|
+
canvasCircle,
|
|
21
|
+
canvasPoints,
|
|
22
|
+
canvasLine,
|
|
23
|
+
canvasRect
|
|
24
|
+
} from "./canvas/index.js";
|
|
25
|
+
const Graphics={
|
|
26
|
+
Svg,
|
|
27
|
+
ZikoUISvg,
|
|
28
|
+
svgCircle,
|
|
29
|
+
svgEllipse,
|
|
30
|
+
svgImage,
|
|
31
|
+
svgLine,
|
|
32
|
+
svgPolygon,
|
|
33
|
+
svgRect,
|
|
34
|
+
svgText,
|
|
35
|
+
svgGroupe,
|
|
36
|
+
svgLink,
|
|
37
|
+
svgGrid,
|
|
38
|
+
svgObject,
|
|
39
|
+
svgPath,
|
|
40
|
+
Canvas,
|
|
41
|
+
canvasArc,
|
|
42
|
+
canvasCircle,
|
|
43
|
+
canvasPoints,
|
|
44
|
+
canvasLine,
|
|
45
|
+
canvasRect,
|
|
46
|
+
ExtractAll: function () {
|
|
47
|
+
const keys = Object.keys(this);
|
|
48
|
+
for (let i = 0; i < keys.length; i++) {
|
|
49
|
+
const key = keys[i];
|
|
50
|
+
if (key !== 'ExtractAll' && key !== 'RemoveAll') {
|
|
51
|
+
globalThis[key] = this[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return this;
|
|
55
|
+
},
|
|
56
|
+
RemoveAll: function () {
|
|
57
|
+
const keys = Object.keys(this);
|
|
58
|
+
for (let i = 0; i < keys.length; i++) {
|
|
59
|
+
const key = keys[i];
|
|
60
|
+
if (key !== 'RemoveAll') {
|
|
61
|
+
delete globalThis[key];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export * from "./svg/index.js"
|
|
68
|
+
export * from "./canvas/index.js"
|
|
69
|
+
export default Graphics;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import ZikoSvgElement from "../ZikoSvgElement.js";
|
|
2
|
+
class ZikoSvgCircle extends ZikoSvgElement{
|
|
3
|
+
constructor(cx,cy,r){
|
|
4
|
+
super("circle")
|
|
5
|
+
this.element=document?.createElementttNS(
|
|
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 { svgCircle }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ZikoSvgElement from "../ZikoSvgElement.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{ svgEllipse }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import ZikoSvgElement from "../ZikoSvgElement.js";
|
|
2
|
+
import { Flex } from "../../../../user-interface/elements/derived/Flex.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?.createElementtNS(
|
|
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,r)=>new ZikoSvgForeignObject(x,y,r);
|
|
33
|
+
export { svgObject }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ZikoSvgElement from "../ZikoSvgElement.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 { svgGroupe }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import ZikoSvgElement from "../ZikoSvgElement.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 { svgImage }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ZikoSvgElement from "../ZikoSvgElement.js";
|
|
2
|
+
class ZikoSvgLine extends ZikoSvgElement{
|
|
3
|
+
constructor(x1,y1,x2,y2){
|
|
4
|
+
super()
|
|
5
|
+
this.element=document?.createElementtNS(
|
|
6
|
+
"http://www.w3.org/2000/svg",
|
|
7
|
+
"line",
|
|
8
|
+
);
|
|
9
|
+
this.x1(x1).y1(y1).x2(x2).y2(y2).stroke("black");
|
|
10
|
+
}
|
|
11
|
+
x1(x1){
|
|
12
|
+
this.element.x1.baseVal.value=x1;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
y1(y1){
|
|
16
|
+
this.element.y1.baseVal.value=y1;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
x2(x2){
|
|
20
|
+
this.element.x2.baseVal.value=x2;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
y2(y2){
|
|
24
|
+
this.element.y2.baseVal.value=y2;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const svgLine=(x1,y1,x2,y2)=>new ZikoSvgLine(x1,y1,x2,y2);
|
|
29
|
+
export{ svgLine }
|