zimjs 17.3.4 → 18.0.1

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/src/zim.js CHANGED
@@ -88,13 +88,14 @@ to log the item(s) to the console.
88
88
  Use F12 to open your Browser console.
89
89
  zog is dedicated to Pragma (Madeline Zen) who was coding with Dr Abstract (Dan Zen) from the start
90
90
 
91
- Also comes in six ZIM colors:
91
+ Also comes in seven ZIM colors:
92
92
  zogg("green");
93
93
  zogp("pink");
94
94
  zogb("blue");
95
95
  zogr("red");
96
96
  zogy("yellow");
97
97
  zogo("orange");
98
+ zogs("salmon");
98
99
 
99
100
  Note: If zon (comments on) is set to false before ZIM runs, then all zog() commands are turned off
100
101
 
@@ -130,6 +131,7 @@ var zogb = zon?console.log.bind(console, "%c Z ", "background: #50c4b7;"+zogStyl
130
131
  var zogr = zon?console.log.bind(console, "%c Z ", "background: #fb4758;"+zogStyle):function(){};
131
132
  var zogy = zon?console.log.bind(console, "%c Z ", "background: #ebcb35;"+zogStyle):function(){};
132
133
  var zogo = zon?console.log.bind(console, "%c Z ", "background: #f58e25;"+zogStyle):function(){};
134
+ var zogs = zon?console.log.bind(console, "%c Z ", "background: #fa8072;"+zogStyle):function(){};
133
135
  var zogl = zon?console.log.bind(console, "%c Z ", "background: #eeeeee;"+zogStyle):function(){};
134
136
  var zogd = zon?console.log.bind(console, "%c Z ", "background: #444444; border:thin solid black; color: white"):function(){};
135
137
  //-0
@@ -8075,10 +8077,10 @@ choice = Pick.choose([1,2,3]); // 1, 2, or 3
8075
8077
  const rotation = {min:10, max:20, integer:false, negative:true};
8076
8078
  // an example of a Range object - this will give values between -20 and -10 or 10 and 20
8077
8079
  // rotation now holds an object as to how to pick its value
8078
- // this can be passed into a zim.Emitter() for instance
8080
+ // this can be passed into a ZIM Emitter() for instance
8079
8081
  // which will make multiple copies and rotate them based on Pick.choose()
8080
8082
  // or this can be passed into an animation object
8081
- // and then into zim.Emitter() for the animate parameter
8083
+ // and then into Emitter() for the animate parameter
8082
8084
 
8083
8085
  const emitter = new Emitter({
8084
8086
  obj:new Rectangle(),
@@ -10801,6 +10803,12 @@ keyOut(color, tolerance, replacement) - remove color from Bitmap and a tolerance
10801
10803
  the default tolerance is .1 - the higher the tolerance the less sensitive the keying process - so more colors will be removed similar to the provided color
10802
10804
  color and tolerance can be an array of colors and tolerances (or just one tolerance if all are the same)
10803
10805
  replacement (default clear) a color to replace the keyed out color with or an optional array to match the colors array if an array is used
10806
+ removeGreenScreen(smoothing, hueMin, hueMax, satMin, lightMin) - alternative to keyOut() that keys out green
10807
+ smoothing (default 0) Edge smoothing factor (0-10) - higher values create smoother edges around subjects
10808
+ hueMin (default 80) Minimum hue value (0-360) for green detection - sets the lower bound of green hues
10809
+ hueMax (default 160) Maximum hue value (0-360) for green detection - sets the upper bound of green hues
10810
+ satMin (default 30) Minimum saturation value (0-100) - avoids detecting desaturated/grayish pixels as green
10811
+ lightMin (default 15) Minimum lightness value (0-100) - avoids detecting very dark pixels as green
10804
10812
  fromData(data, callback) - STATIC method so use the Bitmap class directly: Bitmap.fromData()
10805
10813
  The callback will receive a reference to the Bitmap after 50ms or 100ms.
10806
10814
  There is no event for making a Bitmap from base64 for instance - so this will have to do.
@@ -11145,10 +11153,104 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
11145
11153
  }
11146
11154
  }
11147
11155
  myContext.putImageData(info,top,left);
11148
- // that.updateCache()
11149
11156
  return this;
11150
11157
  }
11151
11158
 
11159
+ this.removeGreenScreen = function(smoothing, hueMin, hueMax, satMin, lightMin) {
11160
+
11161
+ if (zot(smoothing)) smoothing = 0; // Edge smoothing factor (0-10) - higher values create smoother edges around subjects
11162
+ if (zot(hueMin)) hueMin = 80; // Minimum hue value (0-360) for green detection - sets the lower bound of green hues
11163
+ if (zot(hueMax)) hueMax = 160; // Maximum hue value (0-360) for green detection - sets the upper bound of green hues
11164
+ if (zot(satMin)) satMin = 30; // Minimum saturation value (0-100) - avoids detecting desaturated/grayish pixels as green
11165
+ if (zot(lightMin)) lightMin = 15; // Minimum lightness value (0-100) - avoids detecting very dark pixels as green
11166
+
11167
+ if (!myContext) {
11168
+ that.cache(null,null,null,null,null,null,null,true);
11169
+ myContext = that.cacheCanvas.getContext('2d');
11170
+ // that.uncache();
11171
+ }
11172
+
11173
+ // Get pixel data
11174
+ var imageData = myContext.getImageData(0, 0, width, height);
11175
+ var data = imageData.data;
11176
+
11177
+ // Function to convert RGB to HSL
11178
+ function rgbToHsl(r, g, b) {
11179
+ r /= 255;
11180
+ g /= 255;
11181
+ b /= 255;
11182
+
11183
+ var max = Math.max(r, g, b);
11184
+ var min = Math.min(r, g, b);
11185
+ var h, s, l = (max + min) / 2;
11186
+
11187
+ if (max === min) {
11188
+ h = s = 0; // gray
11189
+ } else {
11190
+ var d = max - min;
11191
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
11192
+
11193
+ switch (max) {
11194
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
11195
+ case g: h = (b - r) / d + 2; break;
11196
+ case b: h = (r - g) / d + 4; break;
11197
+ }
11198
+
11199
+ h /= 6;
11200
+ }
11201
+
11202
+ return {
11203
+ h: h * 360, // convert to degrees
11204
+ s: s * 100, // percentage
11205
+ l: l * 100 // percentage
11206
+ };
11207
+ }
11208
+
11209
+ // Process each pixel
11210
+ for (var i = 0; i < data.length; i += 4) {
11211
+ var r = data[i];
11212
+ var g = data[i + 1];
11213
+ var b = data[i + 2];
11214
+
11215
+ // Convert to HSL for easier green detection
11216
+ var hsl = rgbToHsl(r, g, b);
11217
+
11218
+ // Check if pixel is in the defined green range
11219
+ var isGreen = (hsl.h >= hueMin && hsl.h <= hueMax &&
11220
+ hsl.s >= satMin &&
11221
+ hsl.l >= lightMin);
11222
+
11223
+ // Set transparency with edge smoothing
11224
+ var alpha = 255; // opaque by default
11225
+
11226
+ if (isGreen) {
11227
+ // Completely transparent pixel
11228
+ alpha = 0;
11229
+ } else if (smoothing > 0) {
11230
+ // Check if pixel is close to green range - for edge smoothing
11231
+ var hueDiff = Math.min(
11232
+ Math.abs(hsl.h - hueMin),
11233
+ Math.abs(hsl.h - hueMax)
11234
+ );
11235
+
11236
+ if (hueDiff < smoothing * 5) {
11237
+ // Reduce opacity gradually based on proximity to green
11238
+ var factor = hueDiff / (smoothing * 5);
11239
+ alpha = Math.min(255, Math.max(0, Math.round(factor * 255)));
11240
+ }
11241
+ }
11242
+
11243
+ // Save pixel with updated transparency
11244
+ data[i + 3] = alpha;
11245
+ }
11246
+
11247
+ // Update image data
11248
+ myContext.putImageData(imageData, 0, 0);
11249
+
11250
+ return that;
11251
+ }
11252
+
11253
+
11152
11254
  this.addBitmapData = function() {
11153
11255
  if (!createjs.BitmapData) {
11154
11256
  zogy("zim.Bitmap addBitmapData() needs CreatejS 1.5.0 or greater"); return that;
@@ -16422,7 +16524,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
16422
16524
  if (zot(startHead)) startHead = DS.startHead!=null?DS.startHead:null;
16423
16525
  if (zot(endHead)) endHead = DS.endHead!=null?DS.endHead:null;
16424
16526
  if (zot(strokeObj)) strokeObj = DS.strokeObj!=null?DS.strokeObj:{};
16425
-
16527
+
16426
16528
  if (zot(lineType)) lineType = DS.lineType!=null?DS.lineType:"straight";
16427
16529
  if (lineType !== "corner" && lineType != "curve") lineType = "straight";
16428
16530
  if (zot(lineOrientation)) lineOrientation = DS.lineOrientation!=null?DS.lineOrientation:"auto";
@@ -16500,7 +16602,6 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
16500
16602
  }
16501
16603
  var startArrowGuide;
16502
16604
  var endArrowGuide;
16503
-
16504
16605
  if (that._points) {
16505
16606
  var start = that._points[0];
16506
16607
  that._startX = start[0];
@@ -16591,7 +16692,6 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
16591
16692
  if (endHead && endHead.type == "Triangle") endHead.regY = endHead.startRegY;
16592
16693
  }
16593
16694
  }
16594
-
16595
16695
 
16596
16696
  if (that.lineType == "straight") {
16597
16697
  g.mt(sX, sY).lt(eX, eY);
@@ -18381,7 +18481,7 @@ Note the points property has been split into points and pointObjects (and there
18381
18481
  that.lastSelected = that.lastindex = null;
18382
18482
  }
18383
18483
  }
18384
- that.controls.hold(removeControl);
18484
+ if (that.editPoints) that.controls.hold(removeControl);
18385
18485
 
18386
18486
  if (!_controls) that.hideControls();
18387
18487
  that.dispatchEvent("update");
@@ -20684,7 +20784,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
20684
20784
  that.lastSelected = that.lastindex = null;
20685
20785
  }
20686
20786
  }
20687
- that.controls.hold(removeControl);
20787
+ if (that.editPoints) that.controls.hold(removeControl);
20688
20788
 
20689
20789
  if (!_controls) that.hideControls();
20690
20790
  that.dispatchEvent("update");
@@ -22897,7 +22997,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
22897
22997
  );
22898
22998
  if (italic) that.background.ske(10);
22899
22999
  zim.center(that.background, that, 0);
22900
- that.setBounds(that.background.x, that.background.y, that.background.width, that.background.height);
23000
+ that.setBounds(that.background.x, that.background.y, that.background.width, that.background.height);
22901
23001
  }
22902
23002
 
22903
23003
  function setSize() {
@@ -22973,7 +23073,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
22973
23073
 
22974
23074
  function setBackBounds() {
22975
23075
  var bb = backing.boundsToGlobal();
22976
- var bbb = that.boundsToGlobal(bb, true);
23076
+ var bbb = that.boundsToGlobal(bb, true);
22977
23077
  that.setBounds(bbb.x, bbb.y, bbb.width, bbb.height);
22978
23078
  }
22979
23079
 
@@ -23463,6 +23563,7 @@ zim.LabelOnPath = function(label, path, percentAngle, percents, showPath, allowT
23463
23563
 
23464
23564
  path.addTo(this);
23465
23565
  var that = this;
23566
+ this.label = label;
23466
23567
  this.path = path;
23467
23568
  this.allowToggle = allowToggle;
23468
23569
  path.interactive = interactive;
@@ -23624,7 +23725,7 @@ zim.LabelOnPath = function(label, path, percentAngle, percents, showPath, allowT
23624
23725
  if (showPath) that.toggle(true);
23625
23726
 
23626
23727
  if (style!==false) zim.styleTransforms(this, DS);
23627
- this.clone = function() {
23728
+ this.clone = function() {
23628
23729
  return that.cloneProps(new zim.LabelOnPath(that.label.clone(), that.path.clone(), percentAngle, zim.copy(percents), showPath, allowToggle, interactive, onTop, rtl, style, this.group, inherit));
23629
23730
  };
23630
23731
  this.dispose = function(a,b,disposing) {
@@ -23895,7 +23996,7 @@ zim.extend(zim.LabelOnArc, zim.Container, "clone", "zimContainer", false);
23895
23996
  //-54.55
23896
23997
 
23897
23998
  /*--
23898
- zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, style, group, inherit)
23999
+ zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, lineAlignLast, style, group, inherit)
23899
24000
 
23900
24001
  LabelLetters
23901
24002
  zim class - extends a zim.Container which extends a createjs.Container
@@ -23969,12 +24070,15 @@ lineSpacing - (default 5) - the space between lines (not including lineHeight)
23969
24070
  lineSpacings - (default null) - an array of the space between lines
23970
24071
  any values here will override the lineSpacing
23971
24072
  lineHeight - (default null) null will auto set the height. Set to a number to force line heights - if \n or <br> are present in label
23972
- lineAlign - (default LEFT or RIGHT for rtl:true) the horizontal alignment of lines if multiple lines - set to LEFT, CENTER/MIDDLE, RIGHT
24073
+ lineAlign - (default LEFT or RIGHT for rtl:true) the horizontal alignment of lines if multiple lines - set to LEFT, CENTER/MIDDLE, RIGHT, JUSTIFY
23973
24074
  set to START to lineAlign LEFT for ZIM DIR constant is "ltr" or RIGHT when DIR="rtl" - END is the opposite
24075
+ note the lineAlignLast parameter if using JUSTIFY
23974
24076
  lineValign - (default BOTTOM) the vertical alignment within lineSpacing if multiple lines - set to TOP, CENTER/MIDDLE, BOTTOM
23975
24077
  cache - (default false) set to true to cache each letter - improves performance on animation
23976
24078
  rtl - (default false) set to true to reverse letters other than a-zA-Z0-9 and set default lineAlign to RIGHT
23977
24079
  lineWidth - (default null) set the line width - could cause wrapping. Also see lineWidth property
24080
+ lineAlignLast - (default LEFT or RIGHT for rtl:true) - only applied if lineAlign is JUSTIFY
24081
+ this value can also be JUSTIFY to spread the words of the last line
23978
24082
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
23979
24083
  group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
23980
24084
  inherit - (default null) used internally but can receive an {} of styles directly
@@ -24014,8 +24118,8 @@ See the CreateJS Easel Docs for Container events such as:
24014
24118
  added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
24015
24119
  --*///+54.57
24016
24120
 
24017
- zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, style, group, inherit) {
24018
- var sig = "label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, style, group, inherit";
24121
+ zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, lineAlignLast, style, group, inherit) {
24122
+ var sig = "label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, lineAlignLast, style, group, inherit";
24019
24123
  var duo; if (duo = zob(zim.LabelLetters, arguments, sig, this)) return duo;
24020
24124
  z_d("54.57");
24021
24125
 
@@ -24034,6 +24138,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24034
24138
  if (zot(lineAlign)) lineAlign = DS.lineAlign != null ? DS.lineAlign : rtl?"right":"left";
24035
24139
  if (zot(lineValign)) lineValign = DS.lineValign != null ? DS.lineValign : "bottom";
24036
24140
  if (zot(lineWidth)) lineWidth = DS.lineWidth != null ? DS.lineWidth : "bottom";
24141
+ if (zot(lineAlignLast)) lineAlignLast = DS.lineAlignLast != null ? DS.lineAlignLast : rtl?"right":"left";
24037
24142
  if (zot(cache)) cache = DS.cache != null ? DS.cache : false;
24038
24143
 
24039
24144
  this.zimContainer_constructor(null, null, null, null, false);
@@ -24050,7 +24155,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24050
24155
  if (label.type != "Label") {
24051
24156
  data = parseHTML(label); // returns {text:text, data:data}
24052
24157
  letterData = data.data;
24053
- label = new zim.Label(data.text);
24158
+ label = new zim.Label({text:data.text, paddingH:letterSpacing/2, paddingV:2});
24054
24159
  } else {
24055
24160
  data = parseHTML(label.text);
24056
24161
  letterData = data.data;
@@ -24355,7 +24460,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24355
24460
  letter = label.clone();
24356
24461
  letter.text = label.text[i];
24357
24462
  }
24358
- that.labels.push(letter);
24463
+ that.labels.push(letter);
24464
+ var b = letter.getBounds();
24359
24465
 
24360
24466
  if (bCheck) letter.bold = true;
24361
24467
  if (iCheck) letter.italic = true;
@@ -24415,8 +24521,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24415
24521
  lineNum++;
24416
24522
  }
24417
24523
 
24418
- lineW += letter.width + s;
24419
-
24524
+ lineW += letter.width - b.x + s;
24525
+
24420
24526
  // if (lineW > lineWidth && letter.text == " ") {
24421
24527
  // lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
24422
24528
  // linePositionsY.push(lineY);
@@ -24451,15 +24557,18 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24451
24557
  // LOOP THROUGH LINES AND APPLY POSITIONS
24452
24558
  function doPositions(second) {
24453
24559
  var count = 0;
24560
+
24454
24561
  for (var j=0; j<that.lines.length; j++) {
24455
24562
  var ll = that.lines[j];
24456
24563
  if (rtl) ll.reverse(); // ZIM 017 PATCH
24457
24564
  lineW = lineWidths[j];
24458
24565
  lineH = lineHeights[j];
24459
24566
  lineY = linePositionsY[j];
24567
+ var numSpaces=0;
24460
24568
 
24461
24569
  var startX, startY;
24462
- if (lineAlign=="left" || (lineWidth>0 && !second)) startX = 0; // if lineWidth first time just measuring
24570
+ if (lineWidth > 0 && lineAlign=="justify" && second && j==that.lines.length-1 && lineAlignLast != "justify") lineAlign = lineAlignLast;
24571
+ if (lineAlign=="left" || lineAlign=="justify" || (lineWidth>0 && !second)) startX = 0; // if lineWidth first time just measuring
24463
24572
  else if (lineAlign=="right") startX = maxW-lineW;
24464
24573
  else startX = (maxW-lineW)/2;
24465
24574
  startY = lineY;
@@ -24468,7 +24577,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24468
24577
  count++;
24469
24578
  if (cache) letter.cache();
24470
24579
  letter = ll[i];
24471
- letter.regX = (align=="left")?0:(align=="right"?letter.width:letter.width/2);
24580
+
24581
+ if (letter.text == " ") numSpaces++;
24582
+ letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
24472
24583
  letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
24473
24584
 
24474
24585
  var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
@@ -24476,21 +24587,39 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24476
24587
  sY += (lineHeights[j]-letter.height)/2;
24477
24588
  } else if (lineValign=="bottom") {
24478
24589
  sY += lineHeights[j]-letter.height;
24479
- }
24590
+ }
24480
24591
  s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
24481
24592
  if (align=="left") {
24482
- letter.loc(startX, sY, that);
24593
+ letter.loc(startX, sY, that);
24483
24594
  startX = letter.x+letter.width+s;
24484
24595
  } else if (align=="right") {
24485
24596
  letter.loc(startX+letter.width, sY, that);
24486
24597
  startX = letter.x+s;
24487
- } else {
24598
+ } else {
24488
24599
  letter.loc(startX+letter.width/2, sY, that);
24489
24600
  startX = letter.x+letter.width/2+s;
24490
24601
  }
24602
+
24603
+ if (letter.backgroundColor) {
24604
+ letter.mov(0,-letter.getBounds().y*2)
24605
+ }
24491
24606
 
24492
- } // end lines letters
24493
-
24607
+ } // end lines letters
24608
+
24609
+
24610
+ if (lineWidth > 0 && lineAlign=="justify" && second && numSpaces && (j!=that.lines.length-1 || lineAlignLast=="justify")) {
24611
+
24612
+ if (numSpaces) {
24613
+ var add=0;
24614
+ var shift = (lineWidth - lineWidths[j])/numSpaces;
24615
+ for (i=0; i<ll.length; i++) {
24616
+ letter = ll[i];
24617
+ if (letter.text == " ") add+=shift;
24618
+ letter.mov(add);
24619
+ }
24620
+ }
24621
+
24622
+ }
24494
24623
 
24495
24624
  } // end lines
24496
24625
  }
@@ -24563,7 +24692,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24563
24692
  var back = 0;
24564
24693
  lines[row] = [];
24565
24694
  letters[row] = [];
24566
- lastSpace = null;
24695
+ lastSpace = null;
24567
24696
  for (var i=0; i<list.length; i++) {
24568
24697
  var letter = list[i];
24569
24698
  letter.mov(-back);
@@ -24598,7 +24727,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24598
24727
  }
24599
24728
  }
24600
24729
  if (letter.text == " ") lastSpace = count;
24601
- count++;
24730
+ count++;
24731
+
24602
24732
  }
24603
24733
  row++
24604
24734
  }
@@ -24621,7 +24751,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24621
24751
  var list = that.lines[j];
24622
24752
  for (i=0; i<list.length; i++) {
24623
24753
  var letter = list[i];
24624
- totalW += letter.width + letterSpacing;
24754
+ var b = letter.getBounds();
24755
+ totalW += letter.width + b.x*2 + letterSpacing;
24625
24756
  if (letter.height > maxHeight) maxHeight = letter.height;
24626
24757
  }
24627
24758
  if (list.length==0) maxHeight = lastMaxHeight;
@@ -24630,7 +24761,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24630
24761
  linePositionsY[j] = currentHeight;
24631
24762
  currentHeight += maxHeight + lineSpacing;
24632
24763
  lastMaxHeight = maxHeight;
24633
- totalW = 0;
24764
+ totalW = 0;
24634
24765
  }
24635
24766
 
24636
24767
  doPositions(true); // second time for real
@@ -24716,7 +24847,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24716
24847
 
24717
24848
  if (style!==false) zim.styleTransforms(this, DS);
24718
24849
  this.clone = function () {
24719
- return that.cloneProps(new zim.LabelLetters(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, style, this.group, inherit));
24850
+ return that.cloneProps(new zim.LabelLetters(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, lineAlignLast, style, this.group, inherit));
24720
24851
  };
24721
24852
 
24722
24853
  };
@@ -24892,7 +25023,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24892
25023
  if (zot(spacingH)) spacingH = DS.spacingH != null ? DS.spacingH : size/2;
24893
25024
  if (zot(spacingV)) spacingV = DS.spacingV != null ? DS.spacingV : size/2;
24894
25025
 
24895
- var that = this;
25026
+ var that = this;
24896
25027
 
24897
25028
  function make(label) {
24898
25029
  var sentence;
@@ -24916,7 +25047,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24916
25047
  make(label);
24917
25048
 
24918
25049
  this.zimWrapper_constructor(that.labels, width, spacingH, spacingV, wrapperType, align, valign, alignInner, valignInner, flip, reverse, bottomFull, colSize, rowSize, height, minSpreadNum, minStretchNum, percentVoidH, offsetVoidH, percentVoidV, offsetVoidV, minStretchFirst, style, group, inherit);
24919
-
25050
+ this.type = "LabelWords";
25051
+
24920
25052
  Object.defineProperty(this, 'text', {
24921
25053
  get: function () {
24922
25054
  return this._text;
@@ -28540,8 +28672,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28540
28672
  }
28541
28673
 
28542
28674
  if (style !== false) zim.styleTransforms(this, DS);
28675
+
28543
28676
  this.clone = function () {
28544
- return that.cloneProps(new zim.Toggle(width, height, titleBar ? titleBar.clone() : "", titleBarColor, titleBarBackgroundColor, titleBarHeight, backgroundColor, borderColor, borderWidth, corner, close, closeColor, next, nextColor, extraButton, collapse, collapseColor, that.collapsed, align, shadowColor, shadowBlur, draggable, boundary, style, this.group, inherit));
28677
+ return that.cloneProps(new zim.Panel(width, height, content, titleBar ? titleBar.text : null, titleBarColor, titleBarBackgroundColor, titleBarHeight, backgroundColor, borderColor, borderWidth, corner, close, closeColor, next, nextColor, extraButton, collapse, collapseColor, that.collapsed, align, shadowColor, shadowBlur, draggable, boundary, style, this.group, inherit));
28545
28678
  };
28546
28679
  this.doDispose = function(a,b,disposing) {
28547
28680
  // need to dispose properly for Panel
@@ -28908,6 +29041,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28908
29041
 
28909
29042
  if (content) var myContent = that.content = content;
28910
29043
  content = this.contentContainer = new zim.Container({style:false});
29044
+ content.oob = true;
28911
29045
  this.addChild(content);
28912
29046
  content.mask = mask;
28913
29047
  var stage;
@@ -29188,7 +29322,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29188
29322
  if (zot(titleBarBackgroundColor)) titleBarBackgroundColor = "rgba(0,0,0,.2)";
29189
29323
  that.titleBar = titleBar = new zim.Container(width, titleBarHeight, null, null, false).centerReg(that).mov(0,-height/2-titleBarHeight/2);
29190
29324
  var titleBarMask = new zim.Rectangle(titleBar.width-1, titleBar.height, red).alp(0).addTo(titleBar);
29191
- // titleBarLabel.setMask(titleBarMask, true);
29325
+ titleBarLabel.setMask(titleBarMask, true);
29192
29326
  var titleBarRect = that.titleBar.backing = new zim.Rectangle(width+borderWidth, titleBarHeight, titleBarBackgroundColor, null, null, [corner*.95, corner*.95, 0, 0], true, null, false, false).center(titleBar);
29193
29327
  titleBarLabel.center(titleBar).pos({x:Math.max(corner/2, Math.max(10, padding)), reg:true});
29194
29328
  that.regX = 0; that.regY = -titleBarHeight;
@@ -29205,6 +29339,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29205
29339
  } else {
29206
29340
  titleBar.on("mousedown", function () {});
29207
29341
  }
29342
+
29208
29343
 
29209
29344
  }
29210
29345
 
@@ -29439,7 +29574,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29439
29574
  var duo; if (duo = zob(that.add, arguments, sig, that)) return duo;
29440
29575
 
29441
29576
  var c = obj;
29442
- if (!c.getBounds()) {zogy("Window.add() - please add content with bounds set"); return;}
29577
+ if (!c || !c.getBounds()) {zogy("Window.add() - please add content with bounds set"); return;}
29443
29578
  makeDamp(c);
29444
29579
  if (zot(index)) index = content.numChildren;
29445
29580
  if (replace) {
@@ -29555,7 +29690,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29555
29690
  if (zot(delay)) delay = 100;
29556
29691
  makeDamp(that);
29557
29692
  if (!swipe) return;
29558
- setTimeout(function(){
29693
+ setTimeout(function(){
29694
+ if (!that.enabled) return;
29559
29695
  if (content) {
29560
29696
  zim.drag({
29561
29697
  singleTouch:true,
@@ -29566,7 +29702,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29566
29702
  slide:slide,
29567
29703
  slideFactor:slideFactor,
29568
29704
  slideSnap:(scrollBarH && (swipe===true||swipe=="auto"||swipe=="horizontal")) || (scrollBarV && (swipe===true||swipe=="auto"||swipe=="vertical"))?slideSnap:false
29569
- });
29705
+ });
29570
29706
  content.removeAllEventListeners("slidestart");
29571
29707
  content.on("slidestart", function () {
29572
29708
  that.dispatchEvent("slidestart");
@@ -29593,7 +29729,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29593
29729
  content.on("slidestop", function (e) {
29594
29730
  if (slide) stageUp(e);
29595
29731
  that.dispatchEvent("slidestop");
29596
- });
29732
+ });
29733
+
29597
29734
  if (content.getBounds() && content.getBounds().width > 0) {
29598
29735
  setdragBoundary();
29599
29736
  }
@@ -29793,7 +29930,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29793
29930
  setTimeout(function() {
29794
29931
  lastReadOnly = that.readOnly;
29795
29932
  },50);
29796
- Object.defineProperty(that, 'enabled', {
29933
+ Object.defineProperty(that, 'enabled', {
29797
29934
  get: function() {
29798
29935
  return that._enabled;
29799
29936
  },
@@ -29980,7 +30117,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29980
30117
  //-58.1
29981
30118
 
29982
30119
  /*--
29983
- zim.Page = function(width, height, color, color2, angle, corner, pattern, scalePattern, cache, style, group, inherit)
30120
+ zim.Page = function(width, height, color, color2, angle, corner, borderColor, borderWidth, pattern, scalePattern, cache, style, group, inherit)
29984
30121
 
29985
30122
  Page
29986
30123
  zim class - extends a zim.Container which extends a createjs.Container
@@ -30024,6 +30161,7 @@ height - (default zimDefaultFrame.height) the height of the Page
30024
30161
  color - |ZIM VEE| (default zim.light) the color of the page
30025
30162
  color2 - |ZIM VEE| (default null) a second color which would form a zim.GradientColor() as the color
30026
30163
  angle - (default 90) the angle for the gradient if there is a gradient
30164
+ corner
30027
30165
  pattern - (default null) a DisplayObject that will be added to the page above the backing
30028
30166
  For instance, import zim_pizzazz and use:
30029
30167
  makePattern("slants", series(grey,dark), 20, 52, 40).alp(.2)
@@ -30032,6 +30170,8 @@ scalePattern - (default "fill") scale the pattern so it fills the window (former
30032
30170
  FIT or "fit" fits inside the Page keeping proportion (formerly "smallest")
30033
30171
  FILL or "fill" fills the Page keeping proportion (formerly "biggest" or "outside")
30034
30172
  FULL or "full" keeps both x and y scales - may stretch object (formerly "both")
30173
+ borderColor (default null) set a color for the border
30174
+ borderWidth (default 1 if borderColor) set a borderWidth for the border
30035
30175
  cache - (default false or true for gradient or pattern) whether the backing and pattern is cached
30036
30176
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
30037
30177
  group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
@@ -30067,8 +30207,8 @@ EVENTS
30067
30207
  See the CreateJS Easel Docs for Container events such as:
30068
30208
  added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
30069
30209
  --*///+58.3
30070
- zim.Page = function(width, height, color, color2, angle, pattern, scalePattern, cache, style, group, inherit) {
30071
- var sig = "width, height, color, color2, angle, pattern, scalePattern, cache, style, group, inherit";
30210
+ zim.Page = function(width, height, color, color2, angle, corner, borderColor, borderWidth, pattern, scalePattern, cache, style, group, inherit) {
30211
+ var sig = "width, height, color, color2, angle, corner, borderColor, borderWidth, pattern, scalePattern, cache, style, group, inherit";
30072
30212
  var duo; if (duo = zob(zim.Page, arguments, sig, this)) return duo;
30073
30213
  z_d("58.3");
30074
30214
 
@@ -30088,9 +30228,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
30088
30228
  if (zot(angle)) angle=DS.angle!=null?DS.angle:90;
30089
30229
  if (zot(color)) color=DS.color!=null?DS.color:zim.light;
30090
30230
  if (zot(color2)) color2=DS.color2!=null?DS.color2:null;
30231
+ if (zot(corner)) corner=DS.corner!=null?DS.corner:null;
30091
30232
  if (zot(pattern)) pattern=DS.pattern!=null?DS.pattern:null;
30092
30233
  if (zot(scalePattern)) scalePattern=DS.scalePattern!=null?DS.scalePattern:"fill";
30093
30234
  if (zot(cache)) cache=DS.cache!=null?DS.cache:false;
30235
+ if (zot(borderColor)) borderColor=DS.borderColor!=null?DS.borderColor:null;
30236
+ if (zot(borderWidth)) borderWidth=DS.borderWidth!=null?DS.borderWidth:null;
30094
30237
 
30095
30238
  color = zik(color);
30096
30239
  color2 = zik(color2);
@@ -30099,7 +30242,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
30099
30242
  color = new zim.GradientColor([color, color2], [0,1], angle);
30100
30243
  color2 = null;
30101
30244
  }
30102
- var backing = this.backing = new zim.Rectangle({width:width, height:height, color:color, scaleDimensions:false, style:false}).addTo(this);
30245
+ var backing = this.backing = new zim.Rectangle({width:width, height:height, color:color, borderColor:borderColor, borderWidth:borderWidth, corner:corner, scaleDimensions:false, style:false}).addTo(this);
30103
30246
  if (zot(cache) && (!zot(color2) || !zot(pattern))) cache = true;
30104
30247
  if (cache) backing.cache();
30105
30248
  if (!zot(pattern)) {
@@ -30123,7 +30266,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
30123
30266
  this.clone = function(recursive) {
30124
30267
  if (zot(recursive)) recursive = false;
30125
30268
  if (color.type) color2 = null;
30126
- var w = that.cloneProps(new zim.Page(width, height, color, color2, angle, pattern, scalePattern, cache, style, group, inherit));
30269
+ var w = that.cloneProps(new zim.Page(width, height, color, color2, angle, corner, borderColor, borderWidth, pattern, scalePattern, cache, style, group, inherit));
30127
30270
  if (recursive) {
30128
30271
  that.cloneChildren(w);
30129
30272
  }
@@ -31072,8 +31215,9 @@ show() - shows the progress bar (returns the progress bar for chaining)
31072
31215
  hide() - hides the progress bar
31073
31216
  toggle(state - default null) - shows progress bar if hidden and hides progress bar if showing (returns the object for chaining)
31074
31217
  or pass in true to show progress bar or false to hide progress bar
31075
- run(time, close) - shows and runs the progress bar for the given time (default 3s) (also see ZIM TIME constant)
31218
+ run(time, close, repeat) - shows and runs the progress bar for the given time (default 3s) (also see ZIM TIME constant)
31076
31219
  setting close to true or false will set the main class autoHide setting
31220
+ set repeat to true to keep repeating
31077
31221
  thanks Racheli Golan for the request
31078
31222
  setBacking(backing) - change the backing of the progress bar
31079
31223
  hasProp(property as String) - returns true if property exists on object else returns false
@@ -31284,7 +31428,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31284
31428
  return that;
31285
31429
  };
31286
31430
 
31287
- that.run = function(time, close) {
31431
+ that.run = function(time, close, repeat) {
31288
31432
  if (!zot(close)) autoHide = close;
31289
31433
  if (zot(time)) time=timeType=="s"?3:3000;
31290
31434
  checkTIME(time, timeType); // check for warning
@@ -31296,8 +31440,13 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31296
31440
  that.runInterval = setInterval(function () {
31297
31441
  that.percent = (Date.now()-startTime)/t*100;
31298
31442
  if (that.percent >= 100) {
31299
- that.percent = 100;
31300
- clearInterval(that.runInterval);
31443
+ if (repeat) {
31444
+ that.percent = 0;
31445
+ startTime = Date.now();
31446
+ } else {
31447
+ that.percent = 100;
31448
+ clearInterval(that.runInterval);
31449
+ }
31301
31450
  }
31302
31451
  }, 30);
31303
31452
  return that;
@@ -31357,7 +31506,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31357
31506
  //-59.5
31358
31507
 
31359
31508
  /*--
31360
- zim.Indicator = function(width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, style, group, inherit)
31509
+ zim.Indicator = function(width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, toggleFirst, delayLights, indicatorList, selectedIndicatorList, style, group, inherit)
31361
31510
 
31362
31511
  Indicator
31363
31512
  zim class - extends a zim.Container which extends a createjs.Container
@@ -31411,17 +31560,22 @@ scale - (default 1) for all the lights including spacing
31411
31560
  lightScale - (default 1) scale for each light - keeping the spacing unchanged
31412
31561
  interactive - (default false) set to true to make lights clickable
31413
31562
  clicking on first light when first light is only light on, will toggle light
31563
+ unless toggleFirst is set to false
31414
31564
  shadowColor - (default rgba(0,0,0,.3)) set to -1 for no shadow
31415
31565
  shadowBlur - (default 5) the shadow blur if shadow is set
31416
31566
  index - (default 0) - set the index at start. Use -1 for no indicator at start.
31417
31567
  backgroundAlpha - (default 1 or .2 if indicatorType is Emoji) - affects only Emoji and custom DisplayObject indicatorType
31418
31568
  selectedIndex - same as index, kept in for backwards compatibility in ZIM DUO
31569
+ toggleFirst - (default true) set to false to not toggle first light if indicator is set to interactive
31570
+ delayLight - (default false) set to true to not activate the light when interactive is true
31571
+ sometimes something else will set the lights so just dispatch a change event without updating the light
31419
31572
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
31420
31573
  group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
31421
31574
  inherit - (default null) used internally but can receive an {} of styles directly
31422
31575
 
31423
31576
  METHODS
31424
31577
  hasProp(property as String) - returns true if property exists on object else returns false
31578
+ update() - updates lights - needed only if indicatorList or selectedIndicatorList is used and changed dynamically
31425
31579
  clone() - makes a copy with properties such as x, y, etc. also copied
31426
31580
  dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
31427
31581
 
@@ -31455,8 +31609,8 @@ dispatches a "change" event if press is true and indicator is pressed on and lig
31455
31609
  ALSO: see the CreateJS Easel Docs for Container events such as:
31456
31610
  added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
31457
31611
  --*///+60
31458
- zim.Indicator = function(width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, style, group, inherit) {
31459
- var sig = "width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, style, group, inherit";
31612
+ zim.Indicator = function(width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, toggleFirst, delayLights, indicatorList, selectedIndicatorList, style, group, inherit) {
31613
+ var sig = "width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, toggleFirst, delayLights, indicatorList, selectedIndicatorList, style, group, inherit";
31460
31614
  var duo; if (duo = zob(zim.Indicator, arguments, sig, this)) return duo;
31461
31615
  z_d("60");
31462
31616
  this.zimContainer_constructor(null,null,null,null,false);
@@ -31490,11 +31644,17 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31490
31644
  if (zot(shadowColor)) shadowColor = DS.shadowColor!=null?DS.shadowColor:"rgba(0,0,0,.3)";
31491
31645
  if (zot(shadowBlur)) shadowBlur = DS.shadowBlur!=null?DS.shadowBlur:5;
31492
31646
  if (zot(backgroundAlpha)) backgroundAlpha = DS.backgroundAlpha!=null?DS.backgroundAlpha:.2;
31647
+ if (zot(toggleFirst)) toggleFirst = DS.toggleFirst!=null?DS.toggleFirst:true;
31648
+ if (zot(delayLights)) delayLights = DS.delayLights!=null?DS.delayLights:false;
31649
+ if (zot(indicatorList)) indicatorList = DS.indicatorList!=null?DS.indicatorList:null;
31650
+ if (zot(selectedIndicatorList)) selectedIndicatorList = DS.selectedIndicatorList!=null?DS.selectedIndicatorList:null;
31493
31651
 
31494
31652
  var eventType = (!zns?WW.ACTIONEVENT=="mousedown":zim.ACTIONEVENT=="mousedown")?"mousedown":"click";
31495
31653
 
31496
31654
  var that = this;
31497
31655
  this.lights = [];
31656
+ this.indicatorList = indicatorList;
31657
+ this.selectedIndicatorList = selectedIndicatorList;
31498
31658
 
31499
31659
  var myValue;
31500
31660
  if (backdropColor != -1) {
@@ -31517,7 +31677,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31517
31677
  light = new Container(size,size).reg("center","center");
31518
31678
 
31519
31679
  // dim
31520
- if (indicatorType == "dot" || indicatorType == "circle") {
31680
+ if (that.indicatorList && that.indicatorList[i]) {
31681
+ light.dim = that.indicatorList[i];
31682
+ } else if (indicatorType == "dot" || indicatorType == "circle") {
31521
31683
  light.dim = new zim.Circle(size/2, backgroundColor, borderColor, borderWidth, null, null, null, null, null, false);
31522
31684
  } else if (indicatorType == "square" || indicatorType == "box") {
31523
31685
  light.dim = new zim.Rectangle(size, size, backgroundColor, borderColor, borderWidth, null, null, null, null, false);
@@ -31541,7 +31703,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31541
31703
  this.lights.push(light);
31542
31704
 
31543
31705
  // brights
31544
- if (selectedIndicatorType == "dot" || indicatorType == "circle") {
31706
+ if (that.selectedIndicatorList && that.selectedIndicatorList[i]) {
31707
+ light.bright = that.selectedIndicatorList[i];
31708
+ } else if (selectedIndicatorType == "dot" || indicatorType == "circle") {
31545
31709
  light.bright = new zim.Circle(size/2, foregroundColor, borderColor, borderWidth, null, null, null, null, null, false);
31546
31710
  } else if (selectedIndicatorType == "square" || selectedIndicatorType == "box") {
31547
31711
  light.bright = new zim.Rectangle(size, size, foregroundColor, borderColor, borderWidth, null, null, null, null, false);
@@ -31581,15 +31745,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31581
31745
  that.lightsEvent = lights.on(eventType, function(e) {
31582
31746
  if (myValue == e.target.znum) {
31583
31747
  if (myValue > 0) return;
31584
- else if (myValue==0){
31748
+ else if (toggleFirst && myValue==0){
31585
31749
  myValue = -1;
31586
- setLights(myValue);
31750
+ if (!delayLights) setLights(myValue);
31587
31751
  that.dispatchEvent("change");
31588
31752
  return;
31589
31753
  }
31590
31754
  }
31591
31755
  myValue = e.target.znum;
31592
- setLights(myValue);
31756
+ if (!delayLights) setLights(myValue);
31593
31757
  that.dispatchEvent("change");
31594
31758
  });
31595
31759
  }
@@ -31612,6 +31776,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31612
31776
  if ((!zim.OPTIMIZE&&(zns||!WW.OPTIMIZE)) && that.stage) that.stage.update();
31613
31777
  }
31614
31778
 
31779
+ this.update = function() {
31780
+ for (var i=0; i<num; i++) {
31781
+ var light = lights.getChildAt(i);
31782
+ if (indicatorList && indicatorList[i]) light.dim = indicatorList[i];
31783
+ if (selectedIndicatorList && selectedIndicatorList[i]) light.bright = selectedIndicatorList[i];
31784
+ }
31785
+ setLights(myValue);
31786
+ }
31787
+
31615
31788
  Object.defineProperty(this, 'index', {
31616
31789
  get: function() {
31617
31790
  return myValue;
@@ -31666,7 +31839,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31666
31839
  }
31667
31840
  }
31668
31841
  this.clone = function() {
31669
- return that.cloneProps(new zim.Indicator(width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, style, this.group, inherit));
31842
+ return that.cloneProps(new zim.Indicator(width, height, num, foregroundColor, backgroundColor, borderColor, borderWidth, backdropColor, corner, indicatorType, selectedIndicatorType, fill, scale, lightScale, interactive, shadowColor, shadowBlur, index, backgroundAlpha, selectedIndex, toggleFirst, delayLights, indicatorList, selectedIndicatorList, style, this.group, inherit));
31670
31843
  };
31671
31844
  };
31672
31845
  zim.extend(zim.Indicator, zim.Container, ["clone","dispose"], "zimContainer", false);
@@ -31845,7 +32018,7 @@ focus, blur are dispatched when the text gains and loses focus
31845
32018
  input is dispatched when the input text is typed or pasted into
31846
32019
  capture the key with the event object data property
31847
32020
  change is dispatched when the input text is different after losing focus (except if text is set programmatically)
31848
- capture the key with the event object key or keyCode properties
32021
+ capture the key a F.keydown event object key or keyCode properties
31849
32022
  See the events for HTML input field of type text
31850
32023
  See the events for ZIM Window()
31851
32024
  See the CreateJS Easel Docs for Container events such as:
@@ -32058,12 +32231,14 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
32058
32231
  }
32059
32232
  that.label.on("blur", that.tiBlur);
32060
32233
 
32061
- that.label.on("input", function (e) {
32234
+ that.label.on("fieldinput", function (e) {
32062
32235
  doPlaceholder();
32063
32236
  // if (align=="center" && label.width < width) {
32064
32237
  // label.x = (width-label.width)/2;
32065
32238
  // }
32066
- // that.dispatchEvent(e);
32239
+ var ev = new createjs.Event("input");
32240
+ ev.data = e.data;
32241
+ that.dispatchEvent(ev);
32067
32242
  });
32068
32243
  that.label.on("keydown", function (e) {
32069
32244
  that.label.deleteKey = (e.detail == 46);
@@ -32366,6 +32541,8 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
32366
32541
  this.hiddenInput.style.height = "1px";
32367
32542
  this.hiddenInput.style.fontSize = "1px";
32368
32543
 
32544
+ var that = this;
32545
+
32369
32546
  // this.hiddenInput.style.direction = rtl?"rtl":"ltr";
32370
32547
 
32371
32548
  this.onFocus = function() {
@@ -32395,15 +32572,16 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
32395
32572
  this.text = this.hiddenInput.type=="password"?newText.replace(/./g, '*'):newText;
32396
32573
  this.measureText();
32397
32574
  if (WW.M) this.positionBlinkerAndSelection();
32398
- if (!noEvent) this.dispatchEvent(e);
32575
+ var ev = new createjs.Event("fieldinput");
32576
+ if (e) ev.data = e.data;
32577
+ if (!noEvent) this.dispatchEvent(ev);
32399
32578
  }
32400
32579
  this.onSelect = function() {
32401
32580
  this.positionBlinkerAndSelection();
32402
32581
  if (this.focus) {
32403
32582
  this.blinker.replayTween();
32404
32583
  }
32405
- }
32406
- var that = this;
32584
+ }
32407
32585
  this.onKeydown = function(e) {
32408
32586
  this.deleteKey = (e.code=="Backspace"||e.code=="Delete");
32409
32587
  this.blinker.replayTween();
@@ -33289,9 +33467,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
33289
33467
 
33290
33468
  // handle possible checkboxes
33291
33469
  if (checkBox) {
33292
- zim.loop(listW, function (item, i) {
33470
+ zim.loop(listW, function (item, i) {
33293
33471
  if (listW[i]=="%-&") return;
33294
- listW[i] = zim.List.checkItem(item, null, width, "left", 10, 10, spacing, color, rollColor, selectedColor, selectedRollColor, backgroundColor, rollBackgroundColor, selectedBackgroundColor, selectedRollBackgroundColor);
33472
+ listW[i] = zim.List.checkItem(item, null, width, "left", 10, 10, spacing, zik(color), rollColor, selectedColor, selectedRollColor, zik(backgroundColor), rollBackgroundColor, selectedBackgroundColor, selectedRollBackgroundColor);
33295
33473
  });
33296
33474
  }
33297
33475
 
@@ -37377,8 +37555,10 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
37377
37555
 
37378
37556
  // ADD CONTENT TO WINDOW
37379
37557
  that.add(content);
37380
- that.add(loader, null, true);
37381
- loader.pos(0,0,RIGHT,BOTTOM)
37558
+ if (upload) {
37559
+ that.add(loader, null, true);
37560
+ loader.pos(0,0,RIGHT,BOTTOM);
37561
+ }
37382
37562
 
37383
37563
 
37384
37564
  // LINES
@@ -40211,7 +40391,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
40211
40391
 
40212
40392
  if (style!==false) zim.styleTransforms(this, DS);
40213
40393
  this.clone = function () {
40214
- return that.cloneProps(new zim.NumPad(advanced, titleBar ? titleBar.clone() : "", titleBarColor, titleBarBackgroundColor, titleBarHeight, backgroundColor, borderColor, borderWidth, corner, numberCorner, close, closeColor, collapse, collapseColor, that.collapsed, align, shadowColor, shadowBlur, draggable, boundary, style, this.group, inherit));
40394
+ return that.cloneProps(new zim.NumPad(advanced, that.titleBar ? titleBar.text : null, titleBarColor, titleBarBackgroundColor, titleBarHeight, backgroundColor, borderColor, borderWidth, corner, numberCorner, close, closeColor, collapse, collapseColor, that.collapsed, align, shadowColor, shadowBlur, draggable, boundary, style, this.group, inherit));
40215
40395
  };
40216
40396
  };
40217
40397
  zim.extend(zim.NumPad, zim.Panel, ["clone"], "zimPanel", false);
@@ -41283,6 +41463,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
41283
41463
 
41284
41464
  if (style!==false) zim.styleTransforms(this, DS);
41285
41465
  this.clone = function() {
41466
+ if (menu.core) menu = menu.core;
41286
41467
  return that.cloneProps(new zim.RadialMenu(menu, size, font, height, coreRadius, coreColor, title, titleIcon, startAngle, totalAngle, flip, shiftRadial, rotateIcons, iconsShiftRadial, backgroundColor, rollBackgroundColor, selectedBackgroundColor, selectedRollBackgroundColor, backdropColor, color, rollColor, selectedColor, selectedRollColor, borderColor, borderWidth, gradient, gap, gapAsAngle, spacing, spacingInner, spacingOuter, currentEnabled, currentSelected, open, under, style, this.group, inherit));
41287
41468
  };
41288
41469
 
@@ -42068,7 +42249,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
42068
42249
  that.value = zim.convertColor(dropper.borderColor ,"hex");
42069
42250
  that.dispatchEvent("change");
42070
42251
  if (!dropping) return;
42071
- if (dropperTarget) { // adjusted ZIM ZIM 01 to only do when dropperTarget
42252
+ if (that.dropperTarget) { // adjusted ZIM ZIM 01 to only do when dropperTarget
42072
42253
  setMock();
42073
42254
  dropper.vis(true).top();
42074
42255
  setTimeout(function() {
@@ -44621,8 +44802,8 @@ zim.Keyboard = function(labels, backgroundColor, color, shiftBackgroundColor, sh
44621
44802
  }
44622
44803
 
44623
44804
  if (style!==false) zim.styleTransforms(this, DS);
44624
- this.clone = function() {
44625
- var kb = new zim.Keyboard(labels, backgroundColor, color, shiftBackgroundColor, shiftHoldBackgroundColor, placeBackgroundColor, cursorColor, shadeAlpha, margin, corner, draggable, placeClose, shadowColor, shadowBlur, container, data, place, placeShiftH, placeShiftV, placeScale, special, rtl, hardKeyboard, layout, numPadScale, numPadDraggable, numPadOnly, numPadAdvanced, maxLength, numbersOnly, style, this.group, inherit);
44805
+ this.clone = function() {
44806
+ var kb = new zim.Keyboard(labels, backgroundColor, color, shiftBackgroundColor, shiftHoldBackgroundColor, placeBackgroundColor, placeColor, cursorColor, shadeAlpha, borderColor, borderWidth, margin, corner, draggable, placeClose, shadowColor, shadowBlur, container, data?zim.copy(data):null, place, placeShiftH, placeShiftV, placeScale, special, rtl, hardKeyboard, layout, numPadScale, numPadDraggable, numPadOnly, numPadAdvanced, maxLength, numbersOnly, style, this.group, inherit);
44626
44807
  return that.cloneProps(kb);
44627
44808
  };
44628
44809
  this.dispose = function(a,b,disposing) {
@@ -45386,7 +45567,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45386
45567
 
45387
45568
  if (zot(dblclickTime)) dblclickTime = DS.dblclickTime!=null?DS.dblclickTime:.5;
45388
45569
  var timeType = getTIME(dblclickTime);
45389
- dblclickTime *= timeType=="s"?1000:1;
45570
+ var dt = dblclickTime * (timeType=="s"?1000:1);
45390
45571
 
45391
45572
  if (zot(snapH)) snapH = DS.snapH!=null?DS.snapH:null;
45392
45573
  if (zot(snapV)) snapV = DS.snapV!=null?DS.snapV:null;
@@ -45693,7 +45874,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45693
45874
  });
45694
45875
  if (clearMove) clearselectedList();
45695
45876
  }
45696
- }, dblclickTime);
45877
+ }, dt);
45697
45878
  }
45698
45879
  downCount++;
45699
45880
  }
@@ -46373,7 +46554,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
46373
46554
  };
46374
46555
 
46375
46556
  if (style!==false) zim.styleTransforms(this, DS);
46376
- this.clone = function() {
46557
+ this.clone = function() {
46377
46558
  return that.cloneProps(new zim.Connectors(width, height, points, node, line, linear, linearWrap, linearOrder, num, snapH, snapV, dropType, zim.copy(dropArray), continuous, startIndex, duplicateLine, deleteNode, dblclick, fullMove, min, max, boundary, expand, nodeRollColor, nodeRollBorderColor, nodeSelectedColor, nodeSelectedBorderColor, baseColor, baseBorderColor, baseRollover, rootLock, grandChildren, dblclickTime, steps, style, that.group, inherit));
46378
46559
  };
46379
46560
  };
@@ -46424,17 +46605,17 @@ PARAMETERS
46424
46605
  width - (default 300) width of marquee content
46425
46606
  final marquee width will have marginLeft and marginRight added to this width
46426
46607
  height - (default 100) height of content and marquee
46427
- items - default(null) an array of Display Objects - can be interactive
46428
- time - default(5) time interval in seconds for changing items (also see ZIM TIME constant)
46608
+ items - (default null) an array of Display Objects - can be interactive
46609
+ time - (default 5) time interval in seconds for changing items (also see ZIM TIME constant)
46429
46610
  also see marqueeTime property for each item to individually override the time for viewing
46430
- transition - default("slide") the transition between items
46611
+ transition - (default "slide") the transition between items
46431
46612
  options are: "none", "reveal", "slide", "fade", "clear", "black", "white", "fan"
46432
- speed - default(.5) speed of transition in seconds (also see ZIM TIME constant)
46433
- direction - default(RIGHT) location of next item relative to current item
46613
+ speed - (default .5) speed of transition in seconds (also see ZIM TIME constant)
46614
+ direction - (default RIGHT) location of next item relative to current item
46434
46615
  options are: RIGHT, LEFT, UP, DOWN
46435
- marginLeft - default(25) width at left of content for Indicator and Pause button
46616
+ marginLeft - (default 25) width at left of content for Indicator and Pause button
46436
46617
  set to 0 to not show indicator and pause button
46437
- marginRight - default(25) width at right of content for Z logo with animated MARQUEE
46618
+ marginRight - (default 25) width at right of content for Z logo with animated MARQUEE
46438
46619
  set to 0 to not show Z logo with animated MARQUEE
46439
46620
  marqueeType - (default "dot" or "circle") the Indicator type - also "box" or "square"
46440
46621
  borderColor - (default dark) border color - any ZIM or HTML color - set to -1 for no border
@@ -46841,24 +47022,24 @@ PARAMETERS
46841
47022
  items - default(seven multicolored rectangles) an array of Display Objects - can be interactive
46842
47023
  items will be scaled to the most common width and tiled - see the tile property
46843
47024
  a String item will be converted to a new Pic(item)
46844
- viewNum - default(3) the number of items to show
46845
- time - default(.2) time in seconds to animate between items (also see ZIM TIME constant)
46846
- spacing - default(20) the space between the items
46847
- backgroundColor - default(clear) the backgroundColor - also see background property
46848
- backing - default(null) - an optional backing DisplayObject that goes on top of the backing and under the tile
46849
- padding - default(0) - the default for the background outside the tile
46850
- paddingH - default(padding) - the horizontal padding to override the padding setting
46851
- paddingV - default(padding) - the vertical padding to override the padding setting
46852
- arrowLeft - default(new Arrow().rot(180)) - an arrow for going left
46853
- arrowRight - default(new Arrow()) - an arrow for going right
46854
- arrowGap - default(20) the gap between the arrow and the backing
46855
- valign - default(CENTER) the vertical alignment of the tile items
46856
- ease - default(quadInOut) the ease of the animation - see ZIM animate() ease parameter for types
46857
- swipe - default(true) set to false to not make the tile swipeable - see also the swipe property
46858
- remember - default("zimCarousel") set to false to not remember the index when reloading the page
46859
- index - default(0 or remembered index) the starting index - see also the index property
47025
+ viewNum - (default 3) the number of items to show
47026
+ time - (default .2) time in seconds to animate between items (also see ZIM TIME constant)
47027
+ spacing - (default 20) the space between the items
47028
+ backgroundColor - (default clear) the backgroundColor - also see background property
47029
+ backing - (default null) - an optional backing DisplayObject that goes on top of the backing and under the tile
47030
+ padding - (default 0) - the default for the background outside the tile
47031
+ paddingH - (default padding) - the horizontal padding to override the padding setting
47032
+ paddingV - (default padding) - the vertical padding to override the padding setting
47033
+ arrowLeft - (default new Arrow().rot(180)) - an arrow for going left
47034
+ arrowRight - (default new Arrow()) - an arrow for going right
47035
+ arrowGap - (default 20) the gap between the arrow and the backing
47036
+ valign - (default CENTER) the vertical alignment of the tile items
47037
+ ease - (default quadInOut) the ease of the animation - see ZIM animate() ease parameter for types
47038
+ swipe - (default true) set to false to not make the tile swipeable - see also the swipe property
47039
+ remember - (default "zimCarousel") set to false to not remember the index when reloading the page
47040
+ index - (default 0 or remembered index) the starting index - see also the index property
46860
47041
  this is the index of the first (left) item in view
46861
- continuous - default(true) set to false to stop at ends
47042
+ continuous - (default true) set to false to stop at ends
46862
47043
  this will clone the items and use the modulus to keep index numbers correct
46863
47044
  if continuous is false and the carousel is cycled then it will bounce back and forth
46864
47045
  selectedIndex - same as index, kept in for backwards compatibility in ZIM DUO
@@ -46943,9 +47124,10 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
46943
47124
 
46944
47125
  this.group = group;
46945
47126
  var DS = style===false?{}:zim.getStyle("Carousel", this.group, inherit);
46946
- var that = this;
47127
+ var that = this;
46947
47128
 
46948
47129
  this.zimContainer_constructor();
47130
+ this.type = "Carousel";
46949
47131
 
46950
47132
  if (zot(items)) items = DS.items!=null?DS.items:[
46951
47133
  new Rectangle({color: red}),
@@ -47319,6 +47501,488 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
47319
47501
  zim.extend(zim.Carousel, zim.Container, ["clone", "dispose"], "zimContainer", false);
47320
47502
  //-67.45
47321
47503
 
47504
+ /*--
47505
+ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve, interactive, continuous, fade, fadeColor, vertical, sensitivity, damp, factor, index, selectedIndex, style, group, inherit)
47506
+
47507
+ Carousel3D
47508
+ zim class - extends a zim.Container which extends a createjs.Container
47509
+
47510
+ DESCRIPTION
47511
+ A 3D carousel that cycles through items as it is swiped
47512
+ or using next(), prev() or go() methods or index property.
47513
+ Can be horizontal or vertical.
47514
+ See: ZIM Carousel for a 2D component.
47515
+ See: https://zimjs.com/018/carousel3D.html for an example
47516
+
47517
+ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
47518
+
47519
+ EXAMPLE
47520
+ // normally load this in the Frame()
47521
+ F.loadAssets("ai_monsters.png", "https://zimjs.org/assets/");
47522
+ F.on("complete", ()=>{
47523
+ const pages = [];
47524
+ loop(4*4, i=>{
47525
+ const sprite = new Sprite("ai_monsters.png", 4, 4)
47526
+ .run({frame:i})
47527
+ .reg(CENTER);
47528
+ pages.push(sprite);
47529
+ });
47530
+
47531
+ // 2.5 will spread the items more in the width
47532
+ // 10 will increase height difference
47533
+ // .6 will curve them a little more
47534
+ const carousel = new zim.Carousel3D(700, 500, pages, 2.5, 10, .6)
47535
+ .center()
47536
+ .change(()=>{
47537
+ indicator.index = carousel.index;
47538
+ });
47539
+
47540
+ // optional indicator
47541
+ const indicator = new Indicator({
47542
+ width:pages.length*20,
47543
+ height:25,
47544
+ num:pages.length,
47545
+ interactive:true,
47546
+ toggleFirst:false,
47547
+ delayLights:true
47548
+ }).pos(0,80,CENTER,BOTTOM).change(()=>{
47549
+ carousel.go(indicator.index);
47550
+ });
47551
+
47552
+ // optional arrows
47553
+ new Arrow().pos(50,0,RIGHT,CENTER).tap(()=>{
47554
+ carousel.next();
47555
+ });
47556
+ new Arrow().rot(180).pos(50,0,LEFT,CENTER).tap(()=>{
47557
+ carousel.prev();
47558
+ });
47559
+ S.update();
47560
+ });
47561
+ END EXAMPLE
47562
+
47563
+ PARAMETERS
47564
+ ** supports DUO - parameters or single object with properties below
47565
+ ** supports OCT - parameter defaults can be set with STYLE control (like CSS)
47566
+ width - (default 300) the width of the component
47567
+ if vertical is false then this may not match the actual content as the equations for spreading are complex
47568
+ if vertical is true then this will set the width of the items to match
47569
+ note: if horizontal, the fade is applied across the width, so this can be adjusted to affect the fade effect
47570
+ height - (default 200) the height of the component
47571
+ if vertical is false then this will set the height of the items to match
47572
+ if vertical is true then this may not match the actual content as the equations for spreading are complex
47573
+ note: if vertical, the fade is applied across the height, so this can be adjusted to affect the fade effect
47574
+ items - (default six Pages) an array of Display Objects
47575
+ items will be scaled to the height of the component if the vertical is false
47576
+ or to the width of the component if the vertical is true
47577
+ a String item will be converted to a new Pic(item)
47578
+ if the item is not a form of Container then it will be placed in a Container so fade will work
47579
+ the original item will then be available as currentItem.content
47580
+ items will also automatically have their registration points set to the center
47581
+ widthFactor - (default 1) a number to spread out items horizontally - just experiment, for instance 2.5 or 10 and see results
47582
+ heightFactor - (default 1) a number to spread out items vertically - just experiment, for instance 2.5 or 10 and see results
47583
+ curve - (default .5) a ratio from 0-1 that will move outside items inward to make the carousel look more curved
47584
+ the equations for spreading out and scaling the items is pretty tricky
47585
+ settings also change depending on the number of items
47586
+ adjust widthFactor, heightFactor and curve until the desired look is reached
47587
+ for a horizontal carousel, adjusting the height factor will cause outside items to get smaller faster
47588
+ sometimes outside items will appear to float so then increase the curve
47589
+ sometimes the curve will cause unexpected behavior like crossing over... then reduce the curve... try .98 rather than 1 etc.
47590
+ interactive - (default false) set to true to allow interactivity within the items
47591
+ setting to true may remove swiping on the items - but this can be adjusted
47592
+ for instance, use a Page() to hold the interactive objects
47593
+ then for each page set page.background.noMouse()
47594
+ and then the items can be swiped and the interactive objects interacted with
47595
+ continuous - (default true) set to false to stop at the last item and not go backwards past the first item
47596
+ fade - (default .5) the outside alpha of the fade object that gets added to each item
47597
+ the fade object is added automatically to the top of the item and is a rectangle colored to the fadeColor parameter
47598
+ set fade to 1 to completely fade, set fade to 0 or false to not fade
47599
+ the fade is applied with 0 in the middle and the fade amount at the edges
47600
+ based on the provided width parameter for horizontal or height parameter for vertical
47601
+ so whichever of these values can be adjusted to fine tune the fade
47602
+ fadeColor - (default Frame.color) the color of the fade object - see fade
47603
+ note: just setting the alpha of an item will not work as there are items beneath
47604
+ so a fade object has been added to each item
47605
+ vertical - (default false) set to true to make a vertical carousel
47606
+ sensitivity - (default .2) the sensitivity of the ZIM Swiper() object
47607
+ set to higher to speed up and lower to slow down
47608
+ damp - (default .1) the damp value with 1 being no damping and 0 being no movement
47609
+ factor - (default 1) set to -1 to swipe the opposite way
47610
+ index - (default 0) set the desired starting index - see also the index property
47611
+ selectedIndex - same as index, kept in for backwards compatibility in ZIM DUO
47612
+ style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
47613
+ group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
47614
+ inherit - (default null) used internally but can receive an {} of styles directly
47615
+
47616
+ METHODS
47617
+ go(index, immediate, wrap) - go to an index - returns the object for chaining
47618
+ immediate defaults to false - set to true to avoid animating
47619
+ wrap defaults to false - set to true to animate the shortest route to the index
47620
+ for instance, if there are 22 items and the carousel is at index 2
47621
+ if wrap is false, it will animate forward (2,3,4,...19,20) to target index of 20
47622
+ if wrap is true, it will animate backwards (2,1,22,21,20) to a target index of 20
47623
+ prev(immediate) - go to the previous item - returns object for chaining
47624
+ immediate defaults to false - set to true to go to the item without animating
47625
+ next(immediate) - go to the next item - returns object for chaining
47626
+ immediate defaults to false - set to true to go to the item without animating
47627
+ addItem(item, index) - add an item or an array of items at an index (default at the end)
47628
+ this will adjust the items array and call makeCarousel
47629
+ removeItem(index, num) - remove an item at an index - pass an optional num to remove that many items
47630
+ makeCarousel() - if the items array is changed must call makeCarousel - see the items property
47631
+ clone() - makes a copy with properties such as x, y, etc. also copied
47632
+ dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
47633
+
47634
+ ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
47635
+ drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
47636
+ addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
47637
+ ALSO: see the CreateJS Easel Docs for Container methods, such as:
47638
+ on(), off(), getBounds(), setBounds(), cache(), uncache(), updateCache(), dispatchEvent(),
47639
+ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChildren(), etc.
47640
+
47641
+ PROPERTIES
47642
+ type - holds the class name as a String
47643
+ index - get or set the index of the item
47644
+ selectedItem - the item at the front
47645
+ each item has a content property if the item was added to a container by the carousel (only if item was not a container)
47646
+ each item has a fader property which is a ZIM Rectangle - if the fade was not false or 0
47647
+ items - the array of items
47648
+ if setting this then call makeCarousel() - also see addItem() and removeItem()
47649
+ curve - get or set the curve - see the curve parameter
47650
+ continuous - get or set whether the carousel is continuous - see the continuous parameter
47651
+ if setting this then call makeCarousel()
47652
+ swiper - reference to the ZIM Swiper object
47653
+ backing - the clear rectangle that is the swiper object
47654
+ holder - the Container that holds all the items
47655
+
47656
+ ALSO: see ZIM Container for properties such as:
47657
+ width, height, widthOnly, heightOnly, draggable, level, depth, group
47658
+ blendMode, hue, saturation, brightness, contrast, etc.
47659
+
47660
+ ALSO: see the CreateJS Easel Docs for Container properties, such as:
47661
+ x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
47662
+ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, etc.
47663
+
47664
+ EVENTS
47665
+ dispatches a "change" event (or use change() method) when a new item is at the front
47666
+ dispatches a "still" event when the pointer is up and the carousel has stopped movings
47667
+
47668
+ ALSO: see the CreateJS Easel Docs for Container events such as:
47669
+ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
47670
+ --*///+67.47
47671
+
47672
+ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve, interactive, continuous, fade, fadeColor, vertical, sensitivity, damp, factor, index, selectedIndex, style, group, inherit) {
47673
+ var sig = "width, height, items, widthFactor, heightFactor, curve, interactive, continuous, fade, fadeColor, vertical, sensitivity, damp, factor, index, selectedIndex, style, group, inherit";
47674
+ var duo; if (duo = zob(zim.Carousel3D, arguments, sig, this)) return duo;
47675
+ z_d("67.47");
47676
+
47677
+ this.group = group;
47678
+ var DS = style===false?{}:zim.getStyle("Carousel3D", this.group, inherit);
47679
+
47680
+ if (zot(width)) width = DS.width!=null?DS.width:300;
47681
+ if (zot(height)) height = DS.height!=null?DS.height:200;
47682
+
47683
+ this.zimContainer_constructor(width,height);
47684
+ this.type = "Carousel3D";
47685
+
47686
+ if (zot(items)) items = DS.items!=null?DS.items:[
47687
+ new zim.Page(200,200,blue).reg(CENTER), new zim.Page(200,200,green).reg(CENTER), new zim.Page(200,200,orange).reg(CENTER),
47688
+ new zim.Page(200,200,red).reg(CENTER), new zim.Page(200,200,pink).reg(CENTER), new zim.Page(200,200,yellow).reg(CENTER)
47689
+ ];
47690
+ if (zot(widthFactor)) widthFactor = DS.widthFactor!=null?DS.widthFactor:1;
47691
+ if (zot(heightFactor)) heightFactor = DS.heightFactor!=null?DS.heightFactor:1;
47692
+ if (zot(curve)) curve = DS.curve!=null?DS.curve:.5;
47693
+ if (zot(interactive)) interactive = DS.interactive!=null?DS.interactive:false;
47694
+ if (zot(continuous)) continuous = DS.continuous!=null?DS.continuous:true;
47695
+ if (zot(fade)) fade = DS.fade!=null?DS.fade:.5;
47696
+ if (zot(fadeColor)) fadeColor = DS.fadeColor!=null?DS.fadeColor:zdf.color;
47697
+ if (zot(vertical)) vertical = DS.vertical!=null?DS.vertical:false;
47698
+ if (zot(sensitivity)) sensitivity = DS.sensitivity!=null?DS.sensitivity:.2;
47699
+ if (zot(damp)) damp = DS.damp!=null?DS.damp:M?.5:null;
47700
+ if (zot(factor)) factor = DS.factor!=null?DS.factor:1;
47701
+
47702
+ var that = this;
47703
+ var swiperType = vertical?VERTICAL:HORIZONTAL;
47704
+ that.curve = curve;
47705
+ that.backing = new zim.Rectangle(width, height, clear).addTo(this).expand();
47706
+ that.items = items;
47707
+
47708
+ that.holder = new zim.Container(width, height).addTo(this);
47709
+ var center = (vertical?height:width)/2;
47710
+ var r = (vertical?width:height)/2;
47711
+
47712
+ var shift;
47713
+ var min, max;
47714
+
47715
+ this.makeCarousel = function() {
47716
+
47717
+ items = that.items;
47718
+ that.holder.removeAllChildren();
47719
+
47720
+ shift = (vertical?width:height)/items.length;
47721
+ zim.loop(items, function(item, i) {
47722
+ if (typeof item == "String") item = new zim.Pic(item);
47723
+ if (!item.addChild) {
47724
+ var holder = new zim.Container(item.width, item.height);
47725
+ item.center(holder);
47726
+ holder.content = item;
47727
+ item = holder;
47728
+ } else {
47729
+ item.content = item; // for consistency
47730
+ }
47731
+ item.reg(CENTER);
47732
+ item.dexIndex = i;
47733
+ item.center(that.holder);
47734
+ if (i!=0 || !interactive) {
47735
+ item.mouseEnabled = false;
47736
+ item.mouseChildren = false;
47737
+ }
47738
+ item.start = vertical?item.y:item.x;
47739
+ item.shift = i*shift;
47740
+ if (fade && !item.fader) item.fader = new zim.Rectangle(item.width+2, item.height+2, fadeColor, item.backing?fadeColor:null, item.backing?item.backing.borderWidth:null, item.backing?item.backing.corner:null).center(item).noMouse();
47741
+ })
47742
+
47743
+ if (!continuous) {
47744
+ min = -(items.length-1)*shift;
47745
+ max = 0;
47746
+ }
47747
+
47748
+ if (that.swiper) that.swiper.dispose();
47749
+
47750
+ that.swiper = new zim.Swiper(that.backing, that, "amount", sensitivity, swiperType, min, max, damp, null, factor);
47751
+ that.swiper.on("swipedown", function() {null
47752
+ that.down = true;
47753
+ })
47754
+ that.swiper.on("swipeup", function(){
47755
+ that.down = false;
47756
+ that.waiting = true;
47757
+ })
47758
+
47759
+ return that;
47760
+ }
47761
+
47762
+
47763
+ that.amount = 0;
47764
+
47765
+ that.latestIndex = null;
47766
+ that.down = false;
47767
+ that.waiting = false;
47768
+ that.stillTO;
47769
+ that.added(function(){
47770
+ that.makeCarousel();
47771
+ that.tick = Ticker.add(()=>{
47772
+ if (vertical) {
47773
+ that.holder.loop(function(item, i) {
47774
+ item.y = item.start - r + (that.amount+r+r*2*1000000 + item.shift) % (r*2);
47775
+ var delta = item.y - center;
47776
+ var w = Math.sqrt(Math.pow(r,2) - Math.pow(delta,2)) * 2;
47777
+ item.width = w;
47778
+ var sh = zim.sign((height/2-item.y)) * Math.round(Math.pow((height/2-item.y), 2)/(10+900*(1-that.curve)));
47779
+ item.mov(0,delta*heightFactor+sh);
47780
+ item.width = constrain(item.width - (width-item.width)*widthFactor,0,100000);
47781
+ item.visible = item.width>0;
47782
+
47783
+ });
47784
+ that.holder.sortBy("width");
47785
+ } else {
47786
+ that.holder.loop(function(item, i) {
47787
+ item.x = item.start - r + (that.amount+r+r*2*1000000 + item.shift) % (r*2);
47788
+ var delta = item.x - center;
47789
+ var h = Math.sqrt(Math.pow(r,2) - Math.pow(delta,2)) * 2;
47790
+ item.height = h;
47791
+ var sh = zim.sign((width/2-item.x)) * Math.round(Math.pow((width/2-item.x), 2)/(10+900*(1-that.curve)));
47792
+ item.mov(delta*widthFactor+sh);
47793
+ item.height = constrain(item.height - (height-item.height)*heightFactor,0,100000);
47794
+ item.visible = item.height>0;
47795
+ });
47796
+ that.holder.sortBy("height");
47797
+ }
47798
+ that.currentItem = that.holder.getChildAt(that.holder.numChildren-1);
47799
+ var index = that.currentItem.dexIndex;
47800
+ if (index != that.latestIndex) {
47801
+ that.holder.loop(function(item,i,t) {
47802
+ if (interactive) {
47803
+ if (item==that.currentItem) {
47804
+ item.mouseEnabled = true;
47805
+ item.mouseChildren = true;
47806
+ } else {
47807
+ item.mouseEnabled = false;
47808
+ item.mouseChildren = false;
47809
+ }
47810
+ }
47811
+ });
47812
+ that.latestIndex = index;
47813
+ that.dispatchEvent("change");
47814
+ }
47815
+ if (fade) {
47816
+ that.holder.loop(function(item) {
47817
+ var currentPos = vertical?item.y:item.x;
47818
+ var maxPos = (vertical?height:width)/2;
47819
+ item.fader.alpha = fade*(Math.abs(currentPos-maxPos)/maxPos);
47820
+ });
47821
+ }
47822
+ // that.swiper.desiredValue-=.5 // animates
47823
+ if (that.down==false) {
47824
+ if (that.waiting && Math.abs(that.amount-that.swiper.desiredValue) < shift/10) {
47825
+ that.swiper.desiredValue = Math.round(that.amount/shift)*shift;
47826
+ that.waiting = false;
47827
+ if (that.stillTO) that.stillTO.clear();
47828
+ that.stillTO = zim.timeout(.5, function() {
47829
+ that.dispatchEvent("still");
47830
+ });
47831
+ }
47832
+ } else {
47833
+ if (that.stillTO) {
47834
+ that.stillTO.clear();
47835
+ that.stillTO = null;
47836
+ }
47837
+ }
47838
+ if (!continuous) {
47839
+ that.holder.loop(function(item) {
47840
+ var p = vertical?item.y:item.x
47841
+ if (item.dexIndex < index && p > center) item.visible = false;
47842
+ else if (item.dexIndex > index && p < center) item.visible = false;
47843
+ else item.visible = true;
47844
+ })
47845
+ }
47846
+ });
47847
+
47848
+ if (startIndex) that.go(startIndex, true);
47849
+
47850
+ });
47851
+
47852
+
47853
+ this.addItem = function(item, index) {
47854
+ if (zot(index)) index = that.items.length;
47855
+ if (!Array.isArray(item)) item = [item];
47856
+ var start = that.items.slice(0,index);
47857
+ var end = that.items.slice(index);
47858
+ that.items = start.concat(item, end);
47859
+ that.makeCarousel();
47860
+ if (index < that.index) that.go(that.index+1, true);
47861
+ return that;
47862
+ }
47863
+
47864
+ this.removeItem = function(index, num) {
47865
+ if (zot(index)) return that;
47866
+ if (zot(num)) num = 1;
47867
+ that.items.splice(index,num);
47868
+ that.makeCarousel();
47869
+ if (index < that.index) that.go(that.index-1, true);
47870
+ return that;
47871
+ }
47872
+
47873
+
47874
+ this.next = function(immediate) {
47875
+ var newVal = that.swiper.desiredValue-shift;
47876
+ if (!continuous && newVal < min) return that;
47877
+ that.swiper.desiredValue = newVal;
47878
+ if (immediate) that.swiper.immediate(that.swiper.desiredValue);
47879
+ return that;
47880
+ }
47881
+ this.prev = function(immediate) {
47882
+ var newVal = that.swiper.desiredValue+shift;
47883
+ if (!continuous && newVal > max) return that;
47884
+ that.swiper.desiredValue = newVal;
47885
+ if (immediate) that.swiper.immediate(that.swiper.desiredValue);
47886
+ return that;
47887
+ }
47888
+ this.go = function(target, immediate, wrap) {
47889
+ var num;
47890
+ var index = that.index;
47891
+ items = that.items;
47892
+ if (!that.swiper) return that;
47893
+ if (typeof target == "number") {
47894
+ num = target;
47895
+ } else {
47896
+ num = target.dexIndex;
47897
+ }
47898
+ if (num == index) return that;
47899
+ if (!continuous) {
47900
+ that.swiper.desiredValue = -num*shift;
47901
+ } else {
47902
+ if (wrap) {
47903
+ var a;
47904
+ var b;
47905
+ if (num>index) {
47906
+ a = index+items.length - num;
47907
+ b = num-index;
47908
+ if (b > a) {
47909
+ that.swiper.desiredValue += a*shift;
47910
+ } else {
47911
+ that.swiper.desiredValue -= b*shift;
47912
+ }
47913
+ } else {
47914
+ a = num+items.length - index;
47915
+ b = index-num;
47916
+ if (b > a) {
47917
+ that.swiper.desiredValue -= a*shift;
47918
+ } else {
47919
+ that.swiper.desiredValue += b*shift;
47920
+ }
47921
+ }
47922
+ } else {
47923
+ if (num>index) that.swiper.desiredValue -= (num-index)*shift;
47924
+ else that.swiper.desiredValue += (index-num)*shift;
47925
+ }
47926
+ if (immediate) that.swiper.immediate(that.swiper.desiredValue);
47927
+ }
47928
+ return that;
47929
+ }
47930
+
47931
+ var startIndex;
47932
+ if (index) startIndex = index;
47933
+
47934
+ Object.defineProperty(that, 'index', {
47935
+ get: function() {
47936
+ return that.currentItem?that.currentItem.dexIndex:null;
47937
+ },
47938
+ set: function(val) {
47939
+ that.go(val);
47940
+ }
47941
+ });
47942
+
47943
+ Object.defineProperty(that, 'selectedIndex', {
47944
+ get: function() {
47945
+ return that.currentItem?that.currentItem.dexIndex:null;
47946
+ },
47947
+ set: function(val) {
47948
+ that.go(val);
47949
+ }
47950
+ });
47951
+
47952
+ Object.defineProperty(that, 'continuous', {
47953
+ get: function() {
47954
+ return continuous;
47955
+ },
47956
+ set: function(val) {
47957
+ if (val != continuous) {
47958
+ continuous = val;
47959
+ that.makeCarousel();
47960
+ if (!continuous) that.swiper.immediate(-that.index*shift);
47961
+ }
47962
+ }
47963
+ });
47964
+
47965
+ this.dispose = function(a,b,disposing) {
47966
+ if (that.swiper) that.swiper.dispose();
47967
+ if (!disposing) {this.zimContainer_dispose();}
47968
+ return true;
47969
+ };
47970
+
47971
+ if (style!==false) zim.styleTransforms(this, DS);
47972
+ this.clone = function() {
47973
+ var newItems = [];
47974
+ for (var i=0; i<that.items.length; i++) {
47975
+ var newItem = that.items[i];
47976
+ if (newItem.duplicate) newItems.push(newItem.duplicate());
47977
+ else if (newItem.clone) newItems.push(newItem.clone());
47978
+ else newItems.push(zim.copy(that.items[i]));
47979
+ }
47980
+ return that.cloneProps(new zim.Carousel3D(width, height, newItems, widthFactor, heightFactor, that.curve, interactive, continuous, fade, fadeColor, vertical, sensitivity, damp, factor, index, selectedIndex, style, this.group));
47981
+ };
47982
+ }
47983
+ zim.extend(zim.Carousel3D, zim.Container, ["clone", "dispose"], "zimContainer", false);
47984
+ //-67.47
47985
+
47322
47986
  /*--
47323
47987
  zim.Loader = function(width, height, label, type, backgroundColor, rollBackgroundColor, color, rollColor, borderColor, borderWidth, corner, shadowColor, shadowBlur, hitPadding, gradient, gloss, dashed, backing, rollBacking, rollPersist, icon, rollIcon, toggle, toggleBacking, rollToggleBacking, toggleIcon, rollToggleIcon, toggleEvent, frame, multiple, accept, style, group, inherit)
47324
47988
 
@@ -48424,13 +49088,16 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
48424
49088
 
48425
49089
  that._enabled = true;
48426
49090
  var lastReadOnly = that.readOnly;
49091
+ var ss;
49092
+ var se;
49093
+ var sf;
48427
49094
  Object.defineProperty(that, 'enabled', {
48428
49095
  get: function() {
48429
- zog("here")
48430
49096
  return that._enabled;
48431
49097
  },
48432
49098
  set: function(value) {
48433
49099
  if (!value) {
49100
+ sf = that.tag == document.activeElement;
48434
49101
  lastReadOnly = that.readOnly;
48435
49102
  that.readOnly = false; // needed to remove selection
48436
49103
  that.focus = false;
@@ -48438,9 +49105,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
48438
49105
  setTimeout(function() {
48439
49106
  that.readOnly = true;
48440
49107
  },50); // setting readonly brings back selection even after blur - bug in HTML
49108
+ ss = that.tag.selectionStart;
49109
+ se = that.tag.selectionEnd;
48441
49110
  } else {
48442
49111
  that.tag.style.pointerEvents = "unset"; // tried all, unset, inherent, auto, initial, revert
48443
49112
  that.readOnly = lastReadOnly; // does not bring selection back
49113
+ if (sf) {
49114
+ that.tag.focus();
49115
+ that.tag.setSelectionRange(ss,se);
49116
+ }
48444
49117
  }
48445
49118
  zenable(that, value);
48446
49119
  }
@@ -50924,7 +51597,7 @@ RETURNS obj for chaining
50924
51597
  var duo; if (duo = zob(zim.tap, arguments, sig)) return duo;
50925
51598
  z_d("47.8");
50926
51599
  if (zot(obj) || zot(call) || typeof call != "function") return;
50927
- if (zot(distance)) distance = dbl?10:5;
51600
+ if (zot(distance)) distance = zim.handCursor?(dbl?100:50):(dbl?10:5);
50928
51601
  var timeType = getTIME(time);
50929
51602
  if (zot(time)) time = timeType=="s"?8:8000;
50930
51603
  if (zot(once)) once = false;
@@ -50992,7 +51665,7 @@ RETURNS obj for chaining
50992
51665
  });
50993
51666
  });
50994
51667
  } else {
50995
- obj.zimClickDownEvent = obj.on("mousedown", function (e) {
51668
+ obj.zimClickDownEvent = obj.on("mousedown", function (e) {
50996
51669
  if (e.currentTarget.type == "List") {
50997
51670
  if (e.target.type == "WindowBacking") return;
50998
51671
  var local = e.currentTarget.globalToLocal(e.stageX / zim.scaX, e.stageY / zim.scaY);
@@ -51423,7 +52096,6 @@ RETURNS obj for chaining
51423
52096
  z_d("31");
51424
52097
 
51425
52098
  if (zot(obj) || !obj.on) return;
51426
-
51427
52099
 
51428
52100
  var DA = zim.DRAGALL;
51429
52101
  if (WW.DRAGALL != null) DA = WW.DRAGALL;
@@ -51483,6 +52155,7 @@ RETURNS obj for chaining
51483
52155
  if (zot(dropHitTest)) dropHitTest = "bounds";
51484
52156
 
51485
52157
  obj.dragPaused = false;
52158
+
51486
52159
 
51487
52160
  if (slide) {
51488
52161
  // set up damping for slide and variables used to predict future locations
@@ -51825,7 +52498,7 @@ RETURNS obj for chaining
51825
52498
  r = obj.zimBoundary;
51826
52499
  if (surround) rLocal = zim.boundsToGlobal(o.parent, obj.zimBoundary, true); // flips to global to local
51827
52500
  }
51828
- }
52501
+ }
51829
52502
  x = p.x;
51830
52503
  y = p.y;
51831
52504
  if (slide) {
@@ -51835,7 +52508,7 @@ RETURNS obj for chaining
51835
52508
  // if (dampX) dampX.immediate(objUpX);
51836
52509
  // if (dampY) dampY.immediate(objUpY);
51837
52510
  }
51838
- }
52511
+ }
51839
52512
 
51840
52513
  // TODO only need this if boundary - so try and test for that first...
51841
52514
  var point;
@@ -52164,7 +52837,8 @@ RETURNS obj for chaining
52164
52837
  // if it is not snapping then the object stops at the bounds when it is slid
52165
52838
 
52166
52839
 
52167
- function setUpSlide() {
52840
+ function setUpSlide() {
52841
+
52168
52842
  obj.zimDragTicker = function() {
52169
52843
  if (zot(obj.slideStartX)) return; // don't stop other things like window scrollbar from moving object
52170
52844
 
@@ -52310,7 +52984,7 @@ RETURNS obj for chaining
52310
52984
  if (obj.zimDragTicker) {
52311
52985
  zim.Ticker.remove(obj.zimDragTicker);
52312
52986
  if (snapBack) {
52313
- var f = obj.zimCheckBounds(obj, obj.x, obj.y);
52987
+ var f = obj.zimCheckBounds(obj, obj.x, obj.y);
52314
52988
  obj.animate({x:f.x, y:f.y}, .3);
52315
52989
  }
52316
52990
  }
@@ -53073,7 +53747,7 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
53073
53747
 
53074
53748
  if (zot(container)) container = stage;
53075
53749
 
53076
- if (zot(frame.eventRemove)) {
53750
+ if (zot(frame.downEventRemove)) {
53077
53751
  stage.enableMouseOver();
53078
53752
  frame.ctrlKey = false;
53079
53753
  frame.shiftKey = false;
@@ -55382,6 +56056,50 @@ RETURNS a Boolean true if hitting, false if not
55382
56056
  }
55383
56057
  };//-37
55384
56058
 
56059
+
56060
+ /*--
56061
+ obj.hitTestRectPoint = function(x, y, margin)
56062
+
56063
+ hitTestRectPoint
56064
+ zim DisplayObject method
56065
+
56066
+ DESCRIPTION
56067
+ Uses an equation to see if the bounds of a rectangular object is hitting a point x, y.
56068
+ This is faster than hitTests on shapes - so will have the speed of hitTestBounds, hitTestCircles and hitTestGrid.
56069
+ A margin parameter is provided to tweak the hitTest
56070
+
56071
+ EXAMPLE
56072
+ const rect = new Rectangle(50, 50, red).center().drag();
56073
+ rect.on("pressmove", ()=>{
56074
+ if (rect.hitTestRectPoint(W/2, H/2)) {
56075
+ zog("hitting!");
56076
+ }
56077
+ });
56078
+ END EXAMPLE
56079
+
56080
+ PARAMETERS
56081
+ x - the global x for the point to test
56082
+ y - the global y for the point to test
56083
+ margin (default 0) pixels the bounds of the rectangle is increased or decreased to effect the hit
56084
+
56085
+ RETURNS a Boolean true if hitting, false if not
56086
+ --*///+37.3
56087
+ zim.hitTestRectPoint = function(obj, x, y, margin) {
56088
+ if (!zim.zimhtrp) {z_d("37.3"); zim.zimhtrp=true;}
56089
+ if (!obj.stage || zot(x) || zot(y)) return false;
56090
+ var stage = obj.stage;
56091
+ var bounds = obj.getBounds();
56092
+ if (zot(obj) || !bounds) {
56093
+ if (zon) zogy("hitTestRectPoint():\n please provide object with bounds");
56094
+ return false;
56095
+ }
56096
+ if (zot(margin)) margin = 0;
56097
+
56098
+ var rect = obj.boundsToGlobal();
56099
+ return x >= rect.x - margin && x <= rect.x + rect.width + margin && y >= rect.y - margin && y <= rect.y + rect.height + margin;
56100
+
56101
+ };//-37.3
56102
+
55385
56103
  /*--
55386
56104
  obj.hitTestCircle = function(other, num, boundsCheck, inside)
55387
56105
 
@@ -55483,7 +56201,7 @@ const ball = new Circle(50, red).center().drag();
55483
56201
  const box = new Rectangle(100, 100, blue).loc(100,100);
55484
56202
  ball.on("pressmove", ()=>{
55485
56203
  if (ball.hitTestCircleRect(box)) {
55486
- zog("points!");
56204
+ zog("hitting!");
55487
56205
  }
55488
56206
  });
55489
56207
  END EXAMPLE
@@ -55528,6 +56246,58 @@ RETURNS a Boolean true if hitting, false if not
55528
56246
 
55529
56247
  };//-38.2
55530
56248
 
56249
+ /*--
56250
+ obj.hitTestCirclePoint = function(x, y, margin)
56251
+
56252
+ hitTestCirclePoint
56253
+ zim DisplayObject method
56254
+
56255
+ DESCRIPTION
56256
+ Uses an equation to see if a circlular object is hitting a point x, y.
56257
+ This is faster than hitTests on shapes - so will have the speed of hitTestBounds, hitTestCircles and hitTestGrid.
56258
+ The circle is based on a the object radius if there is one
56259
+ and if no radius then the average of the width and height divided by two.
56260
+ A margin parameter is provided to tweak the hitTest
56261
+
56262
+ EXAMPLE
56263
+ const ball = new Circle(50, red).center().drag();
56264
+ ball.on("pressmove", ()=>{
56265
+ if (ball.hitTestCirclePoint(W/2, H/2)) {
56266
+ zog("hitting!");
56267
+ }
56268
+ });
56269
+ END EXAMPLE
56270
+
56271
+ PARAMETERS
56272
+ x - the global x for the point to test
56273
+ y - the global y for the point to test
56274
+ margin (default 0) pixels the bounds of the circle is increased or decreased to effect the hit
56275
+
56276
+ RETURNS a Boolean true if hitting, false if not
56277
+ --*///+38.3
56278
+ zim.hitTestCirclePoint = function(obj, x, y, margin) {
56279
+ if (!zim.zimhtcp) {z_d("38.3"); zim.zimhtcp=true;}
56280
+ if (!obj.stage || zot(x) || zot(y)) return false;
56281
+ var stage = obj.stage;
56282
+ var bounds = obj.getBounds();
56283
+ if (zot(obj) || !bounds) {
56284
+ if (zon) zogy("hitTestCirclePoint():\n please provide object with bounds");
56285
+ return false;
56286
+ }
56287
+ if (zot(margin)) margin = 0;
56288
+
56289
+ var radius = (obj.radius?obj.radius:(bounds.width+bounds.height)/2)+margin;
56290
+ var sX = obj.getConcatenatedMatrix().decompose().scaleX;
56291
+ radius *= sX/stage.scaleX;
56292
+
56293
+ var point = obj.localToGlobal(0,0);
56294
+ var dx = point.x-x;
56295
+ var dy = point.y-y;
56296
+ return Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2)) <= radius;
56297
+
56298
+ };//-38.3
56299
+
56300
+
55531
56301
  /*--
55532
56302
  obj.hitTestCircles = function(other, margin)
55533
56303
 
@@ -60751,6 +61521,7 @@ zim.STYLE and Style()
60751
61521
 
60752
61522
  STYLE
60753
61523
  zim constant and static Class
61524
+ Also GLOBALSTYLE zim constant
60754
61525
 
60755
61526
  DESCRIPTION
60756
61527
  STYLE can be used to set any parameter on a DisplayObject and many of the Controls.
@@ -60770,7 +61541,14 @@ They are cascading with each level overriding the previous level:
60770
61541
  See: https://zimjs.com/style.html for an example
60771
61542
  And: https://zimjs.com/test/styles.html for Control Styles
60772
61543
 
60773
- NOTE: As of ZIM Cat, a Style class has been added with the static methods to manage styles
61544
+ NOTE: As of ZIM 018, GLOBALSTYLE has been added.
61545
+ GLOBALSTYLE can be used like STYLE and any styles in GLOBALSTYLE will be added to STYLE.
61546
+ GLOBALSTYLE is only active after it is set and it can be cleared with GLOBALSTYLE = {} or null.
61547
+ GLOBALSTYLE properties that are the same as STYLE properties will be overwritten by STYLE properties
61548
+ including all of type and group styles, ie. if both have Button styles only the STYLE Button styles will be applied.
61549
+ GLOBALSTYLE makes it easier to keep common styles across multiple specific STYLE changes.
61550
+
61551
+ NOTE: As of ZIM Cat, a Style class has been added with the static methods to manage styles.
60774
61552
  STYLE is an object so all of these are just a couple lines to make it easier to update the object.
60775
61553
  These include methods such as clear(), add(), remember(), addType(), addGroup(), etc.
60776
61554
  See the Style entry down below for a complete listing and description.
@@ -60888,6 +61666,25 @@ STYLE = {color:red, wonder:{percent:50}};
60888
61666
  new Circle({style:false, group:"wonder"}).center();
60889
61667
  END EXAMPLE
60890
61668
 
61669
+ EXAMPLE
61670
+ GLOBALSTYLE = {font:"courier"};
61671
+ STYLE = {size:50}
61672
+ new Label("hello").center(); // courier and size 50
61673
+ STYLE = {size:20}
61674
+ new Label("goodbye").center().mov(0,50); // courier and size 20
61675
+ STYLE = {font:"lidia", size:30}
61676
+ new Label("ciao").center().mov(0,150); // lucidia and size 30
61677
+ STYLE = {size:20}
61678
+ new Label("bella").center().mov(0,180); // courier and size 20
61679
+ GLOBALSTYLE = null;
61680
+ new Label("greets").center().mov(0,-100); // default font size 20
61681
+ GLOBALSTYLE = {Button:{corner:0}}; // can reset a GLOBALSTYLE
61682
+ STYLE = {font:"courier"};
61683
+ new Button().pos(100,100,RIGHT,BOTTOM); // courier with 0 corner
61684
+ STYLE = {Button:{font:"courier"}}; // this will override all Button styles in GLOBALSTYLE
61685
+ new Button().pos(100,100,RIGHT,BOTTOM); // courier with default corner
61686
+ END EXAMPLE
61687
+
60891
61688
  EXAMPLE
60892
61689
  // Note: these commands are on the Style class not STYLE - but they operate on STYLE
60893
61690
  // Also remember that ZIM STYLE only gets applied to new objects
@@ -60957,7 +61754,7 @@ If it does not work, just turn the STYLE = {} or Style.clear() manually.
60957
61754
  FUNCTION STYLES
60958
61755
  The following functions have been added:
60959
61756
  addTo, loc, pos, center, centerReg, reg, transform, drag, gesture,
60960
- tap, change, hold, outline, bounds, mov, animate, wiggle, expand and cache
61757
+ tap, change, hold, outline, bounds, mov, animate, wiggle, expand, cache, and mouse
60961
61758
  Values of true will give default functionality for all but tap, change, mov, animate and wiggle
60962
61759
  ZIM DUO configuration objects can be set as a value for any of these
60963
61760
  example: drag:true; or drag:{onTop:false}
@@ -60965,6 +61762,7 @@ For animate and wiggle, [] can be put around multiple configuration objects
60965
61762
  to wiggle in the x and y for instance or run multiple animate calls on the object
60966
61763
  The tap, change and hold events are only what function to call - no extra parameters are available
60967
61764
  They can be turned off with noTap, noChange and noHold styles.
61765
+ Note: ZIM will run faster if non-interactive objects have their noMouse set.
60968
61766
 
60969
61767
  CONVENIENCE STYLES
60970
61768
  add:true - has been provided to add to the stage (use addTo for other containers)
@@ -61054,14 +61852,17 @@ Style.removeGroup(groupName) - removes a group as a string
61054
61852
  same as: delete STYLE.group.groupName
61055
61853
  --*///+50.34
61056
61854
  zim.STYLE = null;
61855
+ zim.GLOBALSTYLE = null;
61057
61856
  zim.getStyle = function(type, group, inherit, groupOnly) {
61058
61857
  if (!zim.STYLECHECK) {z_d("50.34"); zim.STYLECHECK=true;}
61059
61858
 
61060
- var functionList = ["tap", "change", "hold", "noTap", "noChange", "noHold", "pos", "addTo", "center", "centerReg", "reg", "mov", "move", "drag", "transform", "gesture", "mouse", "expand", "outline", "bounds", "animate", "wiggle", "cache", "cursor","uppercase", "shadow"];
61859
+ var functionList = ["tap", "change", "hold", "noTap", "noChange", "noHold", "pos", "addTo", "center", "centerReg", "reg", "mov", "move", "drag", "transform", "gesture", "mouse", "expand", "outline", "bounds", "animate", "wiggle", "cache", "cursor","uppercase", "shadow", "mouse"];
61061
61860
 
61062
61861
  // called by DisplayObjects
61063
61862
  // ZIM NFT MODULE ADJUST
61064
61863
  var STYLE = WW.STYLE || zim.STYLE;
61864
+ var GLOBALSTYLE = WW.GLOBALSTYLE || zim.GLOBALSTYLE;
61865
+ if (GLOBALSTYLE) STYLE = zim.merge(GLOBALSTYLE, STYLE);
61065
61866
  var DS = STYLE;
61066
61867
  var val;
61067
61868
 
@@ -61309,6 +62110,11 @@ zim.styleTransforms = function(obj, styles) {
61309
62110
  if (styles.noChange && obj.noChange) obj.noChange();
61310
62111
  if (styles.noTap && obj.noTap) obj.noTap();
61311
62112
  if (styles.noHold && obj.noHold) obj.noHold();
62113
+ if (!zot(styles.mouse) && obj.mouse) {
62114
+ if (styles.mouse) obj.mouse();
62115
+ else obj.noMouse();
62116
+ }
62117
+ if (styles.noMouse && obj.noMouse) obj.noMouse();
61312
62118
 
61313
62119
  var STYLE = WW.STYLE || zim.STYLE;
61314
62120
  if (STYLE && (STYLE.once===true || STYLE.once==obj.type)) {
@@ -65397,8 +66203,8 @@ obj - |ZIM VEE| (default new Circle()) the display object to tile
65397
66203
  If the obj is a ZIM VEE function (not array, object literal or series) then the Tile clone parameter will default to false
65398
66204
  cols - (default 1 - if no cols and rows then 3) the columns to tile
65399
66205
  rows - (default 1 - if no cols and rows then 3) the rows to tile
65400
- spacingH - (default 0 - if no cols and rows then 3) a spacing between columns - ignored if colSize is set
65401
- spacingV - (default 0 - if no cols and rows then 3) a spacing between rows - ignored if rowSize is set
66206
+ spacingH - |ZIM VEE| (default 0 - if no cols and rows then 3) a spacing between columns - ignored if colSize is set
66207
+ spacingV - |ZIM VEE| (default 0 - if no cols and rows then 3) a spacing between rows - ignored if rowSize is set
65402
66208
  unique - (default false) - set to true if tiling unique items like components with events set or objects with custom properties
65403
66209
  1. this will turn off ZIM VEE for the obj parameter which will accept an array of unique objects
65404
66210
  2. the count parameter will be set to the length of the array
@@ -65486,6 +66292,10 @@ itemUnderPoint(x, y, ignoreSpacing) - gets the item under a global point - (with
65486
66292
  setProps(properties) - sets provided properties (as {prop:val, prop:val}) for each item
65487
66293
  the values accept ZIM VEE - dynamic parameters - see ZIM Pick()
65488
66294
  returns object for chaining
66295
+ setSpacing(h,v) - set arrays of horizontal and vertical spacing
66296
+ ZIM Tile() makes spacing arrays for horizontal and vertical spacing based on ZIM VEE calculations from the spacingH and spacingV parameters
66297
+ to change spacing afterwards, new arrays can be provided to setSpacing()
66298
+ the arrays must have col-1 and row-1 items - although h or v can be left null or undefined to keep existing spacing
65489
66299
  remake(items) - pass in an array of items to tile - see items property for editing current list - returns tile for chaining
65490
66300
  can also change rows and cols and remake()
65491
66301
  resize(width, height) - resize the tile with new width and/or height if the width and/or height parameters were set - returns tile for chaining
@@ -65528,14 +66338,13 @@ These properties can be changed by calling remake()
65528
66338
  cols - number of columns - can modify - need to call remake() to see changes
65529
66339
  rows - number of rows - can modify - need to call remake() to see changes
65530
66340
  These properties can be changed by calling resize(width, height) - set width or height to 0 for no spreading
65531
- spacingH - horizontal spacing - can modify - need to call resize() to see changes
65532
- spacingV - vertical spacing - can modify - need to call resize() to see changes
65533
66341
  squeezeH - horizontal compression - can modify - need to call resize() to see changes
65534
66342
  squeezeV - vertical compression - can modify - need to call resize() to see changes
65535
66343
  align - (not with ZIM VEE) horizontal alignment - can modify - need to call resize() to see changes
65536
66344
  valign - (not with ZIM VEE) vertical alignment - can modify - need to call resize() to see changes
65537
66345
  mirrorH - horizontal mirroring - can modify - need to call resize() to see changes
65538
66346
  mirrorV - vertical mirroring - can modify - need to call resize() to see changes
66347
+ NOTE: spacingV and spacingH can be adjusted with setSpacing() method
65539
66348
 
65540
66349
  ALSO: see ZIM Container for properties such as:
65541
66350
  width, height, widthOnly, heightOnly, draggable, level, depth, group
@@ -65578,10 +66387,43 @@ note: the item is not the event object target - as that is the tile
65578
66387
 
65579
66388
  if (zot(spacingH)) spacingH = DS.spacingH!=null?DS.spacingH:null;
65580
66389
  if (zot(spacingV)) spacingV = DS.spacingV!=null?DS.spacingV:null;
65581
- var spacingHO = spacingH;
65582
- var spacingVO = spacingV;
66390
+
66391
+ // Added ZIM 018
66392
+ var spacingHOList = [];
66393
+ var spacingVOList = [];
66394
+ var spacingHOTotal = 0;
66395
+ var spacingVOTotal = 0;
66396
+ for (i=0; i<cols-1; i++) {
66397
+ var s = zik(spacingH);
66398
+ spacingHOList.push(s);
66399
+ spacingHOTotal += s;
66400
+ }
66401
+ for (i=0; i<rows-1; i++) {
66402
+ var s = zik(spacingV);
66403
+ spacingVOList.push(s);
66404
+ spacingVOTotal += s;
66405
+ }
66406
+ var spacingHAve = cols-1>0?spacingHTotal/(cols-1):0
66407
+ var spacingVAve = rows-1>0?spacingVTotal/(rows-1):0
66408
+
65583
66409
  if (zot(spacingH) || !zot(colSize) || !zot(width)) spacingH = 0; // sizes override spacing
65584
- if (zot(spacingV) || !zot(rowSize) || !zot(height)) spacingV = 0;
66410
+ if (zot(spacingV) || !zot(rowSize) || !zot(height)) spacingV = 0;
66411
+
66412
+ // Added ZIM 018
66413
+ var spacingHList = [];
66414
+ var spacingVList = [];
66415
+ var spacingHTotal = 0;
66416
+ var spacingVTotal = 0;
66417
+ for (i=0; i<cols-1; i++) {
66418
+ var s = zik(spacingH);
66419
+ spacingHList.push(s);
66420
+ spacingHTotal += s;
66421
+ }
66422
+ for (i=0; i<rows-1; i++) {
66423
+ var s = zik(spacingV);
66424
+ spacingVList.push(s);
66425
+ spacingVTotal += s;
66426
+ }
65585
66427
  if (zot(squeezeH)) squeezeH = DS.squeezeH!=null?DS.squeezeH:false;
65586
66428
  if (zot(squeezeV)) squeezeV = DS.squeezeV!=null?DS.squeezeV:false;
65587
66429
  if (zot(align)) align = DS.align!=null?DS.align:"left";
@@ -65618,8 +66460,6 @@ note: the item is not the event object target - as that is the tile
65618
66460
  var that = this;
65619
66461
  that.cols = cols = Math.round(cols);
65620
66462
  that.rows = rows = Math.round(rows);
65621
- that.spacingH = spacingH;
65622
- that.spacingV = spacingV;
65623
66463
  that.squeezeH = squeezeH;
65624
66464
  that.squeezeV = squeezeV;
65625
66465
  var VEEAlign = (typeof align=="function");
@@ -65630,6 +66470,9 @@ note: the item is not the event object target - as that is the tile
65630
66470
  that.mirrorH = mirrorH;
65631
66471
  that.mirrorV = mirrorV;
65632
66472
 
66473
+ that.spacingH = spacingHList[0];
66474
+ that.spacingV = spacingVList[0];
66475
+
65633
66476
  // ~~~~~~~~~~~~~~~~~~~ GET ARRAY OF ITEMS ~~~~~~~~~~~~~~~
65634
66477
  // this list could be edited later and passed back into remake()
65635
66478
  // so need to separate this part from the rest
@@ -65644,7 +66487,7 @@ note: the item is not the event object target - as that is the tile
65644
66487
  currentCount++;
65645
66488
  if (!zot(count) && currentCount > count) break outer;
65646
66489
  tile = unique?obj[currentCount-1]:zim.Pick.choose(obj);
65647
- if (typeof tile == "string") tile = WW.asset(tile).centerReg({add:false}).clone();
66490
+ if (typeof tile == "string") tile = WW.asset(tile).reg(CENTER).clone();
65648
66491
  if (zot(tile)) {
65649
66492
  tile = new zim.Container(0,0,0,0);
65650
66493
  }
@@ -65749,6 +66592,8 @@ note: the item is not the event object target - as that is the tile
65749
66592
  if (!rowSize||!zot(height)) h = Math.abs(tB.height);
65750
66593
  // if (!colSize||!zot(width)) w = Math.abs(tile.width);
65751
66594
  // if (!rowSize||!zot(height)) h = Math.abs(tile.height);
66595
+ tile.fW = w;
66596
+ tile.fH = h;
65752
66597
 
65753
66598
  widthHeights[j][i] = [w,h];
65754
66599
  if (zot(widthMax[i])) widthMax[i] = 0;
@@ -65789,11 +66634,10 @@ note: the item is not the event object target - as that is the tile
65789
66634
  var rowTotals;
65790
66635
  var rowSpacings;
65791
66636
  var widthScaling = 1;
65792
- var heightScaling = 1;
65793
-
65794
-
66637
+ var heightScaling = 1;
66638
+
65795
66639
  function resize(width, height) {
65796
-
66640
+
65797
66641
  if (that.normalized) that.resetOriginalReg();
65798
66642
 
65799
66643
  if (!zot(backdropColor) && backdropPadding) {
@@ -65810,25 +66654,25 @@ note: the item is not the event object target - as that is the tile
65810
66654
  overallWidth = width;
65811
66655
  } else if (!zot(width)) {
65812
66656
  if (scaleToH) overallWidth = width;
65813
- else overallWidth = Math.max(widthTotalMax+(that.cols-1)*that.spacingH, width);
66657
+ else overallWidth = Math.max(widthTotalMax+spacingHTotal, width);
65814
66658
  } else {
65815
- if (widthUncompressedMax > 0) overallWidth = widthUncompressedMax+(that.cols-1)*that.spacingH;
65816
- else overallWidth = widthTotalMax+(that.cols-1)*that.spacingH;
66659
+ if (widthUncompressedMax > 0) overallWidth = widthUncompressedMax+spacingHTotal;
66660
+ else overallWidth = widthTotalMax+spacingHTotal;
65817
66661
  }
65818
66662
 
65819
66663
  if (!zot(height)&&that.squeezeV=="full") {
65820
66664
  overallHeight = height;
65821
66665
  } else if (!zot(height)) {
65822
66666
  if (scaleToV) overallHeight = height;
65823
- else overallHeight = Math.max(heightTotalMax+(that.rows-1)*that.spacingV, height);
66667
+ else overallHeight = Math.max(heightTotalMax+spacingVTotal, height);
65824
66668
  } else {
65825
- if (heightUncompressedMax > 0) overallHeight = heightUncompressedMax+(that.rows-1)*that.spacingV;
65826
- else overallHeight = heightTotalMax+(that.rows-1)*that.spacingV;
66669
+ if (heightUncompressedMax > 0) overallHeight = heightUncompressedMax+spacingVTotal;
66670
+ else overallHeight = heightTotalMax+spacingVTotal;
65827
66671
  }
65828
66672
 
65829
66673
  that.setBounds(0,0,overallWidth,overallHeight);
65830
- widthScaling = (overallWidth-(that.cols-1)*spacingHO)/(widthO);
65831
- heightScaling = (overallHeight-(that.rows-1)*spacingVO)/(heightO);
66674
+ widthScaling = (overallWidth-spacingHOTotal)/(widthO);
66675
+ heightScaling = (overallHeight-spacingVOTotal)/(heightO);
65832
66676
 
65833
66677
  // ~~~~~~~~~~~~~~~~~~~ PLACEMENTS ~~~~~~~~~~~~~~~
65834
66678
 
@@ -65838,6 +66682,7 @@ note: the item is not the event object target - as that is the tile
65838
66682
  rowTotals = []; // keep track of current y positions
65839
66683
  rowSpacings = [];
65840
66684
  var rowTops = [];
66685
+
65841
66686
  for (j=0; j<objects.length; j++) {
65842
66687
  rowObjects = objects[j];
65843
66688
  colTotal = 0;
@@ -65854,17 +66699,17 @@ note: the item is not the event object target - as that is the tile
65854
66699
  if (that.squeezeV=="full") {
65855
66700
  rowSpacings[i] = rowCounts[i]>1?((height - heightTotals[i]) / (rowCounts[i]-1)):0;
65856
66701
  } else if (that.squeezeV) {
65857
- rowSpacings[i] = rowCounts[i]>1?Math.max(that.spacingV, (height - heightTotals[i]) / (rowCounts[i]-1)):0;
66702
+ rowSpacings[i] = rowCounts[i]>1?Math.max(spacingVAve, (height - heightTotals[i]) / (rowCounts[i]-1)):0;
65858
66703
  } else {
65859
- rowSpacings[i] = rowCounts[i]>1?Math.max(that.spacingV, (overallHeight - heightTotals[i]) / (rowCounts[i]-1)):0;
66704
+ rowSpacings[i] = rowCounts[i]>1?Math.max(spacingVAve, (overallHeight - heightTotals[i]) / (rowCounts[i]-1)):0;
65860
66705
  }
65861
66706
  }
65862
66707
  if (that.squeezeV) {
65863
66708
  // check for center or bottom valign of whole row
65864
66709
  if (that.valign=="center" || that.valign=="middle") {
65865
- rowTops[i] = (overallHeight-(heightTotals[i]+(rowCounts[i]-1)*(!zot(height)?rowSpacings[i]:that.spacingV)))/2;
66710
+ rowTops[i] = (overallHeight-(heightTotals[i]+(rowCounts[i]-1)*(!zot(height)?rowSpacings[i]:spacingVAve)))/2;
65866
66711
  } else if (that.valign=="bottom") {
65867
- rowTops[i] = overallHeight-(heightTotals[i]+(rowCounts[i]-1)*(!zot(height)?rowSpacings[i]:that.spacingV));
66712
+ rowTops[i] = overallHeight-(heightTotals[i]+(rowCounts[i]-1)*(!zot(height)?rowSpacings[i]:spacingVAve));
65868
66713
  } else {
65869
66714
  rowTops[i] = 0;
65870
66715
  }
@@ -65881,17 +66726,17 @@ note: the item is not the event object target - as that is the tile
65881
66726
  if (that.squeezeH=="full") {
65882
66727
  spreadXspacing = rowObjects.length>1?((width - widthTotals[j]) / (rowObjects.length-1)):0;
65883
66728
  } else if (that.squeezeH) {
65884
- spreadXspacing = rowObjects.length>1?Math.max(that.spacingH, (width - widthTotals[j]) / (rowObjects.length-1)):0;
66729
+ spreadXspacing = rowObjects.length>1?Math.max(spacingHAve, (width - widthTotals[j]) / (rowObjects.length-1)):0;
65885
66730
  } else {
65886
- spreadXspacing = rowObjects.length>1?Math.max(that.spacingH, (overallWidth - widthTotals[j]) / (rowObjects.length-1)):0;
66731
+ spreadXspacing = rowObjects.length>1?Math.max(spacingHAve, (overallWidth - widthTotals[j]) / (rowObjects.length-1)):0;
65887
66732
  }
65888
66733
  }
65889
66734
  if (that.squeezeH) {
65890
66735
  // check for center or right align of whole row
65891
66736
  if (that.align=="center" || that.align=="middle") {
65892
- left = (overallWidth-(widthTotals[j]+(rowObjects.length-1)*(!zot(width)?spreadXspacing:that.spacingH)))/2;
66737
+ left = (overallWidth-(widthTotals[j]+(rowObjects.length-1)*(!zot(width)?spreadXspacing:spacingHAve)))/2;
65893
66738
  } else if (that.align=="right") {
65894
- left = overallWidth-(widthTotals[j]+(rowObjects.length-1)*(!zot(width)?spreadXspacing:that.spacingH));
66739
+ left = overallWidth-(widthTotals[j]+(rowObjects.length-1)*(!zot(width)?spreadXspacing:spacingHAve));
65895
66740
  } else {
65896
66741
  left = 0;
65897
66742
  }
@@ -65916,23 +66761,23 @@ note: the item is not the event object target - as that is the tile
65916
66761
  }
65917
66762
  tile.pos(colTotal, null);
65918
66763
 
65919
- if (!that.squeezeH && VEEAlign) {
66764
+ if (!that.squeezeH && VEEAlign) {
65920
66765
  if (zot(width) && (align=="center" || align=="middle")) {
65921
- tile.x += (widthMax[i]-tile.width)/2;
66766
+ tile.x += (widthMax[i]-tile.fW)/2;
65922
66767
  } else if (zot(width) && align=="right") {
65923
- tile.x += widthMax[i]-tile.width;
66768
+ tile.x += widthMax[i]-tile.fW;
65924
66769
  }
65925
- } else if (!that.squeezeH) { // this allows for dynamic setting of align (for non-VEE, non squeezeH)
66770
+ } else if (!that.squeezeH) { // this allows for dynamic setting of align (for non-VEE, non squeezeH)
65926
66771
  if (zot(width) && (that.align=="center" || that.align=="middle")) {
65927
- tile.x += (widthMax[i]-tile.width)/2;
66772
+ tile.x += (widthMax[i]-tile.fW)/2;
65928
66773
  } else if (zot(width) && that.align=="right") {
65929
- tile.x += widthMax[i]-tile.width;
66774
+ tile.x += widthMax[i]-tile.fW;
65930
66775
  }
65931
66776
  } else {
65932
66777
  if (zot(width) && (that.align=="center" || that.align=="middle")) {
65933
- tile.x += (w-tile.width)/2;
66778
+ tile.x += (w-tile.fW)/2;
65934
66779
  } else if (zot(width) && that.align=="right") {
65935
- tile.x += w-tile.width;
66780
+ tile.x += w-tile.fW;
65936
66781
  }
65937
66782
  }
65938
66783
  if (that.mirrorV && j%2==1) {
@@ -65944,37 +66789,37 @@ note: the item is not the event object target - as that is the tile
65944
66789
  tile.pos(null,rowTotals[i]);
65945
66790
  if (!that.squeezeV && VEEVAlign) {
65946
66791
  if (zot(height) && (finalVAlign=="center" || finalVAlign=="middle")) {
65947
- tile.y += (heightMax[j]-tile.height)/2;
66792
+ tile.y += (heightMax[j]-tile.fH)/2;
65948
66793
  } else if (zot(height) && finalVAlign=="bottom") {
65949
- tile.y += heightMax[j]-tile.height;
66794
+ tile.y += heightMax[j]-tile.fH;
65950
66795
  }
65951
66796
  } else if (!that.squeezeV) { // this allows for dynamic setting of valign (for non-VEE, non squeezeV)
65952
66797
  if (zot(height) && (that.valign=="center" || that.valign=="middle")) {
65953
- tile.y += (heightMax[j]-tile.height)/2;
66798
+ tile.y += (heightMax[j]-tile.fH)/2;
65954
66799
  } else if (zot(height) && that.valign=="bottom") {
65955
- tile.y += heightMax[j]-tile.height;
66800
+ tile.y += heightMax[j]-tile.fH;
65956
66801
  }
65957
66802
  } else {
65958
66803
  if (zot(height) && (that.valign=="center" || that.valign=="middle")) {
65959
- tile.y += (h-tile.height)/2;
66804
+ tile.y += (h-tile.fH)/2;
65960
66805
  } else if (zot(height) && that.valign=="bottom") {
65961
- tile.y += h-tile.height;
66806
+ tile.y += h-tile.fH;
65962
66807
  }
65963
66808
  }
65964
66809
 
65965
66810
  if (that.squeezeH === true || !zot(width)) {
65966
- colTotal += w+(!zot(width)?spreadXspacing:that.spacingH);
66811
+ colTotal += w+(!zot(width)?spreadXspacing:spacingHList[i]);
65967
66812
  } else {
65968
- colTotal += widthMax[i]+(!zot(width)?spreadXspacing:that.spacingH);
66813
+ colTotal += widthMax[i]+(!zot(width)?spreadXspacing:spacingHList[i]);
65969
66814
  }
65970
66815
 
65971
66816
  tile.x += left;
65972
66817
  tile.y += rowTops[i];
65973
66818
 
65974
66819
  if (that.squeezeV === true || !zot(height)) {
65975
- rowTotals[i] += h+(!zot(height)?rowSpacings[i]:that.spacingV);
66820
+ rowTotals[i] += h+(!zot(height)?rowSpacings[i]:spacingVList[j]);
65976
66821
  } else {
65977
- rowTotals[i] += heightMax[j]+(!zot(height)?rowSpacings[i]:that.spacingV);
66822
+ rowTotals[i] += heightMax[j]+(!zot(height)?rowSpacings[i]:spacingVList[j]);
65978
66823
  }
65979
66824
  }
65980
66825
  }
@@ -65988,7 +66833,7 @@ note: the item is not the event object target - as that is the tile
65988
66833
  this.setProps = function(props) {
65989
66834
  zim.setProps(this.items, props);
65990
66835
  return this;
65991
- }
66836
+ }
65992
66837
 
65993
66838
  this.itemUnderPoint = function(x, y, ignoreSpacing) {
65994
66839
  if (zot(ignoreSpacing)) ignoreSpacing = true;
@@ -65999,12 +66844,12 @@ note: the item is not the event object target - as that is the tile
65999
66844
 
66000
66845
  var wT = 0;
66001
66846
  var co = zim.loop(widthMax, function (w, i) {
66002
- wT+=w+that.spacingH;
66847
+ wT+=w+spacingHList[i];
66003
66848
  if (!ignoreSpacing || ignoreSpacing == "vertical") {
66004
66849
  // test for in cracks
66005
- if (x > wT-that.spacingH && x < wT) return false;
66850
+ if (x > wT-spacingHList[i] && x < wT) return false;
66006
66851
  }
66007
- if (x < wT-that.spacingH/2) return i;
66852
+ if (x < wT-spacingHList[i]/2) return i;
66008
66853
  });
66009
66854
  if (co === false) return; // in crack
66010
66855
  if (co === true) co = cols-1;
@@ -66034,6 +66879,13 @@ note: the item is not the event object target - as that is the tile
66034
66879
  return that;
66035
66880
  };
66036
66881
 
66882
+ that.setSpacing = function(h,v) {
66883
+ if (!zot(h) && Array.isArray(h)) spacingHList = h;
66884
+ if (!zot(v) && Array.isArray(v)) spacingVList = v;
66885
+ that.remake();
66886
+ return that;
66887
+ }
66888
+
66037
66889
  this.resize = function(w, h) {
66038
66890
  if (zot(w)) w = width;
66039
66891
  if (zot(h)) h = height;
@@ -66099,7 +66951,7 @@ note: the item is not the event object target - as that is the tile
66099
66951
  var b = t.getBounds();
66100
66952
  var x = t.x - t.regX + b.x + b.width / 2;
66101
66953
  var y = t.y - t.regY + b.y + b.height / 2;
66102
- var index = that.hitTestGrid(that.width, that.height, that.cols, that.rows, x, y, null, null, that.spacingH, that.spacingV, true, "open");
66954
+ var index = that.hitTestGrid(that.width, that.height, that.cols, that.rows, x, y, null, null, spacingHList[0], spacingVList[0], true, "open");
66103
66955
  if (index != null) items[index[0]] = t;
66104
66956
  });
66105
66957
  // // slow with hundreds
@@ -66171,8 +67023,8 @@ note: the item is not the event object target - as that is the tile
66171
67023
  if (!resize && !zot(backgroundColor)) backgroundColors = [];
66172
67024
  if (!resize && backing) backings = [];
66173
67025
 
66174
- var lastX = (colSize?spacingHO:0)/2;
66175
- var lastY = (rowSize?spacingVO:0)/2;
67026
+ var lastX = (colSize?spacingHOList[0]:0)/2;
67027
+ var lastY = (rowSize?spacingVOList[0]:0)/2;
66176
67028
  var rect;
66177
67029
  var cou = 0;
66178
67030
  zim.loop(that.items2D, function(c, j) {
@@ -66182,14 +67034,14 @@ note: the item is not the event object target - as that is the tile
66182
67034
  if (resize && !zot(backgroundColor)) {
66183
67035
  color = backgroundColors[cou];
66184
67036
  rect = backgrounds[cou]
66185
- .siz(widthMax[i]*widthScaling-(colSize?spacingHO:0)+backgroundPaddingH*2, heightMax[j]*heightScaling-(rowSize?spacingVO:0)+backgroundPaddingV*2)
67037
+ .siz(widthMax[i]*widthScaling-(colSize?spacingHOList[i]:0)+backgroundPaddingH*2, heightMax[j]*heightScaling-(rowSize?spacingVOList[j]:0)+backgroundPaddingV*2)
66186
67038
  .loc(lastX, lastY, that, 0);
66187
67039
  } else {
66188
67040
  color = zik(backgroundColor);
66189
67041
  backgroundColors.push(backgroundColor);
66190
67042
  rect = new zim.Rectangle({
66191
- width:widthMax[i]*widthScaling-(colSize?spacingHO:0)+backgroundPaddingH*2,
66192
- height:heightMax[j]*heightScaling-(rowSize?spacingVO:0)+backgroundPaddingV*2,
67043
+ width:widthMax[i]*widthScaling-(colSize?spacingHOList[i]:0)+backgroundPaddingH*2,
67044
+ height:heightMax[j]*heightScaling-(rowSize?spacingVOList[j]:0)+backgroundPaddingV*2,
66193
67045
  color:color,
66194
67046
  style:false,
66195
67047
  scaleDimensions:false,
@@ -66202,7 +67054,7 @@ note: the item is not the event object target - as that is the tile
66202
67054
  item.pos(0,0,align,valign,rect).addTo(that);
66203
67055
  }
66204
67056
 
66205
- lastX = rect.x + rect.width + spacingHO;
67057
+ lastX = rect.x + rect.width + spacingHOList[i];
66206
67058
  if (scaleToH || scaleToV) {
66207
67059
  var sX;
66208
67060
  var sY;
@@ -66226,8 +67078,8 @@ note: the item is not the event object target - as that is the tile
66226
67078
  }
66227
67079
  cou++;
66228
67080
  });
66229
- lastX = (colSize?spacingHO:0)/2;
66230
- lastY += rect.height + spacingVO;
67081
+ lastX = (colSize?spacingHOList[i]:0)/2;
67082
+ lastY += rect.height + spacingVOList[j];
66231
67083
  });
66232
67084
  if (backing && !zot(backgroundColor)) {
66233
67085
  zim.loop(backings, function(bbb) {
@@ -66246,14 +67098,18 @@ note: the item is not the event object target - as that is the tile
66246
67098
  }
66247
67099
 
66248
67100
  if (!zot(backgroundColor) && (colSize || rowSize)) {
66249
- that.loop(function(item) {
66250
- item.mov(colSize?-spacingHO/2:0, rowSize?-spacingVO/2:0);
67101
+ that.loop(function(item, i) {
67102
+ item.mov(colSize?-spacingHOList[i]/2:0, rowSize?-spacingVOList[Math.floor(i/that.cols)]/2:0);
66251
67103
  });
66252
67104
  var bb = that.getBounds();
66253
- that.setBounds(bb.x, bb.y, bb.width-(colSize?spacingHO:0)*cols, bb.height-(rowSize?spacingVO:0)*rows)
67105
+ that.setBounds(bb.x, bb.y, bb.width-(colSize?spacingHOTotal:0), bb.height-(rowSize?spacingVOTotal:0))
66254
67106
  bb = that.getBounds();
66255
67107
  }
66256
67108
  if (backing) that.backings = backings;
67109
+
67110
+ that.setBounds(null)
67111
+ var bounds = that.getBounds();
67112
+ that.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
66257
67113
 
66258
67114
  }
66259
67115
 
@@ -66300,7 +67156,7 @@ note: the item is not the event object target - as that is the tile
66300
67156
  if (backing) exactBackings.push(backings[i].clone(true));
66301
67157
  }
66302
67158
  }
66303
- return that.cloneProps(new zim.Tile(exact&&exactItems?zim.series(exactItems):(obj.clone?obj.clone():obj), that.cols, that.rows, that.spacingH, that.spacingV, exact?false:unique, width, height, that.squeezeH, that.squeezeV, colSize, rowSize, align, valign, that.items.length, that.mirrorH, that.mirrorV, snapToPixel, exact?false:clone, events, exact, scaleToH, scaleToV, scaleToType, exact&&exactBackgroundColors?zim.series(exactBackgroundColors):backgroundColor, backgroundPadding, backgroundPaddingH, backgroundPaddingV, exact&&exactBackings?zim.series(exactBackings):(backing&&backing.clone)?backing.clone():backing, backdropColor, backdropPadding, backdropPaddingH, backdropPaddingV, (mat&&mat.clone)?mat.clone():mat, this.style, this.group));
67159
+ return that.cloneProps(new zim.Tile(exact&&exactItems?zim.series(exactItems):(obj.clone?obj.clone():obj), that.cols, that.rows, exact?series(spacingHList):that.spacingH, exact?series(spacingVList):that.spacingV, exact?false:unique, width, height, that.squeezeH, that.squeezeV, colSize, rowSize, align, valign, that.items.length, that.mirrorH, that.mirrorV, snapToPixel, exact?false:clone, events, exact, scaleToH, scaleToV, scaleToType, exact&&exactBackgroundColors?zim.series(exactBackgroundColors):backgroundColor, backgroundPadding, backgroundPaddingH, backgroundPaddingV, exact&&exactBackings?zim.series(exactBackings):(backing&&backing.clone)?backing.clone():backing, backdropColor, backdropPadding, backdropPaddingH, backdropPaddingV, (mat&&mat.clone)?mat.clone():mat, this.style, this.group));
66304
67160
  };
66305
67161
  };
66306
67162
  zim.extend(zim.Tile, zim.Container, "clone", "zimContainer", false);
@@ -69336,12 +70192,9 @@ zim.TextureActive = function(width, height, color, color2, angle, borderColor, b
69336
70192
  if (zot(pattern)) pattern=DS.pattern!=null?DS.pattern:null;
69337
70193
  if (zot(scalePattern)) scalePattern=DS.scalePattern!=null?DS.scalePattern:null;
69338
70194
 
69339
- this.zimPage_constructor(width, height, color, color2, angle, pattern, scalePattern, null, style, group, inherit);
70195
+ this.zimPage_constructor(width, height, color, color2, angle, corner, borderColor, borderWidth, pattern, scalePattern, null, style, group, inherit);
69340
70196
  this.type = "TextureActive";
69341
70197
 
69342
- if (corner) this.backing.corner = corner;
69343
- if (!zot(borderWidth)) this.backing.borderWidth = borderWidth;
69344
- if (!zot(borderColor)) this.backing.borderColor = borderColor;
69345
70198
  if (borderWidth || !zot(borderColor)) {
69346
70199
  this.backing.siz(this.width-borderWidth, this.height-borderWidth);
69347
70200
  this.backing.center();
@@ -70260,6 +71113,7 @@ zim.TextureActivesManager = function(stage, toggleKey, damp) {
70260
71113
  if (doms.indexOf(obj) < 0) doms.push(obj.renderer.domElement);
70261
71114
  if (!createjs.remotePointers) createjs.addRemotePointers(stage, doms);
70262
71115
  else createjs.remotePointers = doms;
71116
+ // else createjs.remoteTargets = doms; // in looking at this after... I think this is what we meant
70263
71117
  return true;
70264
71118
  }
70265
71119
 
@@ -71493,9 +72347,9 @@ dispatches an "undo" event if a CTRL or META plus the U key is pressed
71493
72347
  }
71494
72348
  };
71495
72349
  var eDown = new createjs.Event("keydown");
71496
- this.eventRemove = eDown.remove;
72350
+ this.downEventRemove = eDown.remove;
71497
72351
  this.keydownEvent = function(e) {
71498
- e.remove = that.eventRemove;
72352
+ e.remove = that.downEventRemove;
71499
72353
  if (that.multipleKey) that.multiple = e[that.multipleKey+"Key"];
71500
72354
  that.ctrlKey = e.ctrlKey;
71501
72355
  that.shiftKey = e.shiftKey;
@@ -71507,12 +72361,14 @@ dispatches an "undo" event if a CTRL or META plus the U key is pressed
71507
72361
  };
71508
72362
  WW.addEventListener("keydown", this.keydownEvent);
71509
72363
 
72364
+ var eUp = new createjs.Event("keyup");
72365
+ this.upEventRemove = eUp.remove;
71510
72366
  this.keyupEvent = function(e) {
72367
+ e.remove = that.upEventRemove;
71511
72368
  if (that.multipleKey) that.multiple = e[that.multipleKey+"Key"];
71512
72369
  that.ctrlKey = e.ctrlKey;
71513
72370
  that.shiftKey = e.shiftKey;
71514
72371
  that.metaKey = e.metaKey;
71515
- e.remove = that.eventRemove;
71516
72372
  that.dispatchEvent(e);
71517
72373
  }
71518
72374
  WW.addEventListener("keyup", this.keyupEvent);
@@ -73030,7 +73886,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
73030
73886
  //-69.5
73031
73887
 
73032
73888
  /*--
73033
- 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)
73889
+ 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)
73034
73890
 
73035
73891
  MotionController
73036
73892
  zim class - extends a createjs EventDispatcher
@@ -73042,6 +73898,7 @@ For instance, you can control a player in a game or a butterfly in field
73042
73898
  SEE: https://zimjs.com/controller for more examples
73043
73899
  SEE: https://zimjs.com/explore/sidescroller.html for keyboard work with Scroller, Sprite, Dynamo, Accelerator
73044
73900
  SEE: https://zimjs.com/pen or https://zimjs.com/genpen (complex example)
73901
+ SEE: https://zimjs.com/018/tileObj.html for moving on tile squares
73045
73902
 
73046
73903
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
73047
73904
 
@@ -73153,7 +74010,7 @@ firstPerson - (default false) set to true for keydown, gamebutton and gamecontro
73153
74010
  speed will be damped by damp parameter - also, map parameter changes if in firstPerson mode - see map parameter
73154
74011
  turnSpeed - (default speed*.4) - the speed for turning in firstPerson mode - will be damped but damp parameter
73155
74012
  moveThreshold - (default 5) pixels negative or positive to treat damped motion as stopped
73156
- stickThreshold - (default .2) gamepad stick axes values are from -1 to 1 but there is a lot of noise
74013
+ stickThreshold - (default .2, default .8 with tileObj) gamepad stick axes values are from -1 to 1 but there is a lot of noise
73157
74014
  so consider within +- stickThreshold as no motion 0
73158
74015
  container - (default zimDefaultFrame stage) the Container the target is in - the stage is most likely fine
73159
74016
  if container is specified, it must be on the stage when the MotionController is made
@@ -73173,6 +74030,31 @@ minPercentSpeed - (default 100) if target is an Accelerator, the percentSpeed at
73173
74030
  dampKeyup - (default .3) damping applied to slow down Accelerator with keydown
73174
74031
  rotate - (depreciated) the same as orient - kept for backwards compatibility as of ZIM Cat 01
73175
74032
  mouseOutside - (default false) if a container or boundary is provided, set to true to start motion if pressing outside container or boundary
74033
+ tileObj - (default null) an object to direct the target to move on a theoretical board with tiles
74034
+ works with type keydown, dPad, gamebutton and gamestick - for press tile movement see ZIM GameBoard and EasyStar path finding
74035
+ note: the target must be initially placed properly on a tile to start
74036
+ and if this is not the 0,0 tile then set the startCol and startRow properties
74037
+ moves are then calculated based on original target position, the w, h, spacingH and spacingV
74038
+ tileObj properties are as follows:
74039
+ time (default .2, or .3 for type gamestick, or .4 for dPad) - the time between moves or to animate to next move
74040
+ animate (default true) - set to false to not animate the target to the new tile
74041
+ cols (default 5) - the number of columns of the tile (not used if there is a moves property)
74042
+ rows (default 5) - the number of rows of the tile (not used if there is a moves property)
74043
+ w (default 50) - the width of a tile (not the whole board but just a tile and not including spacing)
74044
+ h (default 50) - the height of a tile (not the whole board but just a tile and not including spacing)
74045
+ spacingH (default 3) - the spacing horizontal between each tile
74046
+ spacingV (default 3) - the spacing vertical between each tile
74047
+ startCol (default 0) - the column index on which the target starts (must still place target at the right location)
74048
+ startRow (default 0) - the row index on which the target starts (must still place target at the right location)
74049
+ moves (default null) - set to an array of rows each with array of columns
74050
+ for allowed moves use 1 and for not-allowed moves use 0
74051
+ to move anywhere on 5x3 grid except the corners and the middle
74052
+ moves:[
74053
+ [0,1,1,1,0],
74054
+ [1,1,0,1,1],
74055
+ [0,1,1,1,0]
74056
+ ]
74057
+ note: this will override the cols and rows values
73176
74058
 
73177
74059
  METHODS
73178
74060
  pause(state, time) - state defaults to true and pauses the motionController (sets speed to 0)
@@ -73209,6 +74091,8 @@ moveThreshold - the maximum value (+-) within which movement is considered stopp
73209
74091
  stickThreshold - the maximum value (+-) within which the gamepad stick axes values are considered 0
73210
74092
  mousedownIncludes - an array of objects that the mousedown will work on - along with the stage
73211
74093
  note: if manually setting this and there is a boundary then add the boundary to the mousedownIncludes as well
74094
+ moveGrid - get or set the moves of a provided tileObj - see the tileObj parameter
74095
+ note: this will not reposition the target if changed
73212
74096
  enabled - set to false to disable or true to enable MotionController - can toggle with enabled = !enabled
73213
74097
 
73214
74098
  ALSO: adds a motionController property to target referencing the MotionController object
@@ -73220,8 +74104,8 @@ dispatches a "mousedown" event if type is "mousedown" or "pressmove"
73220
74104
  dispatches a "pressing" event if type is "pressmove" - note, this dispatches even if not moving
73221
74105
  dispatches a "moving" event if target is moving and "startmoving" and "stopmoving" events
73222
74106
  --*///+69.7
73223
- 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) {
73224
- 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";
74107
+ 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) {
74108
+ 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";
73225
74109
  var duo; if (duo = zob(zim.MotionController, arguments, sig, this)) return duo;
73226
74110
  z_d("69.7");
73227
74111
 
@@ -73261,9 +74145,34 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73261
74145
  type = "manual";
73262
74146
  if (zot(axis)) axis = dPad.axis;
73263
74147
  if (axis == "all") axis = "both";
74148
+
73264
74149
  dPad.on("change", function() {
73265
- that.convert(target.x+dPad.dirX*speed, target.y+dPad.dirY*speed);
74150
+ var d = {dirX:dPad.dirX, dirY:dPad.dirY};
74151
+ if (tileObj) {
74152
+ down = [0,0,0,0];
74153
+ var dC = false;
74154
+ if (Math.abs(d.dirX) > Math.abs(d.dirY)) {
74155
+ if (d.dirX<0) {down[0] = 1; dC=true;}
74156
+ else if (d.dirX>0) {down[1] = 1; dC=true;}
74157
+ } else {
74158
+ if (d.dirY<0) {down[2] = 1; dC=true;}
74159
+ else if (d.dirY>0) {down[3] = 1; dC=true;}
74160
+ }
74161
+ if (dC) {
74162
+ wasDown = true;
74163
+ if (!that.keyInterval) makeKeyInterval();
74164
+ } else {
74165
+ wasDown = false;
74166
+ }
74167
+ } else {
74168
+ that.convert(target.x+dPad.dirX*speed, target.y+dPad.dirY*speed);
74169
+ }
73266
74170
  });
74171
+ if (tileObj) {
74172
+ dPad.on("pressup", function() {
74173
+ down = [0,0,0,0];
74174
+ });
74175
+ }
73267
74176
  }
73268
74177
  if (zot(type) || (type != "mousemove" && type != "pressmove" && type != "pressdrag" && type != "keydown" && type != "gamebutton" && type != "gamestick" && type != "swipe" && type != "follow" && type != "manual")) type = "mousedown";
73269
74178
  if (zot(axis)) axis = accelerator?"horizontal":"both"; // horizontal, vertical, both
@@ -73291,7 +74200,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73291
74200
  if (zot(firstPerson)) firstPerson = false;
73292
74201
  if (zot(turnSpeed)) turnSpeed = speed * .4;
73293
74202
  if (zot(moveThreshold)) moveThreshold = 4;
73294
- if (zot(stickThreshold)) stickThreshold = .2;
74203
+ if (zot(stickThreshold)) stickThreshold = tileObj?.3:.2;
73295
74204
  if (zot(mouseMoveOutside)) mouseMoveOutside = true;
73296
74205
  stage.mouseMoveOutside = mouseMoveOutside;
73297
74206
  if (zot(mousedownIncludes)) mousedownIncludes = [];
@@ -73371,6 +74280,8 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73371
74280
  var pressing = false;
73372
74281
  var moveCheck = false;
73373
74282
  var under, i, a, gamepad, first;
74283
+ var down = [0,0,0,0];
74284
+ var wasDown = false;
73374
74285
 
73375
74286
  if (type == "keydown" || type == "gamebutton") {
73376
74287
 
@@ -73380,7 +74291,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73380
74291
  for (i=0; i<4; i++) {
73381
74292
  if (!Array.isArray(map[i])) map[i] = [map[i]];
73382
74293
  }
73383
- var down = [0,0,0,0];
74294
+
73384
74295
  var ord = []; // order the keys are pressed - so when we release, we can set to last currently pressed key
73385
74296
  var way = ["X","X","Y","Y"];
73386
74297
  var dir = [-1,1,-1,1];
@@ -73510,6 +74421,8 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73510
74421
  if (mouseEvent4) zim.Ticker.remove(mouseEvent4);
73511
74422
  if (type=="follow") mouseEvent4 = zim.Ticker.add(moveMe);
73512
74423
  if (target.type == "Pen") {
74424
+ target.zpenY = Math.round(target.y);
74425
+ target.zpenX = Math.round(target.x);
73513
74426
  target.write = true;
73514
74427
  target.paper.noMouse(); // no need to drag others while drawing
73515
74428
  target.zimDragCheck = true;
@@ -73517,6 +74430,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73517
74430
  });
73518
74431
  mouseEvent3 = stage.on("stagemouseup", function(){
73519
74432
  if (target.type == "Pen") {
74433
+ if (target.zpenX==Math.round(target.x) && target.zpenY==Math.round(target.y)) target.x+=2
73520
74434
  target.write = false;
73521
74435
  target.paper.mouse();
73522
74436
  target.zimDragCheck = false;
@@ -73552,6 +74466,24 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73552
74466
  }
73553
74467
  }
73554
74468
 
74469
+ if (tileObj) {
74470
+ down = [0,0,0,0];
74471
+ var dC = false;
74472
+ if (Math.abs(d.dirX) > Math.abs(d.dirY)) {
74473
+ if (d.dirX<0) {down[0] = 1; dC=true;}
74474
+ else if (d.dirX>0) {down[1] = 1; dC=true;}
74475
+ } else {
74476
+ if (d.dirY<0) {down[2] = 1; dC=true;}
74477
+ else if (d.dirY>0) {down[3] = 1; dC=true;}
74478
+ }
74479
+ if (dC) {
74480
+ wasDown = true;
74481
+ if (!that.keyInterval) makeKeyInterval();
74482
+ } else {
74483
+ wasDown = false;
74484
+ }
74485
+ }
74486
+
73555
74487
  if (firstPerson) {doFirstPerson(d); return;}
73556
74488
 
73557
74489
  that.x += that.speed*d.dirX;
@@ -73566,7 +74498,10 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73566
74498
  });
73567
74499
  }
73568
74500
 
74501
+
73569
74502
  function doDown(e) {
74503
+ wasDown = true;
74504
+ if (tileObj && !that.keyInterval) makeKeyInterval();
73570
74505
  var key = type=="keydown"?e.keyCode:e.buttonCode;
73571
74506
  var inOrd;
73572
74507
  for (i=0; i<4; i++) {
@@ -73585,6 +74520,10 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73585
74520
 
73586
74521
  function doUp(e) {
73587
74522
  var key = type=="keydown"?e.keyCode:e.buttonCode;
74523
+ if (tileObj) {
74524
+ that.x = currentX;
74525
+ that.y = currentY;
74526
+ }
73588
74527
  var inOrd;
73589
74528
  for (i=0; i<4; i++) {
73590
74529
  if (map[i].indexOf(key) > -1) {
@@ -73693,7 +74632,108 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73693
74632
  var lastDirX=0;
73694
74633
  var lastDirY=0;
73695
74634
 
73696
- var mainTicker = zim.Ticker.add(function() {
74635
+
74636
+ if (tileObj) {
74637
+
74638
+ var time = tileObj.time||(type=="gamestick"?.3:type=="manual"?.4:.2);
74639
+ var animate = tileObj.animate;
74640
+ var ease = tileObj.ease||"quadInOut";
74641
+ var cols = tileObj.cols||5;
74642
+ var rows = tileObj.rows||5;
74643
+ var w = tileObj.w||50;
74644
+ var h = tileObj.h||50;
74645
+ var sH = tileObj.spacingH||3;
74646
+ var sV = tileObj.spacingV||3;
74647
+ var startCol = tileObj.startCol||0;
74648
+ var startRow = tileObj.startRow||0;
74649
+ that.moveGrid = tileObj.moves;
74650
+ var startX = target.x - startCol*(w+sH);
74651
+ var startY = target.y - startRow*(h+sV);
74652
+
74653
+ var currentCol = startCol;
74654
+ var currentRow = startRow;
74655
+ var currentX = target.x;
74656
+ var currentY = target.y;
74657
+
74658
+ }
74659
+
74660
+ function makeKeyInterval() {
74661
+
74662
+ that.keyInterval = interval(time, function() {
74663
+ if (down && down[0]==0&&down[1]==0&&down[2]==0&down[3]==0) {
74664
+ that.keyInterval.clear();
74665
+ that.keyInterval = null;
74666
+ }
74667
+ if (!wasDown) return;
74668
+ wasDown = false;
74669
+
74670
+ var x=0;
74671
+ var y=0;
74672
+ if (type=="gamestick" || type=="manual") {
74673
+ if (down[0]) x=-1;
74674
+ else if (down[1]) x=1;
74675
+ else if (down[2]) y=-1;
74676
+ else if (down[3]) y=1;
74677
+ } else {
74678
+ var diffX = currentX-that.x;
74679
+ var diffY = currentY-that.y;
74680
+ if (Math.abs(diffX) >= Math.abs(diffY)) {
74681
+ y = 0;
74682
+ if (that.x > currentX) x = 1;
74683
+ else if (that.x < currentX) x = -1;
74684
+ } else {
74685
+ x = 0;
74686
+ if (that.y > currentY) y = 1;
74687
+ else if (that.y < currentY) y = -1;
74688
+ }
74689
+ if (down && x==0 && y==0) { // might be just starting so no time for that.x and that.y to change
74690
+ if (down[0]) x=-1;
74691
+ else if (down[1]) x=1;
74692
+ else if (down[2]) y=-1;
74693
+ else if (down[3]) y=1;
74694
+ }
74695
+ }
74696
+
74697
+ var lastX = currentCol;
74698
+ var lastY = currentRow;
74699
+ currentCol += x;
74700
+ currentRow += y;
74701
+ var moveCheck = true;
74702
+ if (that.moveGrid) {
74703
+ var row = that.moveGrid[currentRow];
74704
+ if (!row) moveCheck = false;
74705
+ else {
74706
+ var col = row[currentCol];
74707
+ if (!col) moveCheck = false;
74708
+ }
74709
+ } else {
74710
+ if (cols && currentCol < 0 || currentCol > cols-1) moveCheck = false;
74711
+ if (rows && currentRow < 0 || currentRow > rows-1) moveCheck = false;
74712
+ }
74713
+ if (moveCheck) {
74714
+ var newX = currentX = startX+(w+sH)*currentCol;
74715
+ var newY = currentY = startY+(h+sV)*currentRow;
74716
+ if (animate) target.animate({x:newX, y:newY}, time, ease);
74717
+ else target.loc(newX,newY);
74718
+ // dispatch move
74719
+ S.update();
74720
+ } else {
74721
+ currentCol = lastX;
74722
+ currentRow = lastY;
74723
+ // dispatch no move
74724
+ }
74725
+ setTimeout(function(){
74726
+ that.x = currentX;
74727
+ that.y = currentY;
74728
+ },time*.5);
74729
+
74730
+ }, null, true);
74731
+
74732
+ }
74733
+
74734
+
74735
+ var mainTicker = zim.Ticker.add(function() {
74736
+ if (tileObj) return;
73697
74737
  if (target.draggingCheck) return;
73698
74738
  if (type == "manual") calculate();
73699
74739
  if (that.boundary && that.boundary.type!="Blob") {
@@ -74445,6 +75485,23 @@ function ready() {
74445
75485
  }
74446
75486
  END EXAMPLE
74447
75487
 
75488
+ EXAMPLE
75489
+ new Physics();
75490
+ const circle = new Circle(20,red)
75491
+ .center()
75492
+ .wiggle("x", null, 100,200,1,2)
75493
+ .wiggle("y", null, 100,200,1,2); // note - no physics
75494
+ const ring = new Circle(100,clear,purple,2)
75495
+ .center()
75496
+ .addPhysics()
75497
+ .puppet(circle); // ring will follow circle
75498
+ new Rectangle(100,100,purple)
75499
+ .reg(CENTER)
75500
+ .center()
75501
+ .mov(50,50)
75502
+ .addPhysics(false); // static
75503
+ END EXAMPLE
75504
+
74448
75505
  PARAMETERS - FOR PHYSICS
74449
75506
  ** supports DUO - parameters or single object with properties below
74450
75507
  gravity - (default 10) the gravity force in the downward direction
@@ -74662,12 +75719,20 @@ contactEnd(call) - run the call function when object's body ends contacts with a
74662
75719
  Also see sensor parameter to trigger contact but with no physics interaction
74663
75720
  noContact() - remove contact call
74664
75721
  noContactEnd() - remove contactEnd call
75722
+ puppet(o) - make object go to the x and y of the object passed into to the o parameter.
75723
+ this will make the equivilant of a mouseJoin so physics is not broken
75724
+ so that physics objects can be joined to ZIM objects
75725
+ and controlled with animate(), wiggle(), zim drag(), gesture(), transform(), etc.
75726
+ note: it is the x and y property only, not rotation or scale.
75727
+ see https://zimjs.com/018/puppet.html
75728
+ puppetEnd() - stop the object from being a puppet
74665
75729
 
74666
75730
  PROPERTIES - FOR OBJECTS - see also BODY PROPERTIES below
74667
75731
  dynamic - set to true for dynamic and false for static
74668
75732
  there is also kinematic that can be set using the obj.body.SetType(1)
74669
75733
  speed - get or set the speed of an object that is controlled by control()
74670
75734
  speedY - get or set the speedY of an object that is controlled by control()
75735
+ puppetJoint - get the puppetJoint if puppet is set - will be null if puppet is not set
74671
75736
  ** normal x, y, rotation or pos(), loc(), rot() will not work with physics!
74672
75737
  ** see the BODY loc(x,y) METHOD and the rotation PROPERTY below
74673
75738
  ** these should really not be set at all in the physics world
@@ -74726,7 +75791,7 @@ b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
74726
75791
  b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController;
74727
75792
  b2ContactListener = Box2D.Dynamics.b2ContactListener;
74728
75793
  --*///+69.97
74729
- WW.zimContactListener = null; // global so dispose() in physics can access this
75794
+ WW.zimContactListener = null; // global so the dispose() in physics can access this
74730
75795
  var zimContactBeginList;
74731
75796
  var zimContactEndList;
74732
75797
  function setPhysics(obj, dynamic, contract, shape, friction, linear, angular, density, restitution, maskBits, categoryBits, sensor) {
@@ -74874,6 +75939,28 @@ b2ContactListener = Box2D.Dynamics.b2ContactListener;
74874
75939
  zimContactEndList.remove(obj.body);
74875
75940
  return obj;
74876
75941
  };
75942
+ obj.puppet = function(o) {
75943
+ var body = obj.body;
75944
+ var physics = obj.physics;
75945
+ var md = new WW.b2MouseJointDef();
75946
+ md.bodyA = physics.world.GetGroundBody();
75947
+ md.bodyB = body;
75948
+ md.target.Set(obj.x/physics.scale, obj.y/physics.scale);
75949
+ md.collideConnected = true;
75950
+ md.maxForce = 300.0 * body.GetMass();
75951
+ obj.puppetJoint = physics.world.CreateJoint(md);
75952
+ body.SetAwake(true);
75953
+ obj.zimPuppetTicker = zim.Ticker.add(function(){
75954
+ obj.puppetJoint.SetTarget(new WW.b2Vec2(o.x/physics.scale, o.y/physics.scale));
75955
+ });
75956
+ return obj;
75957
+ };
75958
+ obj.noPuppet = function() {
75959
+ physics.world.DestroyJoint(obj.puppetJoint);
75960
+ obj.puppetJoint = null;
75961
+ zim.Ticker.remove(obj.zimPuppetTicker);
75962
+ return obj;
75963
+ };
74877
75964
  if (!obj.hasOwnProperty("dynamic")) {
74878
75965
  Object.defineProperty(obj, 'dynamic', {
74879
75966
  get: function() {
@@ -85191,7 +86278,7 @@ zim.scaY = 1;
85191
86278
  // Zim Frame provides code to help you set up your coding environment
85192
86279
 
85193
86280
  /*--
85194
- zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, path, progress, ticker, rollover, touch, scrollTop, align, valign, canvasID, rollPerSecond, delay, canvasCheck, gpu, gpuObj, nextFrame, nextStage, allowDefault, loadFailObj, sensors, retina, mouseMoveOutside, captureMouse, shim, maxConnections, maxNum, singleTouch)
86281
+ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, path, progress, ticker, rollover, touch, scrollTop, align, valign, canvasID, rollPerSecond, delay, canvasCheck, gpu, gpuObj, nextFrame, nextStage, allowDefault, loadFailObj, retina, mouseMoveOutside, captureMouse, shim, maxConnections, maxNum, singleTouch)
85195
86282
 
85196
86283
  Frame
85197
86284
  zim class - extends a createjs EventDispatcher
@@ -85577,6 +86664,7 @@ loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, cr
85577
86664
  It is recommended to use the Queue any time you use multiple LoadAssets() calls at the same time
85578
86665
  You still access assets with asset() as outlined below whether you use the Queue or not
85579
86666
  asset(file, width, height, maxNum) - access an asset such as an image or sound - see loadAssets() for more on types
86667
+ note: asset() is a general alternative to new Pic(), new Aud(), new Dat() - also see new Vid() and new SVG()
85580
86668
  file is the string name or url to the file
85581
86669
  if the asset was loaded with a string then use the string (less the path if provided)
85582
86670
  if the asset was loaded with a full URL then use the full URL here
@@ -85802,7 +86890,7 @@ EVENTS
85802
86890
  and then perhaps constrain the value - here the scale is constrained between .5 and 5
85803
86891
  note - when changing scale, it is better to multiply by a factor rather than add to the scale
85804
86892
  eg. circle.scale = constrain(circle.scale*(sign(e.deltaY)>0?.75:1.25), .5, 5);
85805
- "deviceorientation" - MUST SET Frame sensors parameter to true
86893
+ "deviceorientation" - turned on when using ZIM PermissionAsk()
85806
86894
  fired as device orientation changes:
85807
86895
  eventObject.rotation.x (beta in HTML specs) holds rotation about the x axis between -180 and 180 (tipped forward or backward)
85808
86896
  eventObject.rotation.y (gamma in HTML specs) holds rotation about the y axis between -90 and 90 (tipped left or right)
@@ -85811,14 +86899,16 @@ EVENTS
85811
86899
  note also that beta, gamma and alpha from the HTML 5 specs are also provided
85812
86900
  eg.
85813
86901
  var label = new Label().center();
86902
+ // Note: MUST USE PermissionAsk()
85814
86903
  F.on("deviceorientation", function(e) {
85815
86904
  label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
85816
86905
  S.update();
85817
86906
  });
85818
- "devicemotion" - MUST SET Frame sensors parameter to true
86907
+ "devicemotion" - turned on when using ZIM PermissionAsk()
85819
86908
  fired on moving mobile device - like a tilt or shake - eventObject.acceleration holds x, y and z properties of motion
85820
86909
  eg.
85821
86910
  var label = new Label().center();
86911
+ // Note: MUST USE PermissionAsk()
85822
86912
  F.on("devicemotion", function(e) {
85823
86913
  label.text = e.acceleration.x +","+ e.acceleration.y +","+ e.acceleration.z;
85824
86914
  S.update();
@@ -85842,8 +86932,8 @@ NOTE: if loadAssets() queueOnly parameter is true, then only the queue receives
85842
86932
  and if loadAssets() or lazy-load with asset() are used then the error event must be captured outside the complete event
85843
86933
 
85844
86934
  --*///+83
85845
- zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, path, progress, ticker, rollover, touch, scrollTop, align, valign, canvasID, rollPerSecond, delay, canvasCheck, gpu, gpuObj, nextFrame, nextStage, allowDefault, loadFailObj, sensors, retina, mouseMoveOutside, captureMouse, shim, maxConnections, maxNum, singleTouch) {
85846
- var sig = "scaling, width, height, color, outerColor, ready, assets, path, progress, ticker, rollover, touch, scrollTop, align, valign, canvasID, rollPerSecond, delay, canvasCheck, gpu, gpuObj, nextFrame, nextStage, allowDefault, loadFailObj, sensors, retina, mouseMoveOutside, captureMouse, shim, maxConnections, maxNum, singleTouch";
86935
+ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, path, progress, ticker, rollover, touch, scrollTop, align, valign, canvasID, rollPerSecond, delay, canvasCheck, gpu, gpuObj, nextFrame, nextStage, allowDefault, loadFailObj, retina, mouseMoveOutside, captureMouse, shim, maxConnections, maxNum, singleTouch) {
86936
+ var sig = "scaling, width, height, color, outerColor, ready, assets, path, progress, ticker, rollover, touch, scrollTop, align, valign, canvasID, rollPerSecond, delay, canvasCheck, gpu, gpuObj, nextFrame, nextStage, allowDefault, loadFailObj, retina, mouseMoveOutside, captureMouse, shim, maxConnections, maxNum, singleTouch";
85847
86937
  var duo; if (duo = zob(zim.Frame, arguments, sig, this)) return duo;
85848
86938
  z_d("83");
85849
86939
  if (zon) zogg("ZIM FRAME");
@@ -85902,7 +86992,6 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
85902
86992
  if (zot(allowDefault)) allowDefault = false;
85903
86993
  if (zot(loadFailObj)) loadFailObj = "circles";
85904
86994
  this.loadFailObj = loadFailObj;
85905
- if (zot(sensors)) sensors = false;
85906
86995
  if (zot(retina)) retina = true;
85907
86996
  this.retina = retina;
85908
86997
  if (zot(mouseMoveOutside)) mouseMoveOutside = false;
@@ -86162,6 +87251,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86162
87251
  }
86163
87252
  }
86164
87253
 
87254
+
86165
87255
  // 5. part of TEN PATCH
86166
87256
  // adjusted checkDispatch to check for resize and assets separately
86167
87257
  // previously, it was as long as there were two checks dispatch!
@@ -86586,14 +87676,18 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86586
87676
 
86587
87677
  // ASSETS
86588
87678
  this.loadAssets = function(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, crossOrigin, fileType, queueOnly, maxConnections, maxNum) {
86589
-
86590
87679
  if (zot(assets)) return endEarly();
86591
87680
  if (zot(assets.src)) { // might be sending single parameter of asset object or audiosprite
86592
87681
  var sig = "assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, crossOrigin, fileType, queueOnly, maxConnections, maxNum";
86593
87682
  var duo; if (duo = zob(that.loadAssets, arguments, sig)) return duo;
86594
87683
  }
86595
- if (!zot(path)) WW.PATH = path;
86596
- // else if (!zot(WW.PATH)) path = WW.PATH;
87684
+
87685
+ if (!zot(path)) {
87686
+ path = path.replace(/\/$/,"");
87687
+ path = path + "/";
87688
+ WW.PATH = path;
87689
+ }
87690
+ // else if (!zot(WW.PATH)) path = WW.PATH;
86597
87691
  var timeType = getTIME(time?time:null);
86598
87692
  if (!zot(progress) && progress.type == "ProgressBar" && zot(xhr)) xhr = true;
86599
87693
  if (zot(xhr)) xhr = true;
@@ -86620,15 +87714,25 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86620
87714
  var soundCheck = false;
86621
87715
  var manifest = [];
86622
87716
  var a, ext, i, j, obj;
86623
- var re = /\.([^.]+)$/i; // get extension
87717
+ var re = /\.([^.]+)$/i; // get extension
86624
87718
  var fonts = [];
86625
87719
  var googleFonts = [];
86626
87720
  var imagesNoCORS = [];
86627
87721
  var mainCount = 0;
86628
87722
  var firstSoundCheck = true;
86629
87723
 
87724
+ // 018 TRYING TO FIX CREATEJS ERROR IF SOUND LOADED AGAIN - BUT BREAKS LAZY LOAD
87725
+ // var emptyAssets = false;
87726
+
86630
87727
  for (i=0; i<assets.length; i++) {
86631
87728
  a = assets[i];
87729
+ // if (zim.assets[a]) {
87730
+ // // 018 TRYING TO FIX CREATEJS ERROR IF SOUND LOADED AGAIN - BUT BREAKS LAZY LOAD
87731
+ // // if (assets.length==1) {
87732
+ // // emptyAssets = true;
87733
+ // // continue;
87734
+ // // }
87735
+ // }
86632
87736
  if (a.replace) a = a.replace(/gf_/i, "https://fonts.googleapis.com/css?family=");
86633
87737
  // split multi into individual ZIM asset objects and make the first of these
86634
87738
  if (a.assets) {
@@ -86640,7 +87744,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86640
87744
  if (aj.split) {
86641
87745
  var temp = aj.split("?");
86642
87746
  ext = temp[0].match(re);
86643
- }
87747
+ }
86644
87748
  if (ext && fontTypes.indexOf(ext[1]) >= 0) {
86645
87749
  fonts.push((a.path?a.path:"")+aj);
86646
87750
  } else if (aj.match && aj.match(/fonts\.googleapis\.com/i)) {
@@ -86695,6 +87799,8 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86695
87799
  } else if (a.id || a.path) { // ZIM asset object
86696
87800
  if (!a.id) a.id = a.src;
86697
87801
  if (a.path) {
87802
+ a.path = a.path.replace(/\/$/,"");
87803
+ a.path = a.path + "/";
86698
87804
  var url, found;
86699
87805
  if (a.path.match(/http/i)) {
86700
87806
  a.src = a.path+a.src;
@@ -86803,6 +87909,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86803
87909
  mainCount++;
86804
87910
  return ext;
86805
87911
  }
87912
+
86806
87913
  that.loadAssetsCount++;
86807
87914
  that.isLoading = true;
86808
87915
  var queue = new zim.Queue();
@@ -86904,10 +88011,10 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86904
88011
  if (soundCheck) preload.installPlugin(createjs.Sound);
86905
88012
 
86906
88013
  preload.on("progress", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
86907
- preload.on("error", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
88014
+ preload.on("error", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
86908
88015
  preload.on("fileload", function(e) {
86909
88016
  // for some reason, errors are not working on IMG and SVG from PreloadJS
86910
- // so check for rawResult - should really fix this in CreateJS
88017
+ // so check for rawResult - should really fix this in CreateJS
86911
88018
  if (!e.result || ((e.result.nodeName=="IMG" || e.result.nodeName=="SVG") && !e.rawResult && xhr)) {
86912
88019
  var ev = new createjs.Event("error");
86913
88020
  ev = new createjs.Event("error");
@@ -87004,12 +88111,13 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87004
88111
  that.dispatchEvent(ev);
87005
88112
  }
87006
88113
  }
87007
- });
88114
+ });
88115
+
87008
88116
  that.preloadEvent = preload.on("complete", function(e) {
87009
88117
  completeEventObject = e;
87010
88118
  queue.loadAssetsCount--;
87011
88119
  if (queue.loadAssetsCount == 0) endAssetLoad();
87012
- });
88120
+ });
87013
88121
  try {preload.loadManifest(manifest);}catch(err){
87014
88122
  +function(){}()
87015
88123
  }
@@ -87022,6 +88130,12 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87022
88130
 
87023
88131
  } // end non font/noCORSonImage
87024
88132
 
88133
+ // 018 TRYING TO FIX CREATEJS ERROR IF SOUND LOADED AGAIN - BUT BREAKS LAZY LOAD
88134
+ // // if calling an already preloaded asset
88135
+ // if (emptyAssets && queue.loadAssetsCount == 0) {
88136
+ // endAssetLoad();
88137
+ // }
88138
+
87025
88139
  function endAssetLoad() {
87026
88140
  // setting a time will force the preload to wait at least this amount of time
87027
88141
  // this can be used for testing or if you always want time to show a loading message
@@ -87067,7 +88181,10 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87067
88181
  // now check auto load assets or broken if second
87068
88182
 
87069
88183
  if (WW.PATH!=null) zim.PATH = WW.PATH;
87070
-
88184
+ if (zim.PATH!=null) {
88185
+ zim.PATH.replace(/\/$/,"");
88186
+ zim.PATH = zim.PATH + "/";
88187
+ }
87071
88188
  if (second) {
87072
88189
  var empty;
87073
88190
  if (that.loadFailObj == "circles") empty = that.makeCircles(14);
@@ -87603,9 +88720,9 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87603
88720
  WW.addEventListener("contextmenu", contextEvent, false);
87604
88721
 
87605
88722
  var eDown = new createjs.Event("keydown");
87606
- this.eventRemove = eDown.remove;
88723
+ this.downEventRemove = eDown.remove;
87607
88724
  function keydownEvent(e) {
87608
- e.remove = that.eventRemove;
88725
+ e.remove = that.downEventRemove;
87609
88726
  that.altKey = e.altKey;
87610
88727
  that.ctrlKey = e.ctrlKey;
87611
88728
  that.metaKey = e.metaKey;
@@ -87616,47 +88733,23 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87616
88733
  }
87617
88734
  // var realWindow = window.parent || window;
87618
88735
  WW.addEventListener("keydown", keydownEvent);
88736
+
88737
+ var eUp = new createjs.Event("keyup");
88738
+ this.upEventRemove = eUp.remove;
87619
88739
  function keyupEvent(e) {
87620
88740
  that.altKey = e.altKey;
87621
88741
  that.ctrlKey = e.ctrlKey;
87622
88742
  that.metaKey = e.metaKey;
87623
88743
  that.shiftKey = e.shiftKey;
87624
- e.remove = that.eventRemove;
88744
+ e.remove = that.upEventRemove;
87625
88745
  that.dispatchEvent(e);
87626
- }
88746
+ }
87627
88747
  WW.addEventListener("keyup", keyupEvent);
87628
- function wheelEvent(e) {
87629
- that.dispatchEvent(e);
87630
- }
87631
- WW.addEventListener("wheel", wheelEvent);
87632
- function devicemotionEvent(e) {
87633
- e.remove = that.eventRemove;
88748
+
88749
+ function wheelEvent(e) {
87634
88750
  that.dispatchEvent(e);
87635
88751
  }
87636
- if (sensors && WW.DeviceMotionEvent) {
87637
- WW.addEventListener("devicemotion",devicemotionEvent);
87638
- }
87639
- function deviceorientationEvent(e) {
87640
- e.remove = that.eventRemove;
87641
- // for some reason, reporting alpha as increasing going counter counterclockwise
87642
- // so this code makes it increase going clockwise
87643
- var z = 360-e.alpha;
87644
- // compass is subtracting 180 if device screen is pointing down
87645
- // in a VR helmet this would be looking slightly up from the horizon...
87646
- // so removing this flip with the following code
87647
- if (Math.abs(z-lastZ) > 180 - 45 && Math.abs(z-lastZ) < 180 + 45) flip = flip == 0 ? 180 : 0;
87648
- lastZ = z;
87649
- e.rotation = {x:e.beta, y:e.gamma, z:(z + flip) % 360};
87650
- that.dispatchEvent(e);
87651
- }
87652
- if (sensors && WW.DeviceOrientationEvent) {
87653
- // zim.timeout(.2, function () {
87654
- // that.dispatchEvent("yes");
87655
- // });
87656
- var lastZ = 0;
87657
- var flip = 0;
87658
- WW.addEventListener("deviceorientation",deviceorientationEvent);
87659
- }
88752
+ WW.addEventListener("wheel", wheelEvent);
87660
88753
 
87661
88754
  this.isFullscreen = document.fullscreenElement?true:false;
87662
88755
  this.htmlobc = zet("html").css("backgroundColor");
@@ -87869,14 +88962,14 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87869
88962
  WW.removeEventListener("keydown", keydownEvent); // thanks Reinout Mechant for the fix!
87870
88963
  WW.removeEventListener("keyup", keyupEvent);
87871
88964
  WW.removeEventListener("wheel", wheelEvent);
87872
- WW.removeEventListener("devicemotion", devicemotionEvent);
87873
- WW.removeEventListener("deviceorientation", deviceorientationEvent);
88965
+ if (that.zimDevicemotionEvent) WW.removeEventListener("devicemotion", that.zimDevicemotionEvent);
88966
+ if (that.zimDeviceorientationEvent) WW.removeEventListener("deviceorientation", that.zimDeviceorientationEvent);
87874
88967
 
87875
88968
  WW.removeEventListener("mousedown", leftEvent, true);
87876
88969
  WW.removeEventListener("mousemove", leftEvent, true);
87877
88970
  WW.removeEventListener("mouseup", leftEvent);
87878
88971
 
87879
- if (!allowDefault) document.body.style.overflow = "auto";
88972
+ if (!allowDefault) document.body.style.overflow = "athatuto";
87880
88973
  recursiveDispose(stage);
87881
88974
  function recursiveDispose(obj) {
87882
88975
  if (!obj) return;
@@ -88916,6 +90009,11 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
88916
90009
  that.file = file;
88917
90010
 
88918
90011
  if (WW.PATH!=null) zim.PATH = WW.PATH;
90012
+ if (zim.PATH!=null) {
90013
+ zim.PATH.replace(/\/$/,"");
90014
+ zim.PATH = zim.PATH + "/";
90015
+ }
90016
+
88919
90017
  var added = "";
88920
90018
  if (file.split("/").length==1 && zim.PATH) added = zim.PATH;
88921
90019
  this.mouseChildren = false;
@@ -89053,6 +90151,121 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89053
90151
  }
89054
90152
  zim.extend(zim.Vid, zim.Container, ["clone", "dispose"], "zimContainer", false);//-83.07
89055
90153
 
90154
+ //
90155
+ /*--
90156
+ Dat = function(file)
90157
+
90158
+ Dat
90159
+ zim class - extends a createjs EventDispatcher
90160
+
90161
+ DESCRIPTION
90162
+ Use Dat() to load data files like text, csv, XML and json.
90163
+ Then use the data property to get the data.
90164
+
90165
+ Before ZIM version ZIM 018 the Frame asset() method was used for data
90166
+ and asset(file) can still be used - the Dat() class is a wrapper class to match Pic(), Aud(), etc.
90167
+ It is just a dozen lines long.
90168
+
90169
+ PRELOADING
90170
+ It is recommended that you preload data files using the Frame() assets and path parameters.
90171
+ After the frame loads, data files can also be loaded on demand with F.loadAssets().
90172
+
90173
+ LAZY-LOADING
90174
+ The data file can be lazy loaded at which point the data property will be available in a complete or ready event
90175
+
90176
+ Dat will give a "ready" and a "complete" event when loaded.
90177
+ These events are triggered 20 ms after making the object if the object is already preloaded.
90178
+
90179
+ See: https://zimjs.com/018/dat.html
90180
+
90181
+ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
90182
+
90183
+ EXAMPLE
90184
+ // loading a text file with some text
90185
+ new Frame(FIT, 1024, 768, light, dark, ready, "data.txt", "assets/");
90186
+ function ready() {
90187
+ const data = new Dat("data.txt").data;
90188
+ new Label(data).center();
90189
+ }
90190
+ END EXAMPLE
90191
+
90192
+ EXAMPLE
90193
+ // loading a JSON file with {"test":"complete"}
90194
+ new Frame(FIT, 1024, 768, light, dark, ready, "data.json", "assets/");
90195
+ function ready() {
90196
+ const data = new Dat("data.json").data;
90197
+ new Label(data.test).center(); // will say complete
90198
+ }
90199
+ END EXAMPLE
90200
+
90201
+ EXAMPLE
90202
+ // loading an XML file with <test>complete</test>
90203
+ new Frame(FIT, 1024, 768, light, dark, ready, "data.xml", "assets/");
90204
+ function ready() {
90205
+ const data = new Dat("data.xml").data;
90206
+ // also children property and getAttribute() method, etc.
90207
+ new Label(data.innerHTML).center(); // will say complete
90208
+ }
90209
+ // also see https://zimjs.com/018/dat.html for looping through multiple tags
90210
+ END EXAMPLE
90211
+
90212
+ EXAMPLE
90213
+ // lazy loading a text file with some text
90214
+ new Frame(FIT, 1024, 768, light, dark, ready);
90215
+ function ready() {
90216
+ const text = new Dat("assets/data.txt");
90217
+ data.on("complete", ()=>{
90218
+ new Label(text.data).center();
90219
+ });
90220
+ }
90221
+ END EXAMPLE
90222
+
90223
+ PARAMETERS
90224
+ file - the file provided to the Frame class (or Frame loadAssets method) assets parameter
90225
+ or if not preloaded then the file to lazy load - then must wait for the complete or ready event
90226
+
90227
+ PROPERTIES
90228
+ type - holds the class name as a String
90229
+ data - the data such as the text for a txt file or will be a JSON parsed object for a JSON file
90230
+
90231
+ EVENTS
90232
+ dispatches a "complete" and a "ready" event
90233
+ used primarily for lazy loading of the file
90234
+ if preloaded then the Frame or loadAsssets ready event is all that is needed
90235
+ there will be a complete or ready event on the Dat() dispatched 20 ms later for compatibility
90236
+ --*///+83.08
90237
+ zim.Dat = function(file) {
90238
+ z_d("83.08");
90239
+ this.type = "Dat";
90240
+ var asset = zim.asset(file);
90241
+ var that = this;
90242
+ if (asset && asset.type != "AC") {
90243
+ if (asset.documentElement) asset = asset.documentElement;
90244
+ that.data = asset;
90245
+ that.file = file;
90246
+ setTimeout(function() {
90247
+ that.dispatchEvent("ready");
90248
+ that.dispatchEvent("complete");
90249
+ }, 20);
90250
+ } else {
90251
+ if (WW.PATH!=null) zim.PATH = WW.PATH;
90252
+ if (zim.PATH!=null) {
90253
+ zim.path.replace(/\/$/,"");
90254
+ zim.path = zim.path + "/";
90255
+ }
90256
+ var loader = zdf.loadAssets(file, zim.PATH);
90257
+ loader.on("complete", function() {
90258
+ var asset = zim.asset(file);
90259
+ if (asset.documentElement) asset = asset.documentElement;
90260
+ that.data = asset;
90261
+ that.file = file;
90262
+ that.dispatchEvent("ready");
90263
+ that.dispatchEvent("complete");
90264
+ });
90265
+ }
90266
+ }
90267
+ zim.extend(zim.Dat, createjs.EventDispatcher, null, "cjsEventDispatcher", false);//-83.08
90268
+
89056
90269
  /*--
89057
90270
  SVG = function(svg, width, height, bitmap, splitTypes, geometric, showControls, interactive, style, group, inherit)
89058
90271
 
@@ -89266,13 +90479,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89266
90479
  if (width && height) this.type = "ACWD"; // AssetContainer with Dimensions - does not recall methods
89267
90480
  else this.type = "AC"; // AssetContainer
89268
90481
 
89269
-
90482
+ var svgO = svg;
90483
+ var fromID = zim.assetIDs[svg];
90484
+ if (fromID) svg = fromID;
89270
90485
  var a = zim.assets[svg];
89271
90486
  if (a) {
89272
90487
  that.src = a.src;
89273
90488
  that.file = a.file;
89274
90489
  that.item = a.item;
89275
- that.svg = a.svg;
90490
+ that.svg = a.svgO;
89276
90491
  }
89277
90492
  if (a && a.type=="Bitmap") {
89278
90493
  that.type = "SVG";
@@ -89297,7 +90512,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89297
90512
  else that.bitmap = a.clone();
89298
90513
  getSVG();
89299
90514
  } else {
89300
- if (svg && svg.match(/<svg/i)) that.svg = svg;
90515
+ if (svgO && svgO.match(/<svg/i)) that.svg = svgO;
89301
90516
  if (that.svg && that.svg.match(/<svg/i)) {
89302
90517
  that.type = "SVG";
89303
90518
  getSVG();
@@ -89392,7 +90607,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89392
90607
 
89393
90608
  if (style!==false) zim.styleTransforms(this, DS);
89394
90609
  that.clone = function (exact) {
89395
- return this.cloneProps(new zim.SVG(exact?svg:originalSVG, width, height, bitmap, splitTypes, geometric, showControls, interactive, style, this.group, inherit));
90610
+ return this.cloneProps(new zim.SVG(exact?svgO:originalSVG, width, height, bitmap, splitTypes, geometric, showControls, interactive, style, this.group, inherit));
89396
90611
  }
89397
90612
  }
89398
90613
  zim.extend(zim.SVG, zim.Container, ["clone"], "zimContainer", false);//-83.09
@@ -89495,9 +90710,10 @@ dispatches "result" when either as each word is spoken if listen() is used (inte
89495
90710
  and a confidence property that is a ratio (0-1) for confidence in the result
89496
90711
  Note: iOS (at this time) does not support the listen() and result event
89497
90712
  dispatches "speechend" events when listen() has detected an end to the talking
90713
+ dispatches "start", "end" events
90714
+ dispatches a "boundary" event between words
89498
90715
  dispatches an "error" event if no words are spoken, etc. the event object has an error property with the error message
89499
- dispatches "start", "end", "boundary", and "error" on the utterance object returned by talk()
89500
- Note: there are more features to the Web Speech API - see the HTML docs
90716
+ Note: there are more features to the Web Speech API - see the HTML docs
89501
90717
  --*///+83.095
89502
90718
  zim.Speech = function() {
89503
90719
  z_d("83.095");
@@ -89693,7 +90909,7 @@ and a keyboardMessage() method to prompt for keyboard interactivity.
89693
90909
  When an app is first loaded it cannot receive keyboard events until it is interacted with.
89694
90910
  Interaction must be a mousedown or click - not just an over or move interaction.
89695
90911
  Often, we will make an intro Pane() or play Button() for a game, for instance, before playing sounds.
89696
- In ZIM 014 we added a keyboardMessage() method to prompt for an interaction so key events are activated.
90912
+ In ZIM 014 we added a keyboardMessage() method to the Frame to prompt for an interaction so key events are activated.
89697
90913
 
89698
90914
  Also see ZIM Keyboard(), TextEditor(), TextInput() and MotionController() for various keyboard functionality.
89699
90915
 
@@ -89759,56 +90975,55 @@ DESCRIPTION
89759
90975
  The Frame has a "devicemotion" event to capture device tilt
89760
90976
  and a "deviceorientation" to capture device rotation (like a compass)
89761
90977
 
89762
- Also see the PermissionAsk() class which will handle asking for permission.
90978
+ Also see the PermissionAsk() class which will handle asking for permission on iOS devices.
89763
90979
 
89764
90980
  NOTE:
89765
90981
  For either event the Frame sensors parameter MUST be set to true
89766
90982
 
89767
90983
  EXAMPLE
89768
- // DEVICE ORIENTATION - gives angle of device in all 3 dimensions
89769
- // Note: this is NOT an orientation event to see if phone is portrait or landscape (see Frame orientation event)
89770
- // Note: must set Frame() sensors true - for example:
89771
- // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
90984
+ // for capturing tilt on device (rotation about an axis)
90985
+ // also SEE the PermissionAsk example below
90986
+ // also set Frame sensors parameter to true
90987
+ // and be on a mobile device
90988
+ const label = new Label().center();
90989
+ F.on("deviceorientation", e=>{
90990
+ label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
90991
+ S.update();
90992
+ });
90993
+ END EXAMPLE
89772
90994
 
89773
- const permissionType = "deviceorientation";
90995
+ EXAMPLE
90996
+ // on iOS, the sensors must be allowed first - this example works for all devices
90997
+ const label = new Label().center();
90998
+ const permissionType = "deviceorientation"; // or "devicemotion"
89774
90999
  const ask = new PermissionAsk(init, permissionType);
89775
- function init(yes) {
89776
- const errorPane = new Pane("SENSOR not available",yellow);
89777
- if (yes) { // the user answers yes to the PermissionAsk
89778
- // use the sensors
89779
- const label = new Label("test on mobile").centerReg();
91000
+ function init(yes) {
91001
+ // if the user answers yes to the PermissionAsk
91002
+ const errorPane = new Pane("SENSOR not available",yellow);
91003
+ if (yes) {
91004
+ // use the sensors
89780
91005
  F.on("deviceorientation", e=>{
89781
- // use the sensors
89782
- label.text = label.text = "x: "+decimals(e.rotation.x) +"\ny: "+ decimals(e.rotation.y) +"\nz: "+ decimals(e.rotation.z);
91006
+ label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
89783
91007
  S.update();
89784
91008
  });
89785
- } else { // the user answered no to PermissionAsk dialog
91009
+ S.update();
91010
+ } else { // answered no to PermissionAsk dialog
89786
91011
  errorPane.show();
89787
91012
  }
89788
91013
  }
89789
91014
  END EXAMPLE
89790
91015
 
89791
91016
  EXAMPLE
89792
- // DEVICE MOTION - gives accelerometer values in all 3 dimensions
89793
- // Note: must set Frame() sensors true - for example:
89794
- // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
89795
-
89796
- const permissionType = "devicemotion";
89797
- const ask = new PermissionAsk(init, permissionType);
89798
- function init(yes) {
89799
- const errorPane = new Pane("SENSOR not available",yellow);
89800
- if (yes) { // the user answers yes to the PermissionAsk
89801
- // use the sensors
89802
- const label = new Label("test on mobile").centerReg();
89803
- F.on("devicemotion", e=>{
89804
- // use the sensors
89805
- label.text = "x: "+decimals(e.acceleration.x, 3) +"\ny: "+ decimals(e.acceleration.y, 3) +"\nz: "+ decimals(e.acceleration.z, 3);
89806
- S.update();
89807
- });
89808
- } else { // the user answered no to PermissionAsk dialog
89809
- errorPane.show();
89810
- }
89811
- }
91017
+ // for shaking motion - ALSO see the PermissionAsk example above for iOS
91018
+ // and replace "deviceorientation" with "devicemotion"
91019
+ // and replace e.rotation.x, etc. with e.acceleration.x etc.
91020
+ // also set Frame sensors parameter to true
91021
+ // and be on a mobile device
91022
+ const label = new Label().center();
91023
+ F.on("devicemotion", e=>{
91024
+ label.text = e.acceleration.x +","+ e.acceleration.y +","+ e.acceleration.z;
91025
+ S.update();
91026
+ });
89812
91027
  END EXAMPLE
89813
91028
 
89814
91029
  EVENTS
@@ -89836,16 +91051,17 @@ A circular confirmation widget to ask the user if they want a permission for iOS
89836
91051
  For some iOS permissions, the app needs to be interactive with first before permission can be asked!
89837
91052
  This is for iOS only - if not in iOS then will just pass through the test.
89838
91053
 
89839
- NOTE: this started as SensorAsk but the class has been adjusted to handle other permissions and the name has been changed in ZIM 016
91054
+ Also adds Frame deviceorientation and devicemotion events for a matching permissionType.
91055
+ Pre ZIM 018, this was done with a sensors parameter on the Frame.
91056
+ The sensors parameter has now been removed and the events are handled with PermissionAsk.
89840
91057
 
89841
- NOTE: for deviceorientation and devicemotion the Frame sensors parameter must be set to true
91058
+ NOTE: this started as SensorAsk but the class has been adjusted to handle other permissions and the name has been changed in ZIM 016
89842
91059
 
89843
91060
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
89844
91061
 
89845
91062
  EXAMPLE
89846
91063
  // DEVICE ORIENTATION - gives angle of device in all 3 dimensions
89847
91064
  // Note: this is NOT an orientation event to see if phone is portrait or landscape (see Frame orientation event)
89848
- // Note: must set Frame() sensors true - for example:
89849
91065
  // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
89850
91066
 
89851
91067
  const permissionType = "deviceorientation";
@@ -89854,7 +91070,7 @@ function init(yes) {
89854
91070
  const errorPane = new Pane("SENSOR not available",yellow);
89855
91071
  if (yes) { // the user answers yes to the PermissionAsk
89856
91072
  // use the sensors
89857
- const label = new Label("test on mobile").centerReg();
91073
+ const label = new Label("on mobile").centerReg();
89858
91074
  F.on("deviceorientation", e=>{
89859
91075
  // use the sensors
89860
91076
  label.text = label.text = "x: "+decimals(e.rotation.x) +"\ny: "+ decimals(e.rotation.y) +"\nz: "+ decimals(e.rotation.z);
@@ -89868,7 +91084,6 @@ END EXAMPLE
89868
91084
 
89869
91085
  EXAMPLE
89870
91086
  // DEVICE MOTION - gives accelerometer values in all 3 dimensions
89871
- // Note: must set Frame() sensors true - for example:
89872
91087
  // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
89873
91088
 
89874
91089
  const permissionType = "devicemotion";
@@ -89877,7 +91092,7 @@ function init(yes) {
89877
91092
  const errorPane = new Pane("SENSOR not available",yellow);
89878
91093
  if (yes) { // the user answers yes to the PermissionAsk
89879
91094
  // use the sensors
89880
- const label = new Label("test on mobile").centerReg();
91095
+ const label = new Label("on mobile").centerReg();
89881
91096
  F.on("devicemotion", e=>{
89882
91097
  // use the sensors
89883
91098
  label.text = "x: "+decimals(e.acceleration.x, 3) +"\ny: "+ decimals(e.acceleration.y, 3) +"\nz: "+ decimals(e.acceleration.z, 3);
@@ -89915,8 +91130,8 @@ PARAMETERS - accepts ZIM DUO regular parameters in order or a configuration obje
89915
91130
  callback - the function to callback when permission is accepted
89916
91131
  if the permissionType is deviceorientation or devicemotion this will receive true for accept or false for no permission
89917
91132
  if the permissionType is audio, video or audiovideo this will receive a stream if accepted or false if not
89918
- for not iOS, the system permissions will appear if needed
89919
- for iOS the PermissionAsk Pane will be shown and then system permissions
91133
+ for not iOS, the system permissions will appear
91134
+ for iOS the PermissionAsk Pane will be shown and the system permissions
89920
91135
  in all cases, the callback will be called on result
89921
91136
  the parameter given to the callback will be true (sensors) or a media stream (mic / cam) or false if not accepted
89922
91137
  permissionType - (default "deviceorientation") the string deviceorientation, devicemotion, mic, cam, or miccam
@@ -89983,10 +91198,10 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
89983
91198
  borderColor:color,
89984
91199
  borderWidth:2
89985
91200
  });
89986
- var pt = permissionType;
91201
+ var pt = permissionType;
89987
91202
  var okay = false;
89988
91203
  that.yes = new zim.Button({label:"YES", group:"PermissionAsk"}).sca(.65).pos(0,30,CENTER,TOP,this);
89989
- var words = {deviceorientation:"sensors", devicemotion:"sensors", mic:"mic", cam:"cam", miccam:"mic/cam"};
91204
+ var words = {deviceorientation:"sensors", devicemotion:"sensors", mic:"mic", cam:"cam", miccam:"mic/cam"};
89990
91205
  that.label = new zim.Label("Use " + (words[pt]?words[pt]:"feature") + "?", 30, null, color, null, null, null, "center").sca(.9).centerReg(this);
89991
91206
  that.no = new zim.Button({label:"NO", group:"PermissionAsk"}).sca(.65).pos(0,30,CENTER,BOTTOM,this);
89992
91207
 
@@ -89996,24 +91211,24 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
89996
91211
  if (style!==false) zim.styleTransforms(this, DS);
89997
91212
 
89998
91213
  var frame = WW.zdf;
89999
- if (pt == "mic" || pt == "cam" || pt == "miccam") {
90000
- if (M=="ios") {
91214
+ if (pt == "mic" || pt == "cam" || pt == "miccam") {
91215
+ if (M=="ios") {
90001
91216
  setPane();
90002
- return;
90003
- }
90004
- if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
90005
- navigator.mediaDevices.getUserMedia({audio: (pt=="mic" || pt=="miccam"), video:(pt=="cam" || pt=="miccam") })
90006
- .then(function(stream) {
90007
- callback(stream);
90008
- })
90009
- .catch(function(err) {
90010
- callback(false);
90011
- });
90012
- } else callback(false);
90013
- return;
90014
- }
91217
+ return;
91218
+ }
91219
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
91220
+ navigator.mediaDevices.getUserMedia({audio: (pt=="mic" || pt=="miccam"), video:(pt=="cam" || pt=="miccam") })
91221
+ .then(function(stream) {
91222
+ callback(stream);
91223
+ })
91224
+ .catch(function(err) {
91225
+ callback(false);
91226
+ });
91227
+ } else callback(false);
91228
+ return;
91229
+ }
90015
91230
 
90016
- // sensors only
91231
+ // sensors only
90017
91232
  if (typeof DeviceOrientationEvent != "undefined" && DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission == "function") {
90018
91233
  setPane();
90019
91234
  } else {
@@ -90032,19 +91247,43 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
90032
91247
  }
90033
91248
  called = true;
90034
91249
  WW.removeEventListener(permissionType, testMe);
90035
- }
91250
+ }
90036
91251
  setTimeout(function(){
90037
91252
  if (!called) callback(false);
90038
91253
  }, 100);
90039
91254
  }
90040
91255
 
90041
- function setEvents() {
91256
+ var lastZ = 0;
91257
+ var flip = 0;
91258
+ function deviceorientationEvent(e) {
91259
+ // for some reason, reporting alpha as increasing going counter counterclockwise
91260
+ // so this code makes it increase going clockwise
91261
+ var z = 360-e.alpha;
91262
+ // compass is subtracting 180 if device screen is pointing down
91263
+ // in a VR helmet this would be looking slightly up from the horizon...
91264
+ // so removing this flip with the following code
91265
+ if (Math.abs(z-lastZ) > 180 - 45 && Math.abs(z-lastZ) < 180 + 45) flip = flip == 0 ? 180 : 0;
91266
+ lastZ = z;
91267
+ e.rotation = {x:e.beta, y:e.gamma, z:(z + flip) % 360};
91268
+ frame.dispatchEvent(e);
91269
+ }
91270
+ function devicemotionEvent(e) {
91271
+ frame.dispatchEvent(e);
91272
+ }
91273
+ function setEvents() {
91274
+ if (permissionType=="deviceorientation") {
91275
+ frame.zimDeviceorientationEvent = deviceorientationEvent;
91276
+ WW.addEventListener("deviceorientation", frame.zimDeviceorientationEvent);
91277
+ } else {
91278
+ frame.zimDevicemotionEvent = devicemotionEvent;
91279
+ WW.addEventListener("devicemotion", frame.zimDevicemotionEvent);
91280
+ }
90042
91281
  callback(true);
90043
91282
  }
90044
91283
 
90045
91284
  function setPane() {
90046
91285
  frame.canvas.style.pointerEvents = "none";
90047
- that.show();
91286
+ that.show();
90048
91287
  document.addEventListener("mousedown", kmd);
90049
91288
  }
90050
91289
 
@@ -90199,7 +91438,7 @@ These DO NOT require the zim namespace, even if zns=true is set or if using node
90199
91438
  These are all equal to strings with lowercase values.
90200
91439
  So using TOP is the same as using "top"
90201
91440
 
90202
- Positioning: FIT, FILL, FULL, LEFT, RIGHT, CENTER, MIDDLE, START, END, TOP, BOTTOM, OVER, UNDER, HORIZONTAL, VERTICAL, BOTH, RANDOM, RADIAL, UP, DOWN, NEXT, PREV, AUTO, DEFAULT, ALL, NONE, AVE
91441
+ Positioning: FIT, FILL, FULL, LEFT, RIGHT, CENTER, MIDDLE, JUSTIFY, START, END, TOP, BOTTOM, OVER, UNDER, HORIZONTAL, VERTICAL, BOTH, RANDOM, RADIAL, UP, DOWN, NEXT, PREV, AUTO, DEFAULT, ALL, NONE, AVE
90203
91442
  Data: GET, POST, LOCALSTORAGE, SOCKET, TO, FROM, BOTH
90204
91443
  Sound: SINE, SQUARE, TRIANGLE, SAW, ZAP
90205
91444
  Style: IGNORE
@@ -90223,6 +91462,7 @@ END EXAMPLE
90223
91462
  zim.RIGHT = "right";
90224
91463
  zim.CENTER = "center";
90225
91464
  zim.MIDDLE = "middle";
91465
+ zim.JUSTIFY ="justify";
90226
91466
  zim.START = "start";
90227
91467
  zim.END = "end";
90228
91468
  zim.TOP ="top";
@@ -90272,7 +91512,7 @@ The globals NEVER require the zim namespace and are global in the JavaScript win
90272
91512
 
90273
91513
  ZIM has a method called zimplify() that can make all ZIM classes, functions and properties global.
90274
91514
  zimplify() loops through all properties on the zim namespace and adds them to the JavaScript window.
90275
- Examples are Frame(), Button(), center(), STYLE, Emitter(), etc.
91515
+ Examples are Frame(), Button(), center(), STYLE, GLOBALSTYLE, Emitter(), etc.
90276
91516
  zimplify() is automatically run when using the CDN ES module or script tags
90277
91517
  unless the global variable zns is set to true before importing ZIM.
90278
91518
  If zns is set to true, then the zim namespace is required: zim.Frame(), etc.
@@ -91012,12 +92252,18 @@ function zimify(obj, a, b, c, d, list) {
91012
92252
  hitTestRect:function(b, num, boundsCheck, inside) {
91013
92253
  return zim.hitTestRect(this, b, num, boundsCheck, inside);
91014
92254
  },
92255
+ hitTestRectPoint:function(x, y, margin) {
92256
+ return zim.hitTestRectPoint(this, x, y, margin);
92257
+ },
91015
92258
  hitTestCircle:function(b, num, boundsCheck, inside) {
91016
92259
  return zim.hitTestCircle(this, b, num, boundsCheck, inside);
91017
92260
  },
91018
92261
  hitTestCircleRect:function(b, margin) {
91019
92262
  return zim.hitTestCircleRect(this, b, margin);
91020
92263
  },
92264
+ hitTestCirclePoint:function(x, y, margin) {
92265
+ return zim.hitTestCirclePoint(this, x, y, margin);
92266
+ },
91021
92267
  hitTestCircles:function(b, margin) {
91022
92268
  return zim.hitTestCircles(this, b, margin);
91023
92269
  },
@@ -92139,7 +93385,7 @@ getLatestVersions(function(versions) {
92139
93385
  });
92140
93386
  END EXAMPLE
92141
93387
  --*///+82.1
92142
- zim.VERSION = "017/zim";
93388
+ zim.VERSION = "018/zim";
92143
93389
  //-82.1
92144
93390
 
92145
93391
  /*--
@@ -92551,6 +93797,10 @@ animator - the Gifler animator
92551
93797
  var to;
92552
93798
  var f;
92553
93799
  if (WW.PATH!=null) zim.PATH = WW.PATH;
93800
+ if (zim.PATH!=null) {
93801
+ zim.path.replace(/\/$/,"");
93802
+ zim.path = zim.path + "/";
93803
+ }
92554
93804
  if (file.match(/http/) || file.match(/^\//)) f = file;
92555
93805
  else f = (zim.PATH?zim.PATH:"")+file;
92556
93806
  that.gifler = gifler(f)
@@ -95064,8 +96314,40 @@ zim class - extends a zim.Container which extends a createjs.Container
95064
96314
  DESCRIPTION
95065
96315
  Shows the output from the Webcam after user permits access.
95066
96316
  Will stretch to fit in dimensions and can choose to flip (default) or not.
95067
- Used by ZIM CamMotion, CamCursor, CamAlpha and CamControls classes
95068
96317
 
96318
+ AS OF ZIM 018 - USE ML5 (Machine Learning 5)
96319
+ We recommend using ZIM Cam() with the ML5 Library at https://ml5js.org/
96320
+ Note: the ML5 library must be imported in a script tag.
96321
+
96322
+ HAND TRACKING WITH ZIM CAM AND ML5
96323
+ ZIM Cam has a handTrack(ML5results) method that will replace normal mouse and touch.
96324
+ Each pointer finger is a cursor for mousemove, mouseover and mouseout
96325
+ and pinching the pointer finger and the thumb, triggers mousedown, pressmove, pressup, tap, and click.
96326
+ There is a cursorMode which defaults to AUTO - there are also true and false values.
96327
+ On AUTO, if a hand is detected, then the mouse and touch are replaced by the finger and pinch
96328
+ but if the hand is not detected, then the mouse and touch are used.
96329
+ On true, the mouse and touch are turned off and only the finger and pinch are used.
96330
+ On false, the mouse and touch are active nd the finger and pinch are not used
96331
+ but the cursors for these are still there and they still give events and data which can be used.
96332
+ The cursorMode property can be used to change the mode dynamically.
96333
+ There is also a toggleReplace parameter and property (default true)
96334
+ which lets the user toggle using the hand rather than mouse and press but pinchin thumb and pinky.
96335
+ When a hand replaces the mouse and touch, the cam.replaceCursor is true as is the zim.handCursor.
96336
+ When the mouse and touch are being used then cam.replaceCursor and zim.handCursor are false.
96337
+ The handTrack() method automatically calls a prepareTrack() method if prepareTrack() is not already called.
96338
+ Optionally, the prepareTrack() can be called first to set a variety of options including the cursorMode parameter.
96339
+ The tracking cursors will still show and the cam dispatches "handmove", "handdown", and "handup" events.
96340
+ SEE: https://zimjs.com/018/handtrack.html - replacing the cursor
96341
+
96342
+ GENERAL ML5 FUNCTIONALITY
96343
+ ML5 can give very accurate hand poses, face poses and body poses and results return points.
96344
+ These points can be used to place ZIM objects or with a ZIM Shape to make circles, etc.
96345
+ There are other features too like shape recognition, blurring backgrounds, etc.
96346
+ These can all be used in ZIM - for using ML5 for interaction see the HAND TRACKING section above.
96347
+ SEE: https://zimjs.com/ml5/ - general ML5 integration examples
96348
+
96349
+ BEFORE ZIM 018
96350
+ ZIM CamMotion, CamCursor, CamAlpha and CamControls classes were used instead of ML5 and are still available
95069
96351
  SEE: https://zimjs.com/nft/bubbling/cam.html and use right arrow to see all four examples
95070
96352
  SEE: https://www.youtube.com/watch?v=z_jn6wkX6Ec
95071
96353
  SEE: https://www.youtube.com/watch?v=0vwJ3aodU4U
@@ -95139,6 +96421,75 @@ const ask = new CamAsk().show(yes => {
95139
96421
  });
95140
96422
  END EXAMPLE
95141
96423
 
96424
+ EXAMPLE
96425
+ // use ML5 at https://unpkg.com/ml5@1/dist/ml5.min.js for hand tracking
96426
+ // on a Mac, the canvas must be interacted with first
96427
+ // so would recommend always using CamAsk first:
96428
+ const ask = new CamAsk().show(yes=>{
96429
+ if (yes) {
96430
+ // new Cam() will trigger the Browser asking for permission
96431
+ // unless already have given permission in this session
96432
+ let cam = new Cam(1280,720);
96433
+ cam.on("ready", ()=>{
96434
+ cam.scaleTo().center().alp(.2);
96435
+
96436
+ // optional - use prepareTrack() with the following parameters:
96437
+ // width, height, hand, pinchColor, pinchHide, leftColor, rightColor, handScale, handAlpha, damp, gapTime, tapTime, cursorMode, toggleReplace
96438
+ // cam.prepareTrack()
96439
+
96440
+ // ML5
96441
+ const handPose = ml5.handPose(modelLoaded);
96442
+ function modelLoaded() {
96443
+ handPose.detectStart(cam.getCanvas(), result);
96444
+ function result(results) {
96445
+ // ZIM Cam to replace mouse with hand and provide pinch for interaction
96446
+ cam.handTrack(results); // this will automatically call prepareTrack() if not called already
96447
+ }
96448
+ }
96449
+
96450
+ const slider = new Slider({
96451
+ button:new Button({
96452
+ rollBgColor:purple,
96453
+ corner:30,
96454
+ width:60,
96455
+ height:60,
96456
+ label:""
96457
+ }),
96458
+ vertical:true,
96459
+ min:0,
96460
+ max:1,
96461
+ value:cam.alpha
96462
+ }).center().change(()=>{
96463
+ cam.alpha = slider.value;
96464
+ });
96465
+
96466
+ const tabs = new Tabs({width:400, height:60, tabs:["LEFT", "BOTH", "RIGHT"], index:2})
96467
+ .pos(0,100,CENTER)
96468
+ .tap(()=>{
96469
+ cam.hand = tabs.text.toLowerCase();
96470
+ });
96471
+
96472
+ new Label({
96473
+ text:"Don't put hands too close\nIndex finger is the cursor\nPinch thumb for mousedown\nRelease pinch for mouseup\nPinch pinky to toggle mouse",
96474
+ color:silver,
96475
+ size:25,
96476
+ backgroundColor:black.toAlpha(.5),
96477
+ lineHeight:40
96478
+ }).pos(50,0,LEFT,CENTER);
96479
+
96480
+ cam.bot();
96481
+
96482
+ });
96483
+ // if the user does not accept the browser asking about cam
96484
+ cam.on("error", ()=>{
96485
+ new Pane("CAM not accepted",yellow).show();
96486
+ });
96487
+ } else { // answered no to CamAsk dialog
96488
+ new Pane("CAM not accepted",yellow).show();
96489
+ }
96490
+ });
96491
+ END EXAMPLE
96492
+
95142
96493
  PARAMETERS
95143
96494
  ** supports DUO - parameters or single object with properties below
95144
96495
  width - (default 640) width of cam output - see also resetSize()
@@ -95175,6 +96526,57 @@ getCanvas() - caches the cam display and adds updateCache to a cam.canvasTicker
95175
96526
  for instance with computer vision libraries like ML5 or TenserFlow, etc.
95176
96527
  forgetCanvas() - turn off getCanvas() cam display cache and Ticker function
95177
96528
  dispose() - close the cam and remove events
96529
+ ** ML5 Hand Cursors **
96530
+ prepareTrack(width, height, hand, pinchColor, pinchHide, leftColor, rightColor, alpha, damp, gapTime, tapTime, cursorMode, toggleReplace)
96531
+ returns a ZIM Container with dots for hand index fingers, thumbs and pinches and adds properties and events
96532
+ Note: this is optional as it will be done with default values when using handTrack() - see below
96533
+ width and height (default W and H of stage) width and height of tracking area
96534
+ hand (default RIGHT) which hand or hands will be tracked - LEFT, BOTH or RIGHT
96535
+ the performance may be a bit better if one hand is track - to avoid the occassional cursor jump from one hand to the other
96536
+ also see the hand property to set the handedness at any time
96537
+ pinchColor (default white) - the color of the dot cursor when pinch is active - will be same for left or right hand
96538
+ pinchHide (default true) - reduce the alpha of finger and thumb dot cursors when pinching - set to false to not reduce the alpha
96539
+ leftColor (default green) the color of the left finger and thumb cursors
96540
+ rightColor (default blue) the color of the right finger and thumb cursors
96541
+ handScale (default 1) the scale of the finger and thumb cursor circles
96542
+ will affect hit area too for pinch
96543
+ may want to decrease scale if people are far from camera
96544
+ also see the handScale property to adjust dynamically - note the pinch cursor circle does not scale
96545
+ to scale the pinch cursor circle dynamically scale the cam leftPinch and rightPinch properties
96546
+ handAlpha (default .5) the alpha of all the dot cursors applied to the dots container
96547
+ to set this dynamically, just set the alpha of the cam dots property
96548
+ damp (default .5) the damp of the cursor movement - .01 is slow, 1 is no damp
96549
+ gapTime (default .5) seconds to wait (after cursor data reads no cursor) until the cursor is reported as up
96550
+ without this, over the several seconds an object is dragged with pinch, the dragging often gets cut off
96551
+ also see tapTime - for initial up report to handle taps
96552
+ note: the gapTime is in effect across the whole time a pinch is active
96553
+ tapTime (default .3) seconds that a cursor up will immediately reported with no gapTime
96554
+ if the pinch cursor is reported up within this time, then it is probably a tap pinch rather than a tap drag
96555
+ note: the tapTime is only measured from the beginning of the pinch
96556
+ cursorMode (default AUTO) if a hand is detected, AUTO will use the hand for interactivity rather than mouse and touch
96557
+ and if there is no hand detected, AUTO will use the mouse and touch for interactivity.
96558
+ Set to true to always use the hand and not the mouse and touch.
96559
+ Set to false to not replace the mouse or touch cursor
96560
+ in all cases, the hand cursors will show hand events will be dispatched
96561
+ when the hand cursor is used, cam.replaceCursor and zim.handCursor will be true
96562
+ when the mouse and touch are used, cam.replaceCursor and zim.handCursor will be false or undefined
96563
+ replaceCursor can be toggled by pinching the thumb and the pinky if the toggleReplace parameter is true
96564
+ also see the replaceCursor property
96565
+ toggleReplace (default true) set to false to not allow toggling of replaceCursor by pinching the thumb and pinky
96566
+ note: the replaceCursor property can still be used to toggle replacing the mouse and touch with a hand cursor
96567
+ handTrack(ML5results) process ML5 HandPose() results
96568
+ this will activate the prepareTrack() with default parameters if handTrack() is not specifically called
96569
+ the results, by default, will replace mouse and touch interactivity if a hand cursor is detected (AUTO)
96570
+ the hand cursor puts a dot at the index finger that will trigger mouseover, mousemove and mouseout
96571
+ and if the index finger and thumb are pinched will act like a mousedown that also activates pressmove
96572
+ and when pinch is released will act like a mouseup that also activates pressup, click and tap
96573
+ there is a hand property that can be tested or set to LEFT, RIGHT (default), or BOTH
96574
+ this will also dispatch events - see hand events below
96575
+ getDistance() - returns an object with left and right properties of the distance between the thumb and the index finger
96576
+ {left:0, right:200} left is probably not active and the right is 200 pixels between thumb and the the index finger
96577
+ getAngle() - returns an object with left and right properties of the angle between the thumb and the index finger
96578
+ the angle is 0 when pointing directly to the right and will be 90 when pointing down, 270 when pointing up, etc.
96579
+ {left:0, right:90} left is probably not active and the right has the thumb at top and finger below
95178
96580
 
95179
96581
  ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
95180
96582
  drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
@@ -95196,6 +96598,36 @@ paused - get or set whether the cam is paused (also see pause() and toggle())
95196
96598
  flipped - get or set whether the cam is mirrored (also see flip())
95197
96599
  facingMode - get which camera is being used - "user", "environment", etc. might be undefined
95198
96600
  see facingMode parameter and setFacingMode() method for more details
96601
+ ** ML5 Hand Cursors **
96602
+ cursorMode - gets and sets if the hand cursor replaces the mouse and touch
96603
+ default is AUTO can also be set to true or false
96604
+ see the cursorMode parameter of prepareTrack()
96605
+ replaceCursor - get or set if ML5 hand tracking is replacing the mouse and touch cursor
96606
+ must import ML5 and use prepareTrack() or handTrack()
96607
+ there is also a read only zim.handCursor property that reports the same as replaceCursor
96608
+ toggleReplace - get or set whether pinching thumb and pinky will toggle replaceCursor (see above)
96609
+ hand - get or set the LEFT, RIGHT (default), or BOTH setting of ML5 hand Cursors (see above)
96610
+ handScale - get or set the scale of the hand cursors - default is 1
96611
+ gapTime - get or set the gapTime - see gapTime parameter
96612
+ tapTime - get or set the tapTime - see tapTime parameter
96613
+ dots - the ZIM Container holding all the hand cursors
96614
+ leftFinger - the ZIM Circle that represents the left index finger - located inside the dots container
96615
+ also includes an active property that is true if active
96616
+ also includes dampX and dampY references to zim Damp object
96617
+ leftThumb - the ZIM Circle that represents the left thumb - located inside the dots container
96618
+ also includes dampX and dampY references to zim Damp object
96619
+ leftPinch - the ZIM Circle that represents the left pinch - located inside the dots container
96620
+ also includes an active property that is true if active
96621
+ also includes dampX and dampY references to zim Damp object
96622
+ rightFinger - the ZIM Circle that represents the right index finger - located inside the dots container
96623
+ also includes an active property that is true if active
96624
+ also includes dampX and dampY references to zim Damp object
96625
+ rightThumb - the ZIM Circle that represents the right thumb - located inside the dots container
96626
+ also includes dampX and dampY references to zim Damp object
96627
+ rightPinch - the ZIM Circle that represents the right pinch - located inside the dots container
96628
+ also includes an active property that is true if active
96629
+ also includes dampX and dampY references to zim Damp object
96630
+ pinchTicker - a reference to the Ticker that handles testing the pinches
95199
96631
 
95200
96632
  ALSO: see ZIM Container for properties such as:
95201
96633
  width, height, widthOnly, heightOnly, draggable, level, depth, group
@@ -95213,6 +96645,19 @@ See the CreateJS Easel Docs for Stage events, such as:
95213
96645
  mouseenter, mouseleave, stagemousedown, stagemousemove, stagemouseup, drawstart, drawend, etc.
95214
96646
  and all the Container events such as:
95215
96647
  click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
96648
+ ** ML5 Hand Cursor Events **
96649
+ distpaches a "handmove" event when hand cursor moves
96650
+ dispatches a "handdown" event when index finger and thumb are pinched
96651
+ dispatches a "handup" event when index finger and thumb are no longer pinched
96652
+ this will be immediate if within the tapTime time (default .3 seconds - see prepareTrack() method)
96653
+ this will be delayed by gapTime (default .5 seconds - see prepareTrack() method) if beyond the tapTime
96654
+ gapTime allows for more complete dragging of ZIM objects like slider buttons, general dragging, etc.
96655
+ note: the hand cursors will be removed right as the gapTime is started
96656
+ dispatches a "handon" when a hand cursor is shown - see
96657
+ dispatches a "handoff" when a hand cursor is hidden
96658
+ dispatches a "replaceon" event when hand cursor replaces mouse because thumb and pinky are pinched and toggleReplace is true
96659
+ dispatches a "replaceoff" event when hand cursor no longer replaces mouse because thumb and pinky are pinched and toggleReplace is true
96660
+
95216
96661
  --*///+142
95217
96662
 
95218
96663
  // THE CODE FOR THE CAM MODULE IS LINKED TO AT THE TOP OF THE DOCS
@@ -96231,6 +97676,7 @@ var globalFunctions = [
96231
97676
  ["zogr", zogr],
96232
97677
  ["zogy", zogy],
96233
97678
  ["zogo", zogo],
97679
+ ["zogs", zogs],
96234
97680
  ["zogl", zogl],
96235
97681
  ["zogd", zogd],
96236
97682
  ["zimplify", zimplify],
@@ -96252,6 +97698,7 @@ for (z_i = 0; z_i < globalFunctions.length; z_i++) {
96252
97698
  ["RIGHT", zim.RIGHT],
96253
97699
  ["CENTER", zim.CENTER],
96254
97700
  ["MIDDLE", zim.MIDDLE],
97701
+ ["JUSTIFY", zim.JUSTIFY],
96255
97702
  ["START", zim.START],
96256
97703
  ["END", zim.END],
96257
97704
  ["TOP", zim.TOP],
@@ -96463,6 +97910,7 @@ export let Organizer = zim.Organizer;
96463
97910
  export let Connectors = zim.Connectors;
96464
97911
  export let Marquee = zim.Marquee;
96465
97912
  export let Carousel = zim.Carousel;
97913
+ export let Carousel3D = zim.Carousel3D;
96466
97914
  export let Loader = zim.Loader;
96467
97915
  export let TextArea = zim.TextArea;
96468
97916
  export let localToGlobal = zim.localToGlobal;
@@ -96526,8 +97974,10 @@ export let removePhysics = zim.removePhysics;
96526
97974
  export let hitTestPoint = zim.hitTestPoint;
96527
97975
  export let hitTestReg = zim.hitTestReg;
96528
97976
  export let hitTestRect = zim.hitTestRect;
97977
+ export let hitTestRectPoint = zim.hitTestRectPoint;
96529
97978
  export let hitTestCircle = zim.hitTestCircle;
96530
97979
  export let hitTestCircleRect = zim.hitTestCircleRect;
97980
+ export let hitTestCirclePoint = zim.hitTestCirclePoint;
96531
97981
  export let hitTestCircles = zim.hitTestCircles;
96532
97982
  export let hitTestBounds = zim.hitTestBounds;
96533
97983
  export let hitTestPath = zim.hitTestPath;
@@ -96603,6 +98053,7 @@ export let Frame = zim.Frame;
96603
98053
  export let Pic = zim.Pic;
96604
98054
  export let Aud = zim.Aud;
96605
98055
  export let Vid = zim.Vid;
98056
+ export let Dat = zim.Dat;
96606
98057
  export let SVG = zim.SVG;
96607
98058
  export let Speech = zim.Speech;
96608
98059
  export let PermissionAsk = zim.PermissionAsk;
@@ -96628,3 +98079,4 @@ export let Style = zim.Style;
96628
98079
  export let assets = zim.assets;
96629
98080
  export let assetIDs = zim.assetIDs;
96630
98081
  export let ZIMON = zim.ZIMON;
98082
+