zimjs 18.1.9 → 18.2.0

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/zim.js +76 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "18.1.9",
3
+ "version": "18.2.0",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -55919,7 +55919,9 @@ hitTestPoint
55919
55919
  zim DisplayObject method
55920
55920
 
55921
55921
  DESCRIPTION
55922
- See if shape of obj is hitting the global point x and y on the stage.
55922
+ Tests if shape of obj is hitting the global point x and y on the stage.
55923
+
55924
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
55923
55925
 
55924
55926
  EXAMPLE
55925
55927
  const circle = new Circle().loc(100,100).drag();
@@ -55970,7 +55972,9 @@ hitTestReg
55970
55972
  zim DisplayObject method
55971
55973
 
55972
55974
  DESCRIPTION
55973
- See if the shape shape of an object is hitting the registration point of object (other).
55975
+ Tests if the shape shape of an object is hitting the registration point of object (other).
55976
+
55977
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
55974
55978
 
55975
55979
  EXAMPLE
55976
55980
  const circle = new Circle(50, red).center().drag();
@@ -56020,6 +56024,8 @@ The rectangle is based on the position, registration and bounds of object (other
56020
56024
  num is how many points on the edge of the rectangle we test - default is 0.
56021
56025
  The four corners are always tested as well as the very middle of the rectangle.
56022
56026
 
56027
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56028
+
56023
56029
  EXAMPLE
56024
56030
  const circle = new Circle(50, red).center().drag();
56025
56031
  const rect = new Rectangle(100, 100, blue).loc(100,100);
@@ -56115,7 +56121,9 @@ zim DisplayObject method
56115
56121
  DESCRIPTION
56116
56122
  Uses an equation to see if the bounds of a rectangular object is hitting a point x, y.
56117
56123
  This is faster than hitTests on shapes - so will have the speed of hitTestBounds, hitTestCircles and hitTestGrid.
56118
- A margin parameter is provided to tweak the hitTest
56124
+ A margin parameter is provided to tweak the hitTest.
56125
+
56126
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56119
56127
 
56120
56128
  EXAMPLE
56121
56129
  const rect = new Rectangle(50, 50, red).center().drag();
@@ -56158,9 +56166,11 @@ zim DisplayObject method
56158
56166
  DESCRIPTION
56159
56167
  See if the shape of an object is hitting points on a circle of another object.
56160
56168
  The circle is based on the position, registration and bounds of object (other).
56161
- num is how many points around the circle we test - default is 8
56169
+ num is how many points around the circle we test - default is 8.
56162
56170
  Also checks center of circle hitting.
56163
56171
 
56172
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56173
+
56164
56174
  EXAMPLE
56165
56175
  var circle = new Circle(50, red).center().drag();
56166
56176
  var triangle = new Triangle(100, 100, 100, blue).loc(100,100);
@@ -56241,9 +56251,11 @@ DO NOT use with a rotated rectangle object - for that use hitTestRect() or hitTe
56241
56251
  This is faster than hitTests on shapes - so will have the speed of hitTestBounds, hitTestCircles and hitTestGrid.
56242
56252
  The circle is based on a the object radius if there is one
56243
56253
  and if no radius then the average of the width and height divided by two.
56244
- A margin parameter is provided to tweak the hitTest
56245
- The rect is based on the bounds of the second object projected globally as a rectangle
56246
- If the second object bounds are rotated, the global bounds will be bigger to keep parallel to the axes
56254
+ A margin parameter is provided to tweak the hitTest.
56255
+ The rect is based on the bounds of the second object projected globally as a rectangle.
56256
+ If the second object bounds are rotated, the global bounds will be bigger to keep parallel to the axes.
56257
+
56258
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56247
56259
 
56248
56260
  EXAMPLE
56249
56261
  const ball = new Circle(50, red).center().drag();
@@ -56306,7 +56318,9 @@ Uses an equation to see if a circlular object is hitting a point x, y.
56306
56318
  This is faster than hitTests on shapes - so will have the speed of hitTestBounds, hitTestCircles and hitTestGrid.
56307
56319
  The circle is based on a the object radius if there is one
56308
56320
  and if no radius then the average of the width and height divided by two.
56309
- A margin parameter is provided to tweak the hitTest
56321
+ A margin parameter is provided to tweak the hitTest.
56322
+
56323
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56310
56324
 
56311
56325
  EXAMPLE
56312
56326
  const ball = new Circle(50, red).center().drag();
@@ -56358,7 +56372,9 @@ Uses an equation to see if two circles are intersecting.
56358
56372
  This is faster than hitTests on shapes - so will have the speed of hitTestBounds and hitTestGrid.
56359
56373
  The circles are based on the bounds of the two objects - it does not matter on which object the method is placed.
56360
56374
  If the bounds are not square then half the average length of the sides is used as the radius.
56361
- A margin parameter is provided to tweak the hitTest
56375
+ A margin parameter is provided to tweak the hitTest.
56376
+
56377
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56362
56378
 
56363
56379
  EXAMPLE
56364
56380
  const ball = new Circle(50, red).center().drag();
@@ -56415,6 +56431,8 @@ See if obj.getBounds() is hitting other.getBounds().
56415
56431
  Margin can be adjusted to tweak the hitTest.
56416
56432
  Pass in a boundsShape shape if you want a demonstration of where the bounds are.
56417
56433
 
56434
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56435
+
56418
56436
  EXAMPLE
56419
56437
  const circle = new Circle(50, red).center().drag();
56420
56438
  const rect = new Rectangle(100, 100, blue).loc(100,100);
@@ -56472,9 +56490,12 @@ zim DisplayObject method
56472
56490
 
56473
56491
  DESCRIPTION
56474
56492
  See if the shape of an object is hitting points on a path of a Squiggle or Blob.
56475
- num is how many points between each point on the path we test - default is 2
56493
+ num is how many points between each point on the path we test - default is 2.
56494
+
56476
56495
  SEE: https://zimjs.com/hittestpath.html
56477
56496
 
56497
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56498
+
56478
56499
  EXAMPLE
56479
56500
  const path = new Blob().center();
56480
56501
  const circle = new Circle(50, purple).pos(100,100).drag();
@@ -56557,6 +56578,8 @@ Converts an x and y point to an index in a grid.
56557
56578
  If you have a grid of rectangles, for instance, use this to find out which rectangle is beneath the cursor.
56558
56579
  This technique will work faster than any of the other hit tests.
56559
56580
 
56581
+ NOTE: https://zimjs.com/tips.html#HITTEST for tips on Hit Tests
56582
+
56560
56583
  EXAMPLE
56561
56584
  const tile = new Tile(new Rectangle(100,100),5,4,10,10).center();
56562
56585
  const circle = new Circle(10,green).pos(10,10).drag();
@@ -74075,7 +74098,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
74075
74098
  //-69.5
74076
74099
 
74077
74100
  /*--
74078
- zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime)
74101
+ zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime, startAngle)
74079
74102
 
74080
74103
  MotionController
74081
74104
  zim class - extends a createjs EventDispatcher
@@ -74269,7 +74292,7 @@ METHODS
74269
74292
  pause(state, time) - state defaults to true and pauses the motionController (sets speed to 0)
74270
74293
  set state to false to unpause the motionController (sets speed to speed before pausing)
74271
74294
  set the time (default 0) to the seconds to take while slowing the motionController to 0 speed (also see ZIM TIME constant)
74272
- immediate(x, y) - set the damping immediately to this value to avoid damping to value - returns object for chaining
74295
+ immediate(x, y, rotation) - set the damping immediately to this value to avoid damping to value - returns object for chaining
74273
74296
  convert(x, y) - for manual mode, pass in x and y and damping and rotation will be calculated
74274
74297
  dispose() - remove listeners and Ticker, Swiper and GamePad, where applicable
74275
74298
 
@@ -74313,8 +74336,8 @@ dispatches a "mousedown" event if type is "mousedown" or "pressmove"
74313
74336
  dispatches a "pressing" event if type is "pressmove" - note, this dispatches even if not moving
74314
74337
  dispatches a "moving" event if target is moving and "startmoving" and "stopmoving" events
74315
74338
  --*///+69.7
74316
- zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime) {
74317
- var sig = "target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime";
74339
+ zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime, startAngle) {
74340
+ var sig = "target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime, startAngle";
74318
74341
  var duo; if (duo = zob(zim.MotionController, arguments, sig, this)) return duo;
74319
74342
  z_d("69.7");
74320
74343
 
@@ -74431,6 +74454,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74431
74454
  if (container && container.backing) this.mousedownIncludes.push(container.backing);
74432
74455
  // this.mousedownExcludes = mousedownExcludes;
74433
74456
  if (zot(dampKeyup)) dampKeyup = .3;
74457
+ if (zot(startAngle)) startAngle = 0;
74434
74458
 
74435
74459
  if (boundary && boundary.type!="Blob") {
74436
74460
  target.x = zim.constrain(target.x, boundary.x, boundary.x+boundary.width);
@@ -74824,6 +74848,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74824
74848
  speedY = trig.speedY;
74825
74849
 
74826
74850
  if (!rotate) return;
74851
+
74827
74852
  if (!zot(trig.angle)) that.rotation = trig.angle+target.zimMCStartAngle;
74828
74853
  if (zot(that.rotation)) {
74829
74854
  that.rotation = that.target.rotation;
@@ -74845,6 +74870,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74845
74870
  that.dampR.immediate(oldR); // required otherwise damping equation has mind of its own
74846
74871
  that.target.rotation = oldR; // make sure to set this again as we may have changed oldR for proper rotational direction when damped
74847
74872
  that.rotation = newR;
74873
+
74848
74874
  }
74849
74875
  function normalizeAngle(a) {
74850
74876
  return (a % 360 + 360) % 360;
@@ -74906,7 +74932,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74906
74932
 
74907
74933
  function makeKeyInterval() {
74908
74934
 
74909
- that.keyInterval = interval(time, function() {
74935
+ that.keyInterval = interval(time, function() {
74910
74936
  if (down && down[0]==0&&down[1]==0&&down[2]==0&down[3]==0) {
74911
74937
  that.keyInterval.clear();
74912
74938
  that.keyInterval = null;
@@ -74982,7 +75008,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74982
75008
  var mainTicker = zim.Ticker.add(function() {
74983
75009
  if (tileObj) return;
74984
75010
  if (target.draggingCheck) return;
74985
- if (type == "manual") calculate();
75011
+ if (type == "manual" && !dPad) calculate();
74986
75012
  if (that.boundary && that.boundary.type!="Blob") {
74987
75013
  that.x = zim.constrain(that.x, that.boundary.x, that.boundary.x+that.boundary.width);
74988
75014
  that.y = zim.constrain(that.y, that.boundary.y, that.boundary.y+that.boundary.height);
@@ -91065,33 +91091,38 @@ Note: there are more features to the Web Speech API - see the HTML docs
91065
91091
 
91066
91092
  var SpeechRecognition = WW.SpeechRecognition || WW.webkitSpeechRecognition;
91067
91093
  var SpeechGrammarList = WW.SpeechGrammarList || WW.webkitSpeechGrammarList;
91094
+
91095
+ var recognition;
91096
+ var SpeechRecognitionEvent = WW.SpeechRecognitionEvent || WW.webkitSpeechRecognitionEvent;
91068
91097
  // this is causing an error on firefox even though they use this in their examples
91069
91098
  // and we have all the speech about:config setting set to true
91070
- var SpeechRecognitionEvent = WW.SpeechRecognitionEvent || WW.webkitSpeechRecognitionEvent;
91071
- var recognition = this.recognition = new SpeechRecognition();
91072
- recognition.continuous = false;
91073
- recognition.lang = this.language = "en-US";
91074
- recognition.interimResults = true;
91075
- recognition.maxAlternatives = 1;
91076
-
91077
- recognition.addEventListener("result", function(e) {
91078
- var ev = new createjs.Event("result");
91079
- ev.words = e.results[0][0].transcript;
91080
- ev.confidence = e.results[0][0].confidence;
91081
- that.dispatchEvent(ev);
91082
- });
91083
- recognition.addEventListener("speechend", function(e) {
91084
- recognition.stop();
91085
- that.dispatchEvent(e);
91086
- });
91087
- recognition.addEventListener("error", function(e) {
91088
- that.dispatchEvent(e);
91089
- });
91099
+ // so test for existence
91100
+ if (typeof SpeechRecognition != "undefined") {
91101
+ recognition = this.recognition = new SpeechRecognition();
91102
+ recognition.continuous = false;
91103
+ recognition.lang = this.language = "en-US";
91104
+ recognition.interimResults = true;
91105
+ recognition.maxAlternatives = 1;
91106
+
91107
+ recognition.addEventListener("result", function(e) {
91108
+ var ev = new createjs.Event("result");
91109
+ ev.words = e.results[0][0].transcript;
91110
+ ev.confidence = e.results[0][0].confidence;
91111
+ that.dispatchEvent(ev);
91112
+ });
91113
+ recognition.addEventListener("speechend", function(e) {
91114
+ recognition.stop();
91115
+ that.dispatchEvent(e);
91116
+ });
91117
+ recognition.addEventListener("error", function(e) {
91118
+ that.dispatchEvent(e);
91119
+ });
91120
+ }
91090
91121
 
91091
91122
  }
91092
91123
 
91093
91124
  this.listen = function(interim, language) {
91094
- if (M=="ios") {zogy("not supported on iOS Web"); return this;}
91125
+ if (M=="ios" || !recognition) {zogy("Speech recognition not supported - search how to activate"); return this;}
91095
91126
  if (zot(interim)) interim = true;
91096
91127
  recognition.interimResults = this.interim = interim;
91097
91128
  if (zot(language)) recognition.lang = this.language;
@@ -91113,7 +91144,10 @@ Note: there are more features to the Web Speech API - see the HTML docs
91113
91144
  var sig = "text, voice, volume, lang, rate, pitch";
91114
91145
  var duo; if (duo = zob(this.talk, arguments, sig)) return duo;
91115
91146
 
91116
- if (typeof speechSynthesis == "undefined") return;
91147
+ if (typeof speechSynthesis == "undefined") {
91148
+ zogy("Speech synthesis not supported - search how to activate");
91149
+ return;
91150
+ }
91117
91151
  // https://wicg.github.io/speech-api
91118
91152
  if (zot(text)) return;
91119
91153
  var utter = new SpeechSynthesisUtterance();
@@ -91140,13 +91174,13 @@ Note: there are more features to the Web Speech API - see the HTML docs
91140
91174
  }
91141
91175
 
91142
91176
  this.stopTalking = function() {
91143
- if (speechSynthesis) speechSynthesis.cancel();
91177
+ if (typeof speechSynthesis != "undefined") speechSynthesis.cancel();
91144
91178
  }
91145
91179
  this.pauseTalking = function() {
91146
- if (speechSynthesis) speechSynthesis.pause();
91180
+ if (typeof speechSynthesis != "undefined") speechSynthesis.pause();
91147
91181
  }
91148
91182
  this.resumeTalking = function() {
91149
- if (speechSynthesis) speechSynthesis.resume();
91183
+ if (typeof speechSynthesis != "undefined") speechSynthesis.resume();
91150
91184
  }
91151
91185
 
91152
91186
  this.getVoices = function() {
@@ -98460,4 +98494,4 @@ export let Ticker = zim.Ticker;
98460
98494
  export let Style = zim.Style;
98461
98495
  export let assets = zim.assets;
98462
98496
  export let assetIDs = zim.assetIDs;
98463
- export let ZIMON = zim.ZIMON;
98497
+ export let ZIMON = zim.ZIMON;