zimjs 16.2.7 → 16.2.8
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/package.json +1 -1
- package/src/zim.js +159 -9
- package/ts-src/typings/zim/index.d.ts +3 -2
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -3332,6 +3332,47 @@ zim.spline = function(points, tension, close, shape, removeLast) {
|
|
|
3332
3332
|
return path;
|
|
3333
3333
|
};//-27.695
|
|
3334
3334
|
|
|
3335
|
+
|
|
3336
|
+
/*--
|
|
3337
|
+
zim.getPointAtPercent = function(x1, y1, x2, y2, percent)
|
|
3338
|
+
|
|
3339
|
+
getPointAtPercent
|
|
3340
|
+
zim function
|
|
3341
|
+
|
|
3342
|
+
DESCRIPTION
|
|
3343
|
+
Gets a new Point along the straight line from x1,y1 to x2,y2 at a percentage of the length
|
|
3344
|
+
|
|
3345
|
+
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
3346
|
+
|
|
3347
|
+
EXAMPLE
|
|
3348
|
+
// A ZIM line() is not needed but here we place a circle 30% along the length of the line
|
|
3349
|
+
const line = new Line(500).rot(45).center();
|
|
3350
|
+
new Circle(20,red).loc(getPointAtPercent(line.startX, line.startY, line.endX, line.endY, 30));
|
|
3351
|
+
END EXAMPLE
|
|
3352
|
+
|
|
3353
|
+
PARAMETERS
|
|
3354
|
+
x1 - (default 0) - the start x of the line
|
|
3355
|
+
y1 - (default 0) - the start y of the line
|
|
3356
|
+
x2 - (default 0) - the end x of the line
|
|
3357
|
+
y2 - (default 0) - the end y of the line
|
|
3358
|
+
percent - (default 50) - the percentage along the line straight for the return point
|
|
3359
|
+
|
|
3360
|
+
RETURNS an ZIM Point() with x an y at the percentage along the straight line
|
|
3361
|
+
--*///+27.697
|
|
3362
|
+
zim.getPointAtPercent = function(x1, y1, x2, y2, percent) {
|
|
3363
|
+
z_d("27.697");
|
|
3364
|
+
if (zot(x1)) x1 = 0;
|
|
3365
|
+
if (zot(y1)) y1 = 0;
|
|
3366
|
+
if (zot(x2)) x2 = 0;
|
|
3367
|
+
if (zot(y2)) y2 = 0;
|
|
3368
|
+
if (zot(percent)) percent = 50;
|
|
3369
|
+
|
|
3370
|
+
var d = dist(x1,y1,x2,y2)*percent/100;
|
|
3371
|
+
var a = angle(x1,y1,x2,y2);
|
|
3372
|
+
return new zim.Point(x1+d*Math.cos(a*zim.RAD), y1+d*Math.sin(a*zim.RAD));
|
|
3373
|
+
};//-27.697
|
|
3374
|
+
|
|
3375
|
+
|
|
3335
3376
|
/*--
|
|
3336
3377
|
zim.pointAlongCurve = function(points, ratio, getAngle)
|
|
3337
3378
|
|
|
@@ -17626,6 +17667,16 @@ b1.removeFrom();
|
|
|
17626
17667
|
// s2.removeFrom();
|
|
17627
17668
|
END EXAMPLE
|
|
17628
17669
|
|
|
17670
|
+
EXAMPLE
|
|
17671
|
+
// Split a blob into two blobs
|
|
17672
|
+
const blobs = new Blob().center().splitBlob(1,3);
|
|
17673
|
+
blobs[0].color = blue;
|
|
17674
|
+
|
|
17675
|
+
// or with points - cuts diagonally across blob
|
|
17676
|
+
const blobs = new Blob().center().splitBlob(new Point(0,0), new Point(W,H));
|
|
17677
|
+
blobs[0].color = blue;
|
|
17678
|
+
END EXAMPLE
|
|
17679
|
+
|
|
17629
17680
|
PARAMETERS
|
|
17630
17681
|
** supports DUO - parameters or single object with properties below
|
|
17631
17682
|
** supports VEE - parameters marked with ZIM VEE mean a zim Pick() object or Pick Literal can be passed
|
|
@@ -17743,8 +17794,15 @@ reversePoints(sameStart) - reverse the order of the points
|
|
|
17743
17794
|
This also swaps each rectangle in the Bezier controls
|
|
17744
17795
|
also see the Code module for reversePoint(points) function to operate on data points in Squiggle format
|
|
17745
17796
|
Note: reversing blob points with the reversePoints function will make the starting point the last point
|
|
17746
|
-
makeSquiggle(index) - create a new Squiggle by cutting
|
|
17747
|
-
returns the new Squiggle - the
|
|
17797
|
+
makeSquiggle(index) - create a new Squiggle by cutting blob at index (default 0)
|
|
17798
|
+
returns the new Squiggle - the blob remains unchanged - so may need to remove it
|
|
17799
|
+
splitBlob(a, b, num, clean) - split a Blob into two blobs - returns an array with each blob
|
|
17800
|
+
this uses makeSquiggle() then splitPoints() to split squiggle then makeBlob() to make two blobs
|
|
17801
|
+
a - (default 0) an index of the blob - or an object with an x and y property (read globally)
|
|
17802
|
+
note - if using x, y points, these points do not have to be on the Blob - and they are global
|
|
17803
|
+
b - (default Math.ceil(num points / 2)) an index of the blob - or an object with an x and y property (read globally)
|
|
17804
|
+
num - (default 50) if points are used, this is how many points to add along the line between points to estimate cut point
|
|
17805
|
+
clean - (default true) remove original blob - set to false to not remove
|
|
17748
17806
|
update(normalize) - update the Blob if animating control points, etc. would do this in a Ticker
|
|
17749
17807
|
set normalize (default false) to true to use pointsAdjusted for rotated and scaled points
|
|
17750
17808
|
use true for manually editing points after setting rotation or scale on point
|
|
@@ -18668,6 +18726,93 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
18668
18726
|
return s;
|
|
18669
18727
|
};
|
|
18670
18728
|
|
|
18729
|
+
that.splitBlob = function(a, b, num, clean) {
|
|
18730
|
+
if (zot(a)) a = 0;
|
|
18731
|
+
if (zot(b)) b = Math.ceil(that.points.length/2);
|
|
18732
|
+
if (zot(num)) num = 50;
|
|
18733
|
+
if (zot(clean)) clean = true;
|
|
18734
|
+
if (typeof a == "number" && typeof b == "number") {
|
|
18735
|
+
var c = a;
|
|
18736
|
+
if (a > b) {
|
|
18737
|
+
a = b;
|
|
18738
|
+
b = c;
|
|
18739
|
+
}
|
|
18740
|
+
}
|
|
18741
|
+
|
|
18742
|
+
if (!zot(a.x) || !zot(b.x)) {
|
|
18743
|
+
// this gets array of cubic beziers that closestPointAlongCurve needs
|
|
18744
|
+
var blobSegments = that.segmentPoints;
|
|
18745
|
+
}
|
|
18746
|
+
|
|
18747
|
+
var p1, p2, i1, i2;
|
|
18748
|
+
if (!zot(a.x)) { // a global x,y point provided
|
|
18749
|
+
var bb = b;
|
|
18750
|
+
if (zot(b.x)) bb = that.pointCircles[b].localToGlobal(0,0);
|
|
18751
|
+
var point1 = zim.loop(num, function(i,t) {
|
|
18752
|
+
var p = zim.getPointAtPercent(a.x,a.y,bb.x,bb.y,i/t*100);
|
|
18753
|
+
if (that.hitTestPoint(p.x, p.y)) return p;
|
|
18754
|
+
});
|
|
18755
|
+
if (point1 === true) return; // not intersecting
|
|
18756
|
+
p1 = that.globalToLocal(point1.x, point1.y);
|
|
18757
|
+
// point, segmentPoints, num, interpolate, percentage
|
|
18758
|
+
var percent1 = zim.closestPointAlongCurve(p1, blobSegments, 20, false, true);
|
|
18759
|
+
} else {
|
|
18760
|
+
i1 = a;
|
|
18761
|
+
p1 = that.pointCircles[a];
|
|
18762
|
+
}
|
|
18763
|
+
|
|
18764
|
+
if (!zot(b.x)) { // a global x,y point provided
|
|
18765
|
+
var aa = a;
|
|
18766
|
+
if (zot(a.x)) aa = that.pointCircles[a].localToGlobal(0,0);
|
|
18767
|
+
var point2 = zim.loop(num, function(i,t) {
|
|
18768
|
+
var p = zim.getPointAtPercent(aa.x,aa.y,b.x,b.y,i/t*100);
|
|
18769
|
+
if (that.hitTestPoint(p.x, p.y)) return p;
|
|
18770
|
+
}, true); // reverse
|
|
18771
|
+
if (point2 === true) return; // not intersecting
|
|
18772
|
+
p2 = that.globalToLocal(point2.x, point2.y);
|
|
18773
|
+
var percent2 = zim.closestPointAlongCurve(p2, blobSegments, 20, false, true);
|
|
18774
|
+
} else {
|
|
18775
|
+
i2 = b;
|
|
18776
|
+
p2 = that.pointCircles[b];
|
|
18777
|
+
}
|
|
18778
|
+
|
|
18779
|
+
if (!zot(a.x)) i1 = that.addPoint(percent1); // returns index of point
|
|
18780
|
+
if (!zot(b.x)) i2 = that.addPoint(percent2);
|
|
18781
|
+
|
|
18782
|
+
if (!zot(a.x) && zot(b.x) && i1 <= i2) i2++;
|
|
18783
|
+
if (!zot(b.x) && zot(a.x) && i2 <= i1) i1++;
|
|
18784
|
+
if (!zot(a.x) && !zot(b.x) && i2 <= i1) i1++;
|
|
18785
|
+
|
|
18786
|
+
// turn the blob into a squiggle at the first point
|
|
18787
|
+
var s1 = that.makeSquiggle(i1).loc(that); // returns Squiggle
|
|
18788
|
+
|
|
18789
|
+
// once the blob is cut into a squiggle
|
|
18790
|
+
// we need to find the new index of the second point
|
|
18791
|
+
// we will store this as i3
|
|
18792
|
+
var num = that.points.length;
|
|
18793
|
+
let i3 = (i1 > i2) ? num-i1+i2 : i2-i1;
|
|
18794
|
+
|
|
18795
|
+
// split the squiggle into two at the adjusted second point
|
|
18796
|
+
var s2 = s1.splitPoints(i3).loc(that); // returns second Squiggle
|
|
18797
|
+
|
|
18798
|
+
// turn the squiggles into blobs
|
|
18799
|
+
var b1 = s1.makeBlob("free").loc(s1);
|
|
18800
|
+
var b2 = s2.makeBlob("free").loc(s2);
|
|
18801
|
+
|
|
18802
|
+
b1.color = that.color;
|
|
18803
|
+
b2.color = that.color;
|
|
18804
|
+
b1.borderColor = that.borderColor;
|
|
18805
|
+
b2.borderColor = that.borderColor;
|
|
18806
|
+
|
|
18807
|
+
// remove the old parts
|
|
18808
|
+
s1.dispose();
|
|
18809
|
+
s2.dispose();
|
|
18810
|
+
if (clean) that.dispose();
|
|
18811
|
+
|
|
18812
|
+
return [b1, b2];
|
|
18813
|
+
|
|
18814
|
+
}
|
|
18815
|
+
|
|
18671
18816
|
that.update = function(normalize) {
|
|
18672
18817
|
if (normalize) {
|
|
18673
18818
|
// located any rotated or scaled points
|
|
@@ -25584,9 +25729,9 @@ closeColor - (default grey) - the color of the close X if close is requested
|
|
|
25584
25729
|
autoPadding - (default 70) the padding used by AUTO width or height
|
|
25585
25730
|
autoPaddingH - (default autoPadding) the padding used by AUTO width
|
|
25586
25731
|
autoPaddingV - (default autoPadding) the padding used by AUTO height
|
|
25587
|
-
|
|
25588
|
-
|
|
25589
|
-
|
|
25732
|
+
keyboardAccess - (default false) set to true to adds a click through iframe to gain keyboard control
|
|
25733
|
+
this sets an invisible Frame keyboardMessage() that will close the pane and give key access to iFrames
|
|
25734
|
+
do not use if expecting interactive content in the Pane - it is for a start message only
|
|
25590
25735
|
style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
|
|
25591
25736
|
group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
|
|
25592
25737
|
inherit - (default null) used internally but can receive an {} of styles directly
|
|
@@ -32843,7 +32988,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
32843
32988
|
};
|
|
32844
32989
|
};
|
|
32845
32990
|
zim["z"+"ut"] = function(e) { // patch for ZIM Distill
|
|
32846
|
-
if (!zot(e) && e["ke"+"y"]) {
|
|
32991
|
+
if (!zot(e) && e["ke"+"y"]) {
|
|
32847
32992
|
zim.async("ht"+"tps://zim"+"js.com/"+"gam"+"da"+"ta."+"ph"+"p?id="+e["k"+"ey"]+"&pla"+"yer="+e["pl"+"ayer"]+"&sco"+"re="+e["sc"+"ore"]+"&reve"+"rse="+e["i"+"nfo"]["rev"+"erse"]+"&to"+"tal="+e["in"+"fo"]["to"+"tal"]+"&allow"+"Zero="+e["i"+"nfo"]["al"+"lowZe"+"ro"], e["in"+"fo"]["t"+"ype"]);
|
|
32848
32993
|
} else {
|
|
32849
32994
|
return true;
|
|
@@ -80818,13 +80963,14 @@ setDefault() - sets the frame to be the default frame
|
|
|
80818
80963
|
the default frame has the stage that addTo(), center(), etc. will use as the default container
|
|
80819
80964
|
a global varible called zdf is also available
|
|
80820
80965
|
as of ZIM ZIM 01, global variables F, S, W, H are provided for frame, stage, width and height of the default frame
|
|
80821
|
-
keyboardMessage(color, backgroundColor, message, response, percent) |ZIM DUO| - place a message to press screen for keyboard control
|
|
80966
|
+
keyboardMessage(color, backgroundColor, message, response, percent, call) |ZIM DUO| - place a message to press screen for keyboard control
|
|
80822
80967
|
works with iFrames as well to avoid having to press outside the canvas on the iframe
|
|
80823
80968
|
it does this by turning off the canvas pointer events until the iframe is pressed
|
|
80824
80969
|
color defaults to yellow, backgroundColor to black
|
|
80825
80970
|
response is the message given when the stage or iframe has been pressed to activate the keyboard
|
|
80826
80971
|
pass in "" for no message and response - to use a custom Pane() for example.
|
|
80827
80972
|
percent defaults to 80% the stage width
|
|
80973
|
+
call - the function to call when keyboard is active - or see keyboardactive event
|
|
80828
80974
|
returns the label if repositioning is desired
|
|
80829
80975
|
Dispatches a "keyboardactive" event when pressed to activate keyboard
|
|
80830
80976
|
fullscreen(mode) - set Frame to HTML fullscreen - mode defaults to true - set to false to come out of fullscreen
|
|
@@ -82873,8 +83019,8 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
82873
83019
|
// Fixed in ZIM 014 to
|
|
82874
83020
|
if (zot(zim.blurCheck)) zim.setBlurDetect(); // added in ZIM NFT 01 for tabfocus and tabblur events
|
|
82875
83021
|
|
|
82876
|
-
this.keyboardMessage = function(color, backgroundColor, message, response, percent) {
|
|
82877
|
-
var sig = "color, backgroundColor, message, response, percent";
|
|
83022
|
+
this.keyboardMessage = function(color, backgroundColor, message, response, percent, call) {
|
|
83023
|
+
var sig = "color, backgroundColor, message, response, percent, call";
|
|
82878
83024
|
var duo; if (duo = zob(that.keyboardMessage, arguments, sig)) return duo;
|
|
82879
83025
|
if (zot(color)) color = zim.yellow;
|
|
82880
83026
|
if (zot(backgroundColor)) backgroundColor = "black";
|
|
@@ -82922,6 +83068,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
82922
83068
|
});
|
|
82923
83069
|
that.stage.update();
|
|
82924
83070
|
}
|
|
83071
|
+
if (call && typeof call == "function") call();
|
|
82925
83072
|
that.dispatchEvent("keyboardactive");
|
|
82926
83073
|
}
|
|
82927
83074
|
return message==""?null:message;
|
|
@@ -88291,6 +88438,8 @@ type - "Orb"
|
|
|
88291
88438
|
** If added to ZIM Board receives these properties:
|
|
88292
88439
|
boardCol - get the visible column index of the tile (negative if left of board)
|
|
88293
88440
|
boardRow - get the visible column index of the tile (negative if right of board)
|
|
88441
|
+
color - the color of the orb
|
|
88442
|
+
color2 - the color2 of the orb
|
|
88294
88443
|
moving - get whether the item is moving (also moving event on board)
|
|
88295
88444
|
boardTile - get the tile under the item
|
|
88296
88445
|
square = a string of "row-col" - so "0-0", "0-1", "0-2", etc. and "3-2" is third row, second column
|
|
@@ -90693,6 +90842,7 @@ export let toBW = zim.toBW;
|
|
|
90693
90842
|
export let invertColor = zim.invertColor;
|
|
90694
90843
|
export let zimEase = zim.zimEase;
|
|
90695
90844
|
export let spline = zim.spline;
|
|
90845
|
+
export let getPointAtPercent = zim.getPointAtPercent;
|
|
90696
90846
|
export let pointAlongCurve = zim.pointAlongCurve;
|
|
90697
90847
|
export let distanceAlongCurve = zim.distanceAlongCurve;
|
|
90698
90848
|
export let closestPointAlongCurve = zim.closestPointAlongCurve;
|
|
@@ -376,6 +376,7 @@ declare namespace zim {
|
|
|
376
376
|
transformPoints(transformType: string, amount: number, x?: number, y?: number): this
|
|
377
377
|
reversePoints(points: [any]): this
|
|
378
378
|
makeSquiggle(index?: number): Squiggle
|
|
379
|
+
splitBlob(point1:Point, point2:Point, num?:number, clean?:boolean): [Blob]
|
|
379
380
|
update(normalized?: boolean): this
|
|
380
381
|
showControls(): this
|
|
381
382
|
hideControls(): this
|
|
@@ -688,7 +689,8 @@ declare namespace zim {
|
|
|
688
689
|
export function invertColor(hex: string): string
|
|
689
690
|
export function zimEase(points: [any], polynomials?: [any], reverse?: boolean, lockEnds?: boolean): Function
|
|
690
691
|
export function spline(points: [any], tension?: number, close?: boolean, shape?: Shape, removeLast?: boolean): string
|
|
691
|
-
export function
|
|
692
|
+
export function getPointAtPercent(x1?:number, y1?:number, x2?:number, y2?:number, percent?:number): Point
|
|
693
|
+
export function pointAlongCurve(points: [any], ratio?: number, getAngle?: boolean): {}
|
|
692
694
|
export function distanceAlongCurve(points: [any]): number
|
|
693
695
|
export function closestPointAlongCurve(point: any, segmentPoints: [any], num?: number, interpolate?: boolean, percentage?: boolean): number
|
|
694
696
|
export function transformPoints(points: [any], transformType: string, amount: number, x?: number, y?: number): [any]
|
|
@@ -1977,7 +1979,6 @@ declare namespace zim {
|
|
|
1977
1979
|
spineBorderColor: color
|
|
1978
1980
|
spineBorderWidth: number
|
|
1979
1981
|
spineBorderDashedCommand: any
|
|
1980
|
-
|
|
1981
1982
|
thicknessA: number
|
|
1982
1983
|
thicknessB: number
|
|
1983
1984
|
cross: boolean
|