zimjs 17.3.3 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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(),
@@ -8258,10 +8260,34 @@ BitmapDataChannel.GREEN
8258
8260
  BitmapDataChannel.BLUE
8259
8261
 
8260
8262
  SEE:
8263
+ https://zimjs.com/zapp/Z_ADQEH - simple version
8261
8264
  https://zimjs.com/zapp/Z_X4PYD - coloring a Pic
8262
8265
  https://zimjs.com/zapp/Z_XMT78 - coloring a Tile
8263
8266
  https://github.com/u-kudox/BitmapData_for_EaselJS/tree/master/examples
8264
8267
 
8268
+ EXAMPLE
8269
+ // this is a shortened version of the examples below using internal code
8270
+ // the addBitmapData() will create take the current Bitmap and pass it to a BitmapData object
8271
+ // then take that BitmapData object and create a new Bitmap from the BitmapData
8272
+ // this is then returned by the addBitmapData()
8273
+ // the color() then applies a floodFill() internally saving a half dozen lines of code
8274
+ const assets = "ai_coloring_groovy.png";
8275
+ const path = "https://zimjs.org/assets/";
8276
+ new Frame(FIT, 1481, 745, light, dark, ready, assets, path);
8277
+ function ready() {
8278
+ const pic = new Pic("ai_coloring_groovy.png");
8279
+ const bitmap = new Bitmap(pic)
8280
+ .addBitmapData()
8281
+ .scaleTo()
8282
+ .cur()
8283
+ .center();
8284
+ const color = series(red, orange, blue, green, yellow);
8285
+ bitmap.on("mousedown", ()=>{
8286
+ bitmap.color(color); // or get from ColorPicker()
8287
+ S.update();
8288
+ });
8289
+ }
8290
+ END EXAMPLE
8265
8291
 
8266
8292
  EXAMPLE
8267
8293
  // coloring a pic with floodFill()
@@ -10640,6 +10666,26 @@ function ready() {
10640
10666
  }
10641
10667
  END EXAMPLE
10642
10668
 
10669
+ EXAMPLE
10670
+ // https://zimjs.com/zapp/Z_ADQEH - coloring a Bitmap pic
10671
+ const assets = "ai_coloring_groovy.png";
10672
+ const path = "https://zimjs.org/assets/";
10673
+ new Frame(FIT, 1481, 745, light, dark, ready, assets, path);
10674
+ function ready() {
10675
+ const pic = new Pic("ai_coloring_groovy.png");
10676
+ const bitmap = new Bitmap(pic)
10677
+ .addBitmapData()
10678
+ .scaleTo()
10679
+ .cur()
10680
+ .center();
10681
+ const color = series(red, orange, blue, green, yellow);
10682
+ bitmap.on("mousedown", ()=>{
10683
+ bitmap.color(color); // or get from ColorPicker()
10684
+ S.update();
10685
+ });
10686
+ }
10687
+ END EXAMPLE
10688
+
10643
10689
  EXAMPLE
10644
10690
  // turn a container of circles into a Bitmap
10645
10691
  const circles = new Container(W, H).addTo();
@@ -10746,11 +10792,23 @@ group - (default null) set to String (or comma delimited String) so STYLE can se
10746
10792
  inherit - (default null) used internally but can receive an {} of styles directly
10747
10793
 
10748
10794
  METHODS
10795
+ addBitmapData() - returns a new Bitmap of the original but with the CreateJS BitmapData class added as a bitmapData property
10796
+ see https://zimjs.com/docs.html?item=BitmapData
10797
+ color(color, thresholdColor, x, y) - color a Bitmap. The Bitmap must be made with addBitmapData() - or have equivilant adjustments applied.
10798
+ color - |ZIM VEE| (default red) is the color to do a BitmapData floodFill() - it will automatically be converted to the right color format
10799
+ thresholdColor (default dark) is the color for which darker colors will not be colored allowing dark lines to separate coloring areas
10800
+ x and y (default F.mouseX and F.mouseY relative to the Bitmap) an x and y inside the Bitmap coordinates to apply BitmapData floodFill()
10749
10801
  keyOut(color, tolerance, replacement) - remove color from Bitmap and a tolerance between 0-1
10750
10802
  the default color is "#389b26" which is a medium dark green
10751
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
10752
10804
  color and tolerance can be an array of colors and tolerances (or just one tolerance if all are the same)
10753
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
10754
10812
  fromData(data, callback) - STATIC method so use the Bitmap class directly: Bitmap.fromData()
10755
10813
  The callback will receive a reference to the Bitmap after 50ms or 100ms.
10756
10814
  There is no event for making a Bitmap from base64 for instance - so this will have to do.
@@ -10815,6 +10873,8 @@ imageData - data for the pixels stored in a data property of an ImageData object
10815
10873
  eg. 0,0,0,255,255,255,255,255 is a black pixel with 1 alpha and a white pixel with 1 alpha
10816
10874
  You set this before calling the Bitmap drawImageData() method
10817
10875
  See also https://developer.mozilla.org/en-US/docs/Web/API/ImageData - but let ZIM do the work
10876
+ bitmapData - if a Bitmap is created with addBitmapData() then a bitmapData property is added to reference its CreateJS BitmpaData object
10877
+ see https://zimjs.com/docs.html?item=BitmapData
10818
10878
  group - used when the object is made to add STYLE with the group selector (like a CSS class)
10819
10879
  ** bounds must be set first (or width and height parameters set) for these to work
10820
10880
  ** setting these adjusts scale not bounds and getting these uses the bounds dimension times the scale
@@ -11093,10 +11153,144 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
11093
11153
  }
11094
11154
  }
11095
11155
  myContext.putImageData(info,top,left);
11096
- // that.updateCache()
11097
11156
  return this;
11098
11157
  }
11099
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
+
11254
+ this.addBitmapData = function() {
11255
+ if (!createjs.BitmapData) {
11256
+ zogy("zim.Bitmap addBitmapData() needs CreatejS 1.5.0 or greater"); return that;
11257
+ }
11258
+ var cc = that.cacheCanvas?that.cacheCanvas:that.cache().cacheCanvas;
11259
+ var bitmapData = new createjs.BitmapData(cc);
11260
+ var bbd = new zim.Bitmap(bitmapData.canvas);
11261
+ bbd.bitmapData = bitmapData;
11262
+ return bbd;
11263
+ }
11264
+
11265
+ this.color = function(color, thresholdColor, x, y) {
11266
+ if (!that.stage) return;
11267
+ if (!that.bitmapData) {
11268
+ zogy("zim.Bitmap must be made with addBitmapData() to use color()"); return that;
11269
+ }
11270
+ if (zot(color)) color = red;
11271
+ color = zik(color);
11272
+ if (zot(thresholdColor)) thresholdColor = dark;
11273
+ var F = that.stage.frame?that.stage.frame:zdf;
11274
+ // convert our mouse point to a point on the bitmap
11275
+ var point;
11276
+ if (x!=null && y!=null) {
11277
+ point = {x:x, y:y};
11278
+ } else {
11279
+ point = that.globalToLocal(F.mouseX, F.mouseY);
11280
+ }
11281
+ // avoid pressing on the same color or the border color
11282
+ var currentColor = this.bitmapData.getPixel(point.x, point.y);
11283
+ if (
11284
+ currentColor == zim.convertColor(color, 'hexnumber') ||
11285
+ currentColor < zim.convertColor(thresholdColor, "hexnumber") // towards black
11286
+ ) return;
11287
+ // get the colorPicker color as hexstring - needed for floodFill
11288
+ var newColor = zim.convertColor(color, 'hexstring');
11289
+ // do a floodFill from the point with the new color
11290
+ that.bitmapData.floodFill(point.x, point.y, newColor);
11291
+ return that;
11292
+ }
11293
+
11100
11294
  zim.displayBase(that);
11101
11295
 
11102
11296
  if (style!==false) zim.styleTransforms(this, DS); // global function - would have put on DisplayObject if had access to it
@@ -12018,8 +12212,12 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
12018
12212
  var a = that.animations[label];
12019
12213
  processAnimation(a);
12020
12214
  }
12021
- function processAnimation(a) {
12215
+ function processAnimation(a) {
12022
12216
  if (Array.isArray(a)) {
12217
+ if (a.length==1) {
12218
+ processAnimation(a[0]);
12219
+ return;
12220
+ }
12023
12221
  processArray(a);
12024
12222
  } else if (a.constructor == {}.constructor) {
12025
12223
  processObject(a);
@@ -12084,6 +12282,8 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
12084
12282
  var sig = "time, label, call, params, wait, waitedCall, waitedParams, loop, loopCount, loopWait, loopCall, loopParams, loopWaitCall, loopWaitParams, loopPick, rewind, rewindWait, rewindCall, rewindParams, rewindWaitCall, rewindWaitParams, rewindTime, rewindEase, startFrame, endFrame, frame, tweek, id, globalControl, pauseOnBlur";
12085
12283
  var duo; if (duo = zob(that.run, arguments, sig)) return duo;
12086
12284
 
12285
+ if (that.running) that.stopAnimate(that.id); // ZIM 017 - moved this up so single frame stops previous animation
12286
+
12087
12287
  var timeType = getTIME();
12088
12288
 
12089
12289
  var obj;
@@ -12097,8 +12297,10 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
12097
12297
  return that; // just go to the frame ZIM 017
12098
12298
  }
12099
12299
 
12300
+ that.running = true; // not calling a single frame a run - as it does not animate - ZIM 017
12301
+
12100
12302
  var extraTime;
12101
- if (Array.isArray(label)) {
12303
+ if (Array.isArray(label)) {
12102
12304
  // check labels
12103
12305
  var innerLabel;
12104
12306
  var lastLabel;
@@ -12130,7 +12332,7 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
12130
12332
  if (endFrame-startFrame > 0) extraTime = tt / (endFrame-startFrame) / 2; // slight cludge - seems to look better?
12131
12333
 
12132
12334
  // if (i==0) firstStartFrame = startFrame;
12133
- }
12335
+ }
12134
12336
  //startFrame = firstStartFrame;
12135
12337
  if (obj.length == 0) return this;
12136
12338
  if (obj.length == 1) { // just one label in list ;-)
@@ -12142,7 +12344,7 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
12142
12344
  }
12143
12345
  } else { // single label
12144
12346
  setSingle();
12145
- }
12347
+ }
12146
12348
 
12147
12349
  function setSingle() {
12148
12350
  _normalizedFrames = that.parseFrames(label, startFrame, endFrame);
@@ -12153,9 +12355,7 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
12153
12355
  }
12154
12356
 
12155
12357
  if (zot(time)) time = timeType=="s"?1:1000;
12156
- // if already running the sprite then stop the last run
12157
- if (that.running) that.stopAnimate(that.id);
12158
- that.running = true;
12358
+
12159
12359
 
12160
12360
  if (!Array.isArray(obj)) {
12161
12361
  extraTime = 0;
@@ -18281,7 +18481,7 @@ Note the points property has been split into points and pointObjects (and there
18281
18481
  that.lastSelected = that.lastindex = null;
18282
18482
  }
18283
18483
  }
18284
- that.controls.hold(removeControl);
18484
+ if (that.editPoints) that.controls.hold(removeControl);
18285
18485
 
18286
18486
  if (!_controls) that.hideControls();
18287
18487
  that.dispatchEvent("update");
@@ -20584,7 +20784,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
20584
20784
  that.lastSelected = that.lastindex = null;
20585
20785
  }
20586
20786
  }
20587
- that.controls.hold(removeControl);
20787
+ if (that.editPoints) that.controls.hold(removeControl);
20588
20788
 
20589
20789
  if (!_controls) that.hideControls();
20590
20790
  that.dispatchEvent("update");
@@ -22797,7 +22997,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
22797
22997
  );
22798
22998
  if (italic) that.background.ske(10);
22799
22999
  zim.center(that.background, that, 0);
22800
- 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);
22801
23001
  }
22802
23002
 
22803
23003
  function setSize() {
@@ -22873,7 +23073,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
22873
23073
 
22874
23074
  function setBackBounds() {
22875
23075
  var bb = backing.boundsToGlobal();
22876
- var bbb = that.boundsToGlobal(bb, true);
23076
+ var bbb = that.boundsToGlobal(bb, true);
22877
23077
  that.setBounds(bbb.x, bbb.y, bbb.width, bbb.height);
22878
23078
  }
22879
23079
 
@@ -23363,6 +23563,7 @@ zim.LabelOnPath = function(label, path, percentAngle, percents, showPath, allowT
23363
23563
 
23364
23564
  path.addTo(this);
23365
23565
  var that = this;
23566
+ this.label = label;
23366
23567
  this.path = path;
23367
23568
  this.allowToggle = allowToggle;
23368
23569
  path.interactive = interactive;
@@ -23524,7 +23725,7 @@ zim.LabelOnPath = function(label, path, percentAngle, percents, showPath, allowT
23524
23725
  if (showPath) that.toggle(true);
23525
23726
 
23526
23727
  if (style!==false) zim.styleTransforms(this, DS);
23527
- this.clone = function() {
23728
+ this.clone = function() {
23528
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));
23529
23730
  };
23530
23731
  this.dispose = function(a,b,disposing) {
@@ -23795,7 +23996,7 @@ zim.extend(zim.LabelOnArc, zim.Container, "clone", "zimContainer", false);
23795
23996
  //-54.55
23796
23997
 
23797
23998
  /*--
23798
- zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, style, group, inherit)
23999
+ zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, lineWidth, lineAlignLast, style, group, inherit)
23799
24000
 
23800
24001
  LabelLetters
23801
24002
  zim class - extends a zim.Container which extends a createjs.Container
@@ -23843,6 +24044,7 @@ label - (default "Label Letters") a String or a ZIM Label
23843
24044
  <i>italic</i> - or <em>italic</em>
23844
24045
  <u>underline</u> - can use this with <a> to make a classic underlined link
23845
24046
  <a href=url target=_blank>link</a>
24047
+ <br> - for a break or use \n
23846
24048
  <font
23847
24049
  color=zimColor
23848
24050
  backgroundColor='htmlColor'
@@ -23868,11 +24070,15 @@ lineSpacing - (default 5) - the space between lines (not including lineHeight)
23868
24070
  lineSpacings - (default null) - an array of the space between lines
23869
24071
  any values here will override the lineSpacing
23870
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
23871
- 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
23872
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
23873
24076
  lineValign - (default BOTTOM) the vertical alignment within lineSpacing if multiple lines - set to TOP, CENTER/MIDDLE, BOTTOM
23874
24077
  cache - (default false) set to true to cache each letter - improves performance on animation
23875
24078
  rtl - (default false) set to true to reverse letters other than a-zA-Z0-9 and set default lineAlign to RIGHT
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
23876
24082
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
23877
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)
23878
24084
  inherit - (default null) used internally but can receive an {} of styles directly
@@ -23897,6 +24103,7 @@ type - the name of the class as a String
23897
24103
  text - get or set the text
23898
24104
  labels - an array of ZIM Label objects for the letters
23899
24105
  numLetters - how many letters (same as numChildren)
24106
+ lineWidth - get or set the line width - could cause wrapping
23900
24107
 
23901
24108
  ALSO: see ZIM Container for properties such as:
23902
24109
  width, height, widthOnly, heightOnly, draggable, level, depth, group
@@ -23911,8 +24118,8 @@ See the CreateJS Easel Docs for Container events such as:
23911
24118
  added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
23912
24119
  --*///+54.57
23913
24120
 
23914
- zim.LabelLetters = function(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, style, group, inherit) {
23915
- var sig = "label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, 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";
23916
24123
  var duo; if (duo = zob(zim.LabelLetters, arguments, sig, this)) return duo;
23917
24124
  z_d("54.57");
23918
24125
 
@@ -23930,6 +24137,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
23930
24137
  if (zot(rtl)) rtl = DS.rtl != null ? DS.rtl : false;
23931
24138
  if (zot(lineAlign)) lineAlign = DS.lineAlign != null ? DS.lineAlign : rtl?"right":"left";
23932
24139
  if (zot(lineValign)) lineValign = DS.lineValign != null ? DS.lineValign : "bottom";
24140
+ if (zot(lineWidth)) lineWidth = DS.lineWidth != null ? DS.lineWidth : "bottom";
24141
+ if (zot(lineAlignLast)) lineAlignLast = DS.lineAlignLast != null ? DS.lineAlignLast : rtl?"right":"left";
23933
24142
  if (zot(cache)) cache = DS.cache != null ? DS.cache : false;
23934
24143
 
23935
24144
  this.zimContainer_constructor(null, null, null, null, false);
@@ -23946,7 +24155,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
23946
24155
  if (label.type != "Label") {
23947
24156
  data = parseHTML(label); // returns {text:text, data:data}
23948
24157
  letterData = data.data;
23949
- label = new zim.Label(data.text);
24158
+ label = new zim.Label({text:data.text, paddingH:letterSpacing/2, paddingV:2});
23950
24159
  } else {
23951
24160
  data = parseHTML(label.text);
23952
24161
  letterData = data.data;
@@ -23974,28 +24183,28 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
23974
24183
  // html = "!Roger הגיע בשבילך משהו בדואר Dan אני לומד עברית";
23975
24184
  // html = "הגיע בשבילך משהו בדואר.";
23976
24185
 
23977
- function insert(data) {
23978
- return data.split("").reverse().join("")
23979
- }
23980
- if (rtl) {
23981
- count = -1;
23982
- html = html.replace(/[\u0591-\u07FF]+/ig, insert);
24186
+ // function insert(data) {
24187
+ // return data.split("").reverse().join("")
24188
+ // }
24189
+ // if (rtl) {
24190
+ // count = -1;
24191
+ // html = html.replace(/[\u0591-\u07FF]+/ig, insert);
23983
24192
 
23984
- // and there may be tags or LTR characters next to RTL without a space:
23985
- html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
23986
- html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space
23987
- html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
23988
- html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
24193
+ // // and there may be tags or LTR characters next to RTL without a space:
24194
+ // html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
24195
+ // html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space
24196
+ // html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
24197
+ // html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
23989
24198
 
23990
- var sp = html.split(/-!!-/g);
23991
- zim.loop(sp, function(ssp, i){
23992
- if (ssp.match(/[\u0591-\u07FF]/i)) {
23993
- sp[i] = ssp.split(" ").reverse().join(" ");
23994
- }
23995
- });
23996
- html = sp.join("");
23997
- }
23998
-
24199
+ // var sp = html.split(/-!!-/g);
24200
+ // zim.loop(sp, function(ssp, i){
24201
+ // if (ssp.match(/[\u0591-\u07FF]/i)) {
24202
+ // sp[i] = ssp.split(" ").reverse().join(" ");
24203
+ // }
24204
+ // });
24205
+ // html = sp.join("");
24206
+ // }
24207
+
23999
24208
 
24000
24209
  // normalize tags
24001
24210
  html = html.replace(/\n|\r/g,"<br>");
@@ -24091,7 +24300,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24091
24300
  // b,i,u,br,a,font
24092
24301
  // var da = [,, [["b","i"]] ,[,["b"]],,,[["br","font color=red size=10 family=courier"]],["i"]],...];
24093
24302
  return {text:p, data:data, original:original};
24094
- }
24303
+
24304
+ } // end parse html
24305
+
24095
24306
 
24096
24307
  that.numLetters = label.text.length;
24097
24308
 
@@ -24249,7 +24460,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24249
24460
  letter = label.clone();
24250
24461
  letter.text = label.text[i];
24251
24462
  }
24252
- that.labels.push(letter);
24463
+ that.labels.push(letter);
24464
+ var b = letter.getBounds();
24253
24465
 
24254
24466
  if (bCheck) letter.bold = true;
24255
24467
  if (iCheck) letter.italic = true;
@@ -24309,7 +24521,22 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24309
24521
  lineNum++;
24310
24522
  }
24311
24523
 
24312
- lineW += letter.width + s;
24524
+ lineW += letter.width - b.x + s;
24525
+
24526
+ // if (lineW > lineWidth && letter.text == " ") {
24527
+ // lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
24528
+ // linePositionsY.push(lineY);
24529
+ // lineHeights.push(zot(lineHeight)?lineH:lineHeight);
24530
+ // lineWidths.push(lineW);
24531
+ // maxW = Math.max(maxW, lineW);
24532
+ // lineH = 0;
24533
+ // lineW = 0;
24534
+ // that.lines.push([]);
24535
+ // lineNum++;
24536
+ // letter.dispose();
24537
+ // continue;
24538
+ // }
24539
+
24313
24540
  lineH = Math.max(lineH, letter.height);
24314
24541
 
24315
24542
  if (i==that.numLetters-1) {
@@ -24328,52 +24555,228 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24328
24555
 
24329
24556
 
24330
24557
  // LOOP THROUGH LINES AND APPLY POSITIONS
24331
- var count = 0;
24332
- for (var j=0; j<that.lines.length; j++) {
24333
- var ll = that.lines[j];
24334
- lineW = lineWidths[j];
24335
- lineH = lineHeights[j];
24336
- lineY = linePositionsY[j];
24337
-
24338
- var startX, startY;
24339
- if (lineAlign=="left") startX = 0;
24340
- else if (lineAlign=="right") startX = maxW-lineW;
24341
- else startX = (maxW-lineW)/2;
24342
- startY = lineY;
24343
-
24344
- for (i=0; i<ll.length; i++) {
24345
- count++;
24346
- if (cache) letter.cache();
24347
- letter = ll[i];
24348
- letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
24349
- letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
24558
+ function doPositions(second) {
24559
+ var count = 0;
24560
+
24561
+ for (var j=0; j<that.lines.length; j++) {
24562
+ var ll = that.lines[j];
24563
+ if (rtl) ll.reverse(); // ZIM 017 PATCH
24564
+ lineW = lineWidths[j];
24565
+ lineH = lineHeights[j];
24566
+ lineY = linePositionsY[j];
24567
+ var numSpaces=0;
24568
+
24569
+ var startX, startY;
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
24572
+ else if (lineAlign=="right") startX = maxW-lineW;
24573
+ else startX = (maxW-lineW)/2;
24574
+ startY = lineY;
24575
+
24576
+ for (i=0; i<ll.length; i++) {
24577
+ count++;
24578
+ if (cache) letter.cache();
24579
+ letter = ll[i];
24580
+
24581
+ if (letter.text == " ") numSpaces++;
24582
+ letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
24583
+ letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
24584
+
24585
+ var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
24586
+ if (lineValign=="center" || lineValign=="middle") {
24587
+ sY += (lineHeights[j]-letter.height)/2;
24588
+ } else if (lineValign=="bottom") {
24589
+ sY += lineHeights[j]-letter.height;
24590
+ }
24591
+ s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
24592
+ if (align=="left") {
24593
+ letter.loc(startX, sY, that);
24594
+ startX = letter.x+letter.width+s;
24595
+ } else if (align=="right") {
24596
+ letter.loc(startX+letter.width, sY, that);
24597
+ startX = letter.x+s;
24598
+ } else {
24599
+ letter.loc(startX+letter.width/2, sY, that);
24600
+ startX = letter.x+letter.width/2+s;
24601
+ }
24602
+
24603
+ if (letter.backgroundColor) {
24604
+ letter.mov(0,-letter.getBounds().y*2)
24605
+ }
24606
+
24607
+ } // end lines letters
24608
+
24609
+
24610
+ if (lineWidth > 0 && lineAlign=="justify" && second && numSpaces && (j!=that.lines.length-1 || lineAlignLast=="justify")) {
24350
24611
 
24351
- var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
24352
- if (lineValign=="center" || lineValign=="middle") {
24353
- sY += (lineHeights[j]-letter.height)/2;
24354
- } else if (lineValign=="bottom") {
24355
- sY += lineHeights[j]-letter.height;
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
+
24356
24622
  }
24357
- s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
24358
- if (align=="left") {
24359
- letter.loc(startX, sY, that);
24360
- startX = letter.x+letter.width+s;
24361
- } else if (align=="right") {
24362
- letter.loc(startX+letter.width, sY, that);
24363
- startX = letter.x+s;
24364
- } else {
24365
- letter.loc(startX+letter.width/2, sY, that);
24366
- startX = letter.x+letter.width/2+s;
24623
+
24624
+ } // end lines
24625
+ }
24626
+ doPositions();
24627
+
24628
+
24629
+ if (lineWidth > 0) {
24630
+ var lines = [];
24631
+ var letters = [];
24632
+ var lastSpace;
24633
+ var row = 0;
24634
+
24635
+ if (rtl) {
24636
+
24637
+ for (var j=0; j<that.lines.length; j++) {
24638
+ var list = that.lines[j];
24639
+ var count = 0;
24640
+ var back = 0;
24641
+ lines[row] = [];
24642
+ letters[row] = [];
24643
+ lastSpace = null;
24644
+
24645
+ var startX = list[list.length-1].x;
24646
+
24647
+ for (var i=list.length-1; i>=0; i--) {
24648
+ var letter = list[i];
24649
+ letter.mov(back);
24650
+ lines[row].push(letter);
24651
+ letters[row].push(letter.text)
24652
+ if (startX-letter.x > lineWidth) {
24653
+ if (letter.text == " ") {
24654
+ lines[row].pop();
24655
+ letters[row].pop();
24656
+ row++;
24657
+ back += letter.x+letterSpacing;
24658
+ letter.dispose();
24659
+ lines[row] = [];
24660
+ letters[row] = [];
24661
+ lastSpace = null;
24662
+ count = -1;
24663
+ } else if (lastSpace > 0) {
24664
+ var move = lines[row].splice(lastSpace);
24665
+ var move2 = letters[row].splice(lastSpace);
24666
+ row++;
24667
+ var space = move.shift(); // remove space from start
24668
+ move2.shift();
24669
+ for (var k=0; k<move.length; k++) {
24670
+ move[k].mov(startX-space.x-letterSpacing);
24671
+ }
24672
+ back += startX-(space.x+letterSpacing);
24673
+ space.dispose();
24674
+ lines[row] = move;
24675
+ letters[row] = move2;
24676
+ lastSpace = null;
24677
+ count = lines[row].length-1;
24678
+ }
24679
+ }
24680
+ if (letter.text == " ") lastSpace = count;
24681
+ count++;
24682
+ }
24683
+ row++
24367
24684
  }
24368
-
24369
- } // end lines letters
24370
- } // end lines
24685
+
24686
+
24687
+ } else {
24688
+
24689
+ for (var j=0; j<that.lines.length; j++) {
24690
+ var list = that.lines[j];
24691
+ var count = 0;
24692
+ var back = 0;
24693
+ lines[row] = [];
24694
+ letters[row] = [];
24695
+ lastSpace = null;
24696
+ for (var i=0; i<list.length; i++) {
24697
+ var letter = list[i];
24698
+ letter.mov(-back);
24699
+ lines[row].push(letter);
24700
+ letters[row].push(letter.text)
24701
+ if (letter.x + letter.width > lineWidth) {
24702
+ if (letter.text == " ") {
24703
+ lines[row].pop();
24704
+ letters[row].pop();
24705
+ row++;
24706
+ back += letter.x+letterSpacing;
24707
+ letter.dispose();
24708
+ lines[row] = [];
24709
+ letters[row] = [];
24710
+ lastSpace = null;
24711
+ count = -1;
24712
+ } else if (lastSpace > 0) {
24713
+ var move = lines[row].splice(lastSpace);
24714
+ var move2 = letters[row].splice(lastSpace);
24715
+ row++;
24716
+ var space = move.shift(); // remove space from start
24717
+ move2.shift();
24718
+ for (var k=0; k<move.length; k++) {
24719
+ move[k].mov(-space.x-letterSpacing);
24720
+ }
24721
+ back += space.x+letterSpacing;
24722
+ space.dispose();
24723
+ lines[row] = move;
24724
+ letters[row] = move2;
24725
+ lastSpace = null;
24726
+ count = lines[row].length-1;
24727
+ }
24728
+ }
24729
+ if (letter.text == " ") lastSpace = count;
24730
+ count++;
24731
+
24732
+ }
24733
+ row++
24734
+ }
24735
+
24736
+ }
24737
+
24738
+
24739
+ that.lines = lines;
24740
+ lineWidths = [];
24741
+ lineHeights = [];
24742
+ linePositionsY = [];
24743
+ maxW = lineWidth;
24744
+
24745
+ var currentHeight = 0;
24746
+ var lastMaxHeight = 0;
24747
+
24748
+ for (j=0; j<that.lines.length; j++) {
24749
+ var maxHeight = 0;
24750
+ var totalW = 0;
24751
+ var list = that.lines[j];
24752
+ for (i=0; i<list.length; i++) {
24753
+ var letter = list[i];
24754
+ var b = letter.getBounds();
24755
+ totalW += letter.width + b.x*2 + letterSpacing;
24756
+ if (letter.height > maxHeight) maxHeight = letter.height;
24757
+ }
24758
+ if (list.length==0) maxHeight = lastMaxHeight;
24759
+ lineWidths[j] = totalW-letterSpacing;
24760
+ lineHeights[j] = maxHeight;
24761
+ linePositionsY[j] = currentHeight;
24762
+ currentHeight += maxHeight + lineSpacing;
24763
+ lastMaxHeight = maxHeight;
24764
+ totalW = 0;
24765
+ }
24766
+
24767
+ doPositions(true); // second time for real
24768
+
24769
+
24770
+ } // end line width
24371
24771
 
24372
- if (!that.getBounds()) that.setBounds(0,0,0,0);
24373
- that.regX = that.getBounds().x;
24374
- that.regY = that.getBounds().y;
24772
+ var bou = that.getBounds();
24773
+ if (!bou) that.setBounds(0,0,0,0);
24774
+ if (lineWidth>0) that.setBounds(0,0,lineWidth,bou.height);
24775
+ bou = that.getBounds();
24776
+ that.regX = bou.x;
24777
+ that.regY = bou.y;
24375
24778
 
24376
- }
24779
+ } // end make
24377
24780
 
24378
24781
  make();
24379
24782
 
@@ -24423,6 +24826,16 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24423
24826
  }
24424
24827
  });
24425
24828
 
24829
+ Object.defineProperty(this, 'lineWidth', {
24830
+ get: function () {
24831
+ return lineWidth;
24832
+ },
24833
+ set: function (value) {
24834
+ lineWidth = value;
24835
+ make();
24836
+ }
24837
+ });
24838
+
24426
24839
  this.dispose = function() {
24427
24840
  zim.gD(this); // globalDispose function for common elements
24428
24841
  zim.loop(that.labels, function (letter) {
@@ -24434,7 +24847,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24434
24847
 
24435
24848
  if (style!==false) zim.styleTransforms(this, DS);
24436
24849
  this.clone = function () {
24437
- return that.cloneProps(new zim.LabelLetters(label, align, valign, letterSpacing, letterSpacings, lineSpacing, lineSpacings, lineHeight, lineAlign, lineValign, cache, rtl, 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));
24438
24851
  };
24439
24852
 
24440
24853
  };
@@ -24610,7 +25023,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24610
25023
  if (zot(spacingH)) spacingH = DS.spacingH != null ? DS.spacingH : size/2;
24611
25024
  if (zot(spacingV)) spacingV = DS.spacingV != null ? DS.spacingV : size/2;
24612
25025
 
24613
- var that = this;
25026
+ var that = this;
24614
25027
 
24615
25028
  function make(label) {
24616
25029
  var sentence;
@@ -24634,7 +25047,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24634
25047
  make(label);
24635
25048
 
24636
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);
24637
-
25050
+ this.type = "LabelWords";
25051
+
24638
25052
  Object.defineProperty(this, 'text', {
24639
25053
  get: function () {
24640
25054
  return this._text;
@@ -28258,8 +28672,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28258
28672
  }
28259
28673
 
28260
28674
  if (style !== false) zim.styleTransforms(this, DS);
28675
+
28261
28676
  this.clone = function () {
28262
- 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));
28263
28678
  };
28264
28679
  this.doDispose = function(a,b,disposing) {
28265
28680
  // need to dispose properly for Panel
@@ -28626,6 +29041,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28626
29041
 
28627
29042
  if (content) var myContent = that.content = content;
28628
29043
  content = this.contentContainer = new zim.Container({style:false});
29044
+ content.oob = true;
28629
29045
  this.addChild(content);
28630
29046
  content.mask = mask;
28631
29047
  var stage;
@@ -28906,7 +29322,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28906
29322
  if (zot(titleBarBackgroundColor)) titleBarBackgroundColor = "rgba(0,0,0,.2)";
28907
29323
  that.titleBar = titleBar = new zim.Container(width, titleBarHeight, null, null, false).centerReg(that).mov(0,-height/2-titleBarHeight/2);
28908
29324
  var titleBarMask = new zim.Rectangle(titleBar.width-1, titleBar.height, red).alp(0).addTo(titleBar);
28909
- // titleBarLabel.setMask(titleBarMask, true);
29325
+ titleBarLabel.setMask(titleBarMask, true);
28910
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);
28911
29327
  titleBarLabel.center(titleBar).pos({x:Math.max(corner/2, Math.max(10, padding)), reg:true});
28912
29328
  that.regX = 0; that.regY = -titleBarHeight;
@@ -28923,6 +29339,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28923
29339
  } else {
28924
29340
  titleBar.on("mousedown", function () {});
28925
29341
  }
29342
+
28926
29343
 
28927
29344
  }
28928
29345
 
@@ -29157,7 +29574,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29157
29574
  var duo; if (duo = zob(that.add, arguments, sig, that)) return duo;
29158
29575
 
29159
29576
  var c = obj;
29160
- 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;}
29161
29578
  makeDamp(c);
29162
29579
  if (zot(index)) index = content.numChildren;
29163
29580
  if (replace) {
@@ -29273,7 +29690,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29273
29690
  if (zot(delay)) delay = 100;
29274
29691
  makeDamp(that);
29275
29692
  if (!swipe) return;
29276
- setTimeout(function(){
29693
+ setTimeout(function(){
29694
+ if (!that.enabled) return;
29277
29695
  if (content) {
29278
29696
  zim.drag({
29279
29697
  singleTouch:true,
@@ -29284,7 +29702,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29284
29702
  slide:slide,
29285
29703
  slideFactor:slideFactor,
29286
29704
  slideSnap:(scrollBarH && (swipe===true||swipe=="auto"||swipe=="horizontal")) || (scrollBarV && (swipe===true||swipe=="auto"||swipe=="vertical"))?slideSnap:false
29287
- });
29705
+ });
29288
29706
  content.removeAllEventListeners("slidestart");
29289
29707
  content.on("slidestart", function () {
29290
29708
  that.dispatchEvent("slidestart");
@@ -29311,7 +29729,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29311
29729
  content.on("slidestop", function (e) {
29312
29730
  if (slide) stageUp(e);
29313
29731
  that.dispatchEvent("slidestop");
29314
- });
29732
+ });
29733
+
29315
29734
  if (content.getBounds() && content.getBounds().width > 0) {
29316
29735
  setdragBoundary();
29317
29736
  }
@@ -29511,7 +29930,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29511
29930
  setTimeout(function() {
29512
29931
  lastReadOnly = that.readOnly;
29513
29932
  },50);
29514
- Object.defineProperty(that, 'enabled', {
29933
+ Object.defineProperty(that, 'enabled', {
29515
29934
  get: function() {
29516
29935
  return that._enabled;
29517
29936
  },
@@ -29698,7 +30117,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29698
30117
  //-58.1
29699
30118
 
29700
30119
  /*--
29701
- 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)
29702
30121
 
29703
30122
  Page
29704
30123
  zim class - extends a zim.Container which extends a createjs.Container
@@ -29742,6 +30161,7 @@ height - (default zimDefaultFrame.height) the height of the Page
29742
30161
  color - |ZIM VEE| (default zim.light) the color of the page
29743
30162
  color2 - |ZIM VEE| (default null) a second color which would form a zim.GradientColor() as the color
29744
30163
  angle - (default 90) the angle for the gradient if there is a gradient
30164
+ corner
29745
30165
  pattern - (default null) a DisplayObject that will be added to the page above the backing
29746
30166
  For instance, import zim_pizzazz and use:
29747
30167
  makePattern("slants", series(grey,dark), 20, 52, 40).alp(.2)
@@ -29750,6 +30170,8 @@ scalePattern - (default "fill") scale the pattern so it fills the window (former
29750
30170
  FIT or "fit" fits inside the Page keeping proportion (formerly "smallest")
29751
30171
  FILL or "fill" fills the Page keeping proportion (formerly "biggest" or "outside")
29752
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
29753
30175
  cache - (default false or true for gradient or pattern) whether the backing and pattern is cached
29754
30176
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
29755
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)
@@ -29785,8 +30207,8 @@ EVENTS
29785
30207
  See the CreateJS Easel Docs for Container events such as:
29786
30208
  added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
29787
30209
  --*///+58.3
29788
- zim.Page = function(width, height, color, color2, angle, pattern, scalePattern, cache, style, group, inherit) {
29789
- 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";
29790
30212
  var duo; if (duo = zob(zim.Page, arguments, sig, this)) return duo;
29791
30213
  z_d("58.3");
29792
30214
 
@@ -29806,9 +30228,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29806
30228
  if (zot(angle)) angle=DS.angle!=null?DS.angle:90;
29807
30229
  if (zot(color)) color=DS.color!=null?DS.color:zim.light;
29808
30230
  if (zot(color2)) color2=DS.color2!=null?DS.color2:null;
30231
+ if (zot(corner)) corner=DS.corner!=null?DS.corner:null;
29809
30232
  if (zot(pattern)) pattern=DS.pattern!=null?DS.pattern:null;
29810
30233
  if (zot(scalePattern)) scalePattern=DS.scalePattern!=null?DS.scalePattern:"fill";
29811
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;
29812
30237
 
29813
30238
  color = zik(color);
29814
30239
  color2 = zik(color2);
@@ -29817,7 +30242,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29817
30242
  color = new zim.GradientColor([color, color2], [0,1], angle);
29818
30243
  color2 = null;
29819
30244
  }
29820
- 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);
29821
30246
  if (zot(cache) && (!zot(color2) || !zot(pattern))) cache = true;
29822
30247
  if (cache) backing.cache();
29823
30248
  if (!zot(pattern)) {
@@ -29841,7 +30266,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
29841
30266
  this.clone = function(recursive) {
29842
30267
  if (zot(recursive)) recursive = false;
29843
30268
  if (color.type) color2 = null;
29844
- 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));
29845
30270
  if (recursive) {
29846
30271
  that.cloneChildren(w);
29847
30272
  }
@@ -30790,8 +31215,9 @@ show() - shows the progress bar (returns the progress bar for chaining)
30790
31215
  hide() - hides the progress bar
30791
31216
  toggle(state - default null) - shows progress bar if hidden and hides progress bar if showing (returns the object for chaining)
30792
31217
  or pass in true to show progress bar or false to hide progress bar
30793
- 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)
30794
31219
  setting close to true or false will set the main class autoHide setting
31220
+ set repeat to true to keep repeating
30795
31221
  thanks Racheli Golan for the request
30796
31222
  setBacking(backing) - change the backing of the progress bar
30797
31223
  hasProp(property as String) - returns true if property exists on object else returns false
@@ -31002,7 +31428,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31002
31428
  return that;
31003
31429
  };
31004
31430
 
31005
- that.run = function(time, close) {
31431
+ that.run = function(time, close, repeat) {
31006
31432
  if (!zot(close)) autoHide = close;
31007
31433
  if (zot(time)) time=timeType=="s"?3:3000;
31008
31434
  checkTIME(time, timeType); // check for warning
@@ -31014,8 +31440,13 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31014
31440
  that.runInterval = setInterval(function () {
31015
31441
  that.percent = (Date.now()-startTime)/t*100;
31016
31442
  if (that.percent >= 100) {
31017
- that.percent = 100;
31018
- 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
+ }
31019
31450
  }
31020
31451
  }, 30);
31021
31452
  return that;
@@ -31075,7 +31506,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31075
31506
  //-59.5
31076
31507
 
31077
31508
  /*--
31078
- 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)
31079
31510
 
31080
31511
  Indicator
31081
31512
  zim class - extends a zim.Container which extends a createjs.Container
@@ -31129,17 +31560,22 @@ scale - (default 1) for all the lights including spacing
31129
31560
  lightScale - (default 1) scale for each light - keeping the spacing unchanged
31130
31561
  interactive - (default false) set to true to make lights clickable
31131
31562
  clicking on first light when first light is only light on, will toggle light
31563
+ unless toggleFirst is set to false
31132
31564
  shadowColor - (default rgba(0,0,0,.3)) set to -1 for no shadow
31133
31565
  shadowBlur - (default 5) the shadow blur if shadow is set
31134
31566
  index - (default 0) - set the index at start. Use -1 for no indicator at start.
31135
31567
  backgroundAlpha - (default 1 or .2 if indicatorType is Emoji) - affects only Emoji and custom DisplayObject indicatorType
31136
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
31137
31572
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
31138
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)
31139
31574
  inherit - (default null) used internally but can receive an {} of styles directly
31140
31575
 
31141
31576
  METHODS
31142
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
31143
31579
  clone() - makes a copy with properties such as x, y, etc. also copied
31144
31580
  dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
31145
31581
 
@@ -31173,8 +31609,8 @@ dispatches a "change" event if press is true and indicator is pressed on and lig
31173
31609
  ALSO: see the CreateJS Easel Docs for Container events such as:
31174
31610
  added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
31175
31611
  --*///+60
31176
- 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) {
31177
- 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";
31178
31614
  var duo; if (duo = zob(zim.Indicator, arguments, sig, this)) return duo;
31179
31615
  z_d("60");
31180
31616
  this.zimContainer_constructor(null,null,null,null,false);
@@ -31208,11 +31644,17 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31208
31644
  if (zot(shadowColor)) shadowColor = DS.shadowColor!=null?DS.shadowColor:"rgba(0,0,0,.3)";
31209
31645
  if (zot(shadowBlur)) shadowBlur = DS.shadowBlur!=null?DS.shadowBlur:5;
31210
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;
31211
31651
 
31212
31652
  var eventType = (!zns?WW.ACTIONEVENT=="mousedown":zim.ACTIONEVENT=="mousedown")?"mousedown":"click";
31213
31653
 
31214
31654
  var that = this;
31215
31655
  this.lights = [];
31656
+ this.indicatorList = indicatorList;
31657
+ this.selectedIndicatorList = selectedIndicatorList;
31216
31658
 
31217
31659
  var myValue;
31218
31660
  if (backdropColor != -1) {
@@ -31235,7 +31677,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31235
31677
  light = new Container(size,size).reg("center","center");
31236
31678
 
31237
31679
  // dim
31238
- 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") {
31239
31683
  light.dim = new zim.Circle(size/2, backgroundColor, borderColor, borderWidth, null, null, null, null, null, false);
31240
31684
  } else if (indicatorType == "square" || indicatorType == "box") {
31241
31685
  light.dim = new zim.Rectangle(size, size, backgroundColor, borderColor, borderWidth, null, null, null, null, false);
@@ -31259,7 +31703,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31259
31703
  this.lights.push(light);
31260
31704
 
31261
31705
  // brights
31262
- 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") {
31263
31709
  light.bright = new zim.Circle(size/2, foregroundColor, borderColor, borderWidth, null, null, null, null, null, false);
31264
31710
  } else if (selectedIndicatorType == "square" || selectedIndicatorType == "box") {
31265
31711
  light.bright = new zim.Rectangle(size, size, foregroundColor, borderColor, borderWidth, null, null, null, null, false);
@@ -31299,15 +31745,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31299
31745
  that.lightsEvent = lights.on(eventType, function(e) {
31300
31746
  if (myValue == e.target.znum) {
31301
31747
  if (myValue > 0) return;
31302
- else if (myValue==0){
31748
+ else if (toggleFirst && myValue==0){
31303
31749
  myValue = -1;
31304
- setLights(myValue);
31750
+ if (!delayLights) setLights(myValue);
31305
31751
  that.dispatchEvent("change");
31306
31752
  return;
31307
31753
  }
31308
31754
  }
31309
31755
  myValue = e.target.znum;
31310
- setLights(myValue);
31756
+ if (!delayLights) setLights(myValue);
31311
31757
  that.dispatchEvent("change");
31312
31758
  });
31313
31759
  }
@@ -31330,6 +31776,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31330
31776
  if ((!zim.OPTIMIZE&&(zns||!WW.OPTIMIZE)) && that.stage) that.stage.update();
31331
31777
  }
31332
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
+
31333
31788
  Object.defineProperty(this, 'index', {
31334
31789
  get: function() {
31335
31790
  return myValue;
@@ -31384,7 +31839,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31384
31839
  }
31385
31840
  }
31386
31841
  this.clone = function() {
31387
- 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));
31388
31843
  };
31389
31844
  };
31390
31845
  zim.extend(zim.Indicator, zim.Container, ["clone","dispose"], "zimContainer", false);
@@ -31563,7 +32018,7 @@ focus, blur are dispatched when the text gains and loses focus
31563
32018
  input is dispatched when the input text is typed or pasted into
31564
32019
  capture the key with the event object data property
31565
32020
  change is dispatched when the input text is different after losing focus (except if text is set programmatically)
31566
- capture the key with the event object key or keyCode properties
32021
+ capture the key a F.keydown event object key or keyCode properties
31567
32022
  See the events for HTML input field of type text
31568
32023
  See the events for ZIM Window()
31569
32024
  See the CreateJS Easel Docs for Container events such as:
@@ -31776,12 +32231,14 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
31776
32231
  }
31777
32232
  that.label.on("blur", that.tiBlur);
31778
32233
 
31779
- that.label.on("input", function (e) {
32234
+ that.label.on("fieldinput", function (e) {
31780
32235
  doPlaceholder();
31781
32236
  // if (align=="center" && label.width < width) {
31782
32237
  // label.x = (width-label.width)/2;
31783
32238
  // }
31784
- // that.dispatchEvent(e);
32239
+ var ev = new createjs.Event("input");
32240
+ ev.data = e.data;
32241
+ that.dispatchEvent(ev);
31785
32242
  });
31786
32243
  that.label.on("keydown", function (e) {
31787
32244
  that.label.deleteKey = (e.detail == 46);
@@ -32084,6 +32541,8 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
32084
32541
  this.hiddenInput.style.height = "1px";
32085
32542
  this.hiddenInput.style.fontSize = "1px";
32086
32543
 
32544
+ var that = this;
32545
+
32087
32546
  // this.hiddenInput.style.direction = rtl?"rtl":"ltr";
32088
32547
 
32089
32548
  this.onFocus = function() {
@@ -32113,15 +32572,16 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
32113
32572
  this.text = this.hiddenInput.type=="password"?newText.replace(/./g, '*'):newText;
32114
32573
  this.measureText();
32115
32574
  if (WW.M) this.positionBlinkerAndSelection();
32116
- 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);
32117
32578
  }
32118
32579
  this.onSelect = function() {
32119
32580
  this.positionBlinkerAndSelection();
32120
32581
  if (this.focus) {
32121
32582
  this.blinker.replayTween();
32122
32583
  }
32123
- }
32124
- var that = this;
32584
+ }
32125
32585
  this.onKeydown = function(e) {
32126
32586
  this.deleteKey = (e.code=="Backspace"||e.code=="Delete");
32127
32587
  this.blinker.replayTween();
@@ -33007,9 +33467,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
33007
33467
 
33008
33468
  // handle possible checkboxes
33009
33469
  if (checkBox) {
33010
- zim.loop(listW, function (item, i) {
33470
+ zim.loop(listW, function (item, i) {
33011
33471
  if (listW[i]=="%-&") return;
33012
- 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);
33013
33473
  });
33014
33474
  }
33015
33475
 
@@ -37095,8 +37555,10 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
37095
37555
 
37096
37556
  // ADD CONTENT TO WINDOW
37097
37557
  that.add(content);
37098
- that.add(loader, null, true);
37099
- loader.pos(0,0,RIGHT,BOTTOM)
37558
+ if (upload) {
37559
+ that.add(loader, null, true);
37560
+ loader.pos(0,0,RIGHT,BOTTOM);
37561
+ }
37100
37562
 
37101
37563
 
37102
37564
  // LINES
@@ -39929,7 +40391,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
39929
40391
 
39930
40392
  if (style!==false) zim.styleTransforms(this, DS);
39931
40393
  this.clone = function () {
39932
- 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));
39933
40395
  };
39934
40396
  };
39935
40397
  zim.extend(zim.NumPad, zim.Panel, ["clone"], "zimPanel", false);
@@ -41001,6 +41463,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
41001
41463
 
41002
41464
  if (style!==false) zim.styleTransforms(this, DS);
41003
41465
  this.clone = function() {
41466
+ if (menu.core) menu = menu.core;
41004
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));
41005
41468
  };
41006
41469
 
@@ -41786,7 +42249,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
41786
42249
  that.value = zim.convertColor(dropper.borderColor ,"hex");
41787
42250
  that.dispatchEvent("change");
41788
42251
  if (!dropping) return;
41789
- if (dropperTarget) { // adjusted ZIM ZIM 01 to only do when dropperTarget
42252
+ if (that.dropperTarget) { // adjusted ZIM ZIM 01 to only do when dropperTarget
41790
42253
  setMock();
41791
42254
  dropper.vis(true).top();
41792
42255
  setTimeout(function() {
@@ -44339,8 +44802,8 @@ zim.Keyboard = function(labels, backgroundColor, color, shiftBackgroundColor, sh
44339
44802
  }
44340
44803
 
44341
44804
  if (style!==false) zim.styleTransforms(this, DS);
44342
- this.clone = function() {
44343
- 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);
44344
44807
  return that.cloneProps(kb);
44345
44808
  };
44346
44809
  this.dispose = function(a,b,disposing) {
@@ -45104,7 +45567,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45104
45567
 
45105
45568
  if (zot(dblclickTime)) dblclickTime = DS.dblclickTime!=null?DS.dblclickTime:.5;
45106
45569
  var timeType = getTIME(dblclickTime);
45107
- dblclickTime *= timeType=="s"?1000:1;
45570
+ var dt = dblclickTime * (timeType=="s"?1000:1);
45108
45571
 
45109
45572
  if (zot(snapH)) snapH = DS.snapH!=null?DS.snapH:null;
45110
45573
  if (zot(snapV)) snapV = DS.snapV!=null?DS.snapV:null;
@@ -45411,7 +45874,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45411
45874
  });
45412
45875
  if (clearMove) clearselectedList();
45413
45876
  }
45414
- }, dblclickTime);
45877
+ }, dt);
45415
45878
  }
45416
45879
  downCount++;
45417
45880
  }
@@ -46091,7 +46554,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
46091
46554
  };
46092
46555
 
46093
46556
  if (style!==false) zim.styleTransforms(this, DS);
46094
- this.clone = function() {
46557
+ this.clone = function() {
46095
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));
46096
46559
  };
46097
46560
  };
@@ -46142,17 +46605,17 @@ PARAMETERS
46142
46605
  width - (default 300) width of marquee content
46143
46606
  final marquee width will have marginLeft and marginRight added to this width
46144
46607
  height - (default 100) height of content and marquee
46145
- items - default(null) an array of Display Objects - can be interactive
46146
- 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)
46147
46610
  also see marqueeTime property for each item to individually override the time for viewing
46148
- transition - default("slide") the transition between items
46611
+ transition - (default "slide") the transition between items
46149
46612
  options are: "none", "reveal", "slide", "fade", "clear", "black", "white", "fan"
46150
- speed - default(.5) speed of transition in seconds (also see ZIM TIME constant)
46151
- 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
46152
46615
  options are: RIGHT, LEFT, UP, DOWN
46153
- 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
46154
46617
  set to 0 to not show indicator and pause button
46155
- 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
46156
46619
  set to 0 to not show Z logo with animated MARQUEE
46157
46620
  marqueeType - (default "dot" or "circle") the Indicator type - also "box" or "square"
46158
46621
  borderColor - (default dark) border color - any ZIM or HTML color - set to -1 for no border
@@ -46559,24 +47022,24 @@ PARAMETERS
46559
47022
  items - default(seven multicolored rectangles) an array of Display Objects - can be interactive
46560
47023
  items will be scaled to the most common width and tiled - see the tile property
46561
47024
  a String item will be converted to a new Pic(item)
46562
- viewNum - default(3) the number of items to show
46563
- time - default(.2) time in seconds to animate between items (also see ZIM TIME constant)
46564
- spacing - default(20) the space between the items
46565
- backgroundColor - default(clear) the backgroundColor - also see background property
46566
- backing - default(null) - an optional backing DisplayObject that goes on top of the backing and under the tile
46567
- padding - default(0) - the default for the background outside the tile
46568
- paddingH - default(padding) - the horizontal padding to override the padding setting
46569
- paddingV - default(padding) - the vertical padding to override the padding setting
46570
- arrowLeft - default(new Arrow().rot(180)) - an arrow for going left
46571
- arrowRight - default(new Arrow()) - an arrow for going right
46572
- arrowGap - default(20) the gap between the arrow and the backing
46573
- valign - default(CENTER) the vertical alignment of the tile items
46574
- ease - default(quadInOut) the ease of the animation - see ZIM animate() ease parameter for types
46575
- swipe - default(true) set to false to not make the tile swipeable - see also the swipe property
46576
- remember - default("zimCarousel") set to false to not remember the index when reloading the page
46577
- 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
46578
47041
  this is the index of the first (left) item in view
46579
- continuous - default(true) set to false to stop at ends
47042
+ continuous - (default true) set to false to stop at ends
46580
47043
  this will clone the items and use the modulus to keep index numbers correct
46581
47044
  if continuous is false and the carousel is cycled then it will bounce back and forth
46582
47045
  selectedIndex - same as index, kept in for backwards compatibility in ZIM DUO
@@ -46661,9 +47124,10 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
46661
47124
 
46662
47125
  this.group = group;
46663
47126
  var DS = style===false?{}:zim.getStyle("Carousel", this.group, inherit);
46664
- var that = this;
47127
+ var that = this;
46665
47128
 
46666
47129
  this.zimContainer_constructor();
47130
+ this.type = "Carousel";
46667
47131
 
46668
47132
  if (zot(items)) items = DS.items!=null?DS.items:[
46669
47133
  new Rectangle({color: red}),
@@ -47037,6 +47501,488 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
47037
47501
  zim.extend(zim.Carousel, zim.Container, ["clone", "dispose"], "zimContainer", false);
47038
47502
  //-67.45
47039
47503
 
47504
+ /*--
47505
+ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve, interactive, continuous, fade, fadeColor, vertical, sensitivity, damp, factor, index, 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, style, group, inherit) {
47673
+ var sig = "width, height, items, widthFactor, heightFactor, curve, interactive, continuous, fade, fadeColor, vertical, sensitivity, damp, factor, index, 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, style, this.group));
47981
+ };
47982
+ }
47983
+ zim.extend(zim.Carousel3D, zim.Container, ["clone", "dispose"], "zimContainer", false);
47984
+ //-67.47
47985
+
47040
47986
  /*--
47041
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)
47042
47988
 
@@ -47060,16 +48006,16 @@ This is so ZIM does not have to keep track of HTML tags each time a container is
47060
48006
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
47061
48007
 
47062
48008
  EXAMPLE
48009
+ // loading a single pic
47063
48010
  const loader = new Loader({
47064
- label:"UPLOAD PIC OR DROP PICS HERE",
48011
+ label:"UPLOAD PIC HERE",
47065
48012
  width:700,
47066
48013
  height:400,
47067
- corner:50
48014
+ corner:50,
48015
+ multiple:false // or don't bother and it just gets the first loaded
47068
48016
  }).center();
47069
48017
  loader.on("loaded", e=>{
47070
- loop(e.bitmaps, bitmap=>{
47071
- bitmap.centerReg().drag();
47072
- });
48018
+ e.bitmap.centerReg().drag();
47073
48019
  loader.removeFrom();
47074
48020
  S.update();
47075
48021
  });
@@ -47079,7 +48025,24 @@ const saveButton = new Button({label:"SAVE"})
47079
48025
  .pos(10,10,RIGHT,BOTTOM)
47080
48026
  .tap(()=>{
47081
48027
  loader.save(S); // or some other container... can specify crop bounds too
47082
- }
48028
+ });
48029
+ END EXAMPLE
48030
+
48031
+ EXAMPLE
48032
+ // loading multiple pics
48033
+ const loader = new Loader({
48034
+ label:"UPLOAD PIC OR DROP PICS HERE",
48035
+ width:700,
48036
+ height:400,
48037
+ corner:50
48038
+ }).center();
48039
+ loader.on("loaded", e=>{
48040
+ loop(e.bitmaps, bitmap=>{
48041
+ bitmap.centerReg().drag();
48042
+ });
48043
+ loader.removeFrom();
48044
+ S.update();
48045
+ });
47083
48046
  END EXAMPLE
47084
48047
 
47085
48048
  EXAMPLE
@@ -48125,13 +49088,16 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
48125
49088
 
48126
49089
  that._enabled = true;
48127
49090
  var lastReadOnly = that.readOnly;
49091
+ var ss;
49092
+ var se;
49093
+ var sf;
48128
49094
  Object.defineProperty(that, 'enabled', {
48129
49095
  get: function() {
48130
- zog("here")
48131
49096
  return that._enabled;
48132
49097
  },
48133
49098
  set: function(value) {
48134
49099
  if (!value) {
49100
+ sf = that.tag == document.activeElement;
48135
49101
  lastReadOnly = that.readOnly;
48136
49102
  that.readOnly = false; // needed to remove selection
48137
49103
  that.focus = false;
@@ -48139,9 +49105,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
48139
49105
  setTimeout(function() {
48140
49106
  that.readOnly = true;
48141
49107
  },50); // setting readonly brings back selection even after blur - bug in HTML
49108
+ ss = that.tag.selectionStart;
49109
+ se = that.tag.selectionEnd;
48142
49110
  } else {
48143
49111
  that.tag.style.pointerEvents = "unset"; // tried all, unset, inherent, auto, initial, revert
48144
49112
  that.readOnly = lastReadOnly; // does not bring selection back
49113
+ if (sf) {
49114
+ that.tag.focus();
49115
+ that.tag.setSelectionRange(ss,se);
49116
+ }
48145
49117
  }
48146
49118
  zenable(that, value);
48147
49119
  }
@@ -50625,7 +51597,7 @@ RETURNS obj for chaining
50625
51597
  var duo; if (duo = zob(zim.tap, arguments, sig)) return duo;
50626
51598
  z_d("47.8");
50627
51599
  if (zot(obj) || zot(call) || typeof call != "function") return;
50628
- if (zot(distance)) distance = dbl?10:5;
51600
+ if (zot(distance)) distance = zim.handCursor?(dbl?100:50):(dbl?10:5);
50629
51601
  var timeType = getTIME(time);
50630
51602
  if (zot(time)) time = timeType=="s"?8:8000;
50631
51603
  if (zot(once)) once = false;
@@ -50693,7 +51665,7 @@ RETURNS obj for chaining
50693
51665
  });
50694
51666
  });
50695
51667
  } else {
50696
- obj.zimClickDownEvent = obj.on("mousedown", function (e) {
51668
+ obj.zimClickDownEvent = obj.on("mousedown", function (e) {
50697
51669
  if (e.currentTarget.type == "List") {
50698
51670
  if (e.target.type == "WindowBacking") return;
50699
51671
  var local = e.currentTarget.globalToLocal(e.stageX / zim.scaX, e.stageY / zim.scaY);
@@ -51124,7 +52096,6 @@ RETURNS obj for chaining
51124
52096
  z_d("31");
51125
52097
 
51126
52098
  if (zot(obj) || !obj.on) return;
51127
-
51128
52099
 
51129
52100
  var DA = zim.DRAGALL;
51130
52101
  if (WW.DRAGALL != null) DA = WW.DRAGALL;
@@ -51184,6 +52155,7 @@ RETURNS obj for chaining
51184
52155
  if (zot(dropHitTest)) dropHitTest = "bounds";
51185
52156
 
51186
52157
  obj.dragPaused = false;
52158
+
51187
52159
 
51188
52160
  if (slide) {
51189
52161
  // set up damping for slide and variables used to predict future locations
@@ -51526,7 +52498,7 @@ RETURNS obj for chaining
51526
52498
  r = obj.zimBoundary;
51527
52499
  if (surround) rLocal = zim.boundsToGlobal(o.parent, obj.zimBoundary, true); // flips to global to local
51528
52500
  }
51529
- }
52501
+ }
51530
52502
  x = p.x;
51531
52503
  y = p.y;
51532
52504
  if (slide) {
@@ -51536,7 +52508,7 @@ RETURNS obj for chaining
51536
52508
  // if (dampX) dampX.immediate(objUpX);
51537
52509
  // if (dampY) dampY.immediate(objUpY);
51538
52510
  }
51539
- }
52511
+ }
51540
52512
 
51541
52513
  // TODO only need this if boundary - so try and test for that first...
51542
52514
  var point;
@@ -51865,7 +52837,8 @@ RETURNS obj for chaining
51865
52837
  // if it is not snapping then the object stops at the bounds when it is slid
51866
52838
 
51867
52839
 
51868
- function setUpSlide() {
52840
+ function setUpSlide() {
52841
+
51869
52842
  obj.zimDragTicker = function() {
51870
52843
  if (zot(obj.slideStartX)) return; // don't stop other things like window scrollbar from moving object
51871
52844
 
@@ -52011,7 +52984,7 @@ RETURNS obj for chaining
52011
52984
  if (obj.zimDragTicker) {
52012
52985
  zim.Ticker.remove(obj.zimDragTicker);
52013
52986
  if (snapBack) {
52014
- var f = obj.zimCheckBounds(obj, obj.x, obj.y);
52987
+ var f = obj.zimCheckBounds(obj, obj.x, obj.y);
52015
52988
  obj.animate({x:f.x, y:f.y}, .3);
52016
52989
  }
52017
52990
  }
@@ -52774,7 +53747,7 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
52774
53747
 
52775
53748
  if (zot(container)) container = stage;
52776
53749
 
52777
- if (zot(frame.eventRemove)) {
53750
+ if (zot(frame.downEventRemove)) {
52778
53751
  stage.enableMouseOver();
52779
53752
  frame.ctrlKey = false;
52780
53753
  frame.shiftKey = false;
@@ -54783,7 +55756,9 @@ END EXAMPLE
54783
55756
 
54784
55757
  EXAMPLE
54785
55758
  const physics = new Physics().drag();
54786
- const points = [ // fish shape
55759
+ // fish shape
55760
+ // make sure points are clockwise in order - if counterClockwise then use myBlob.reversePoints()
55761
+ const points = [
54787
55762
  [0.5,-29.2,0,0,-79.1,25.5,79.1,-25.5,"mirror"],[182.3,15.9,0,0,-33.9,-59.6,-31.1,55.6,"free"],
54788
55763
  [15.4,86.2,0,0,67,10.4,-67,-10.4,"mirror"],[-163.6,73.2,0,0,67.9,-49.9,10.7,-51.8,"free"],
54789
55764
  [-165.7,-43.9,0,0,11.9,40.8,70.1,43.6,"free"]
@@ -54808,7 +55783,8 @@ shape - (default object shape) - "rectangle" for any object other than Circle, D
54808
55783
  but can specify a "circle" for a Sprite or Bitmap, for instance - to try and match shape
54809
55784
  custom polygon bodies can also be made with manual Box2D and then use physics.addMap()
54810
55785
  but the only shapes available automatically are "rectangle", "circle", "triangle"
54811
- Note - addPhysics() can be placed on a ZIM Blob as well
55786
+ Note - addPhysics() can be placed on a ZIM Blob as well - see Physics.validate() for more details
55787
+ such as the Blob must have clockwise points - if counterClockwise then use myBlob.reversePoints()
54812
55788
  friction - (default .8) - how sticky will the body act - set to 0 to slide.
54813
55789
  linear - (default .5) - linear damping which slows the movement - set to 0 for no damping
54814
55790
  angular - (default .5) - angular damping which slows the rotation - set to 0 for no damping
@@ -55080,6 +56056,50 @@ RETURNS a Boolean true if hitting, false if not
55080
56056
  }
55081
56057
  };//-37
55082
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
+
55083
56103
  /*--
55084
56104
  obj.hitTestCircle = function(other, num, boundsCheck, inside)
55085
56105
 
@@ -55181,7 +56201,7 @@ const ball = new Circle(50, red).center().drag();
55181
56201
  const box = new Rectangle(100, 100, blue).loc(100,100);
55182
56202
  ball.on("pressmove", ()=>{
55183
56203
  if (ball.hitTestCircleRect(box)) {
55184
- zog("points!");
56204
+ zog("hitting!");
55185
56205
  }
55186
56206
  });
55187
56207
  END EXAMPLE
@@ -55226,6 +56246,58 @@ RETURNS a Boolean true if hitting, false if not
55226
56246
 
55227
56247
  };//-38.2
55228
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
+
55229
56301
  /*--
55230
56302
  obj.hitTestCircles = function(other, margin)
55231
56303
 
@@ -60449,6 +61521,7 @@ zim.STYLE and Style()
60449
61521
 
60450
61522
  STYLE
60451
61523
  zim constant and static Class
61524
+ Also GLOBALSTYLE zim constant
60452
61525
 
60453
61526
  DESCRIPTION
60454
61527
  STYLE can be used to set any parameter on a DisplayObject and many of the Controls.
@@ -60468,7 +61541,14 @@ They are cascading with each level overriding the previous level:
60468
61541
  See: https://zimjs.com/style.html for an example
60469
61542
  And: https://zimjs.com/test/styles.html for Control Styles
60470
61543
 
60471
- 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.
60472
61552
  STYLE is an object so all of these are just a couple lines to make it easier to update the object.
60473
61553
  These include methods such as clear(), add(), remember(), addType(), addGroup(), etc.
60474
61554
  See the Style entry down below for a complete listing and description.
@@ -60586,6 +61666,25 @@ STYLE = {color:red, wonder:{percent:50}};
60586
61666
  new Circle({style:false, group:"wonder"}).center();
60587
61667
  END EXAMPLE
60588
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
+
60589
61688
  EXAMPLE
60590
61689
  // Note: these commands are on the Style class not STYLE - but they operate on STYLE
60591
61690
  // Also remember that ZIM STYLE only gets applied to new objects
@@ -60655,7 +61754,7 @@ If it does not work, just turn the STYLE = {} or Style.clear() manually.
60655
61754
  FUNCTION STYLES
60656
61755
  The following functions have been added:
60657
61756
  addTo, loc, pos, center, centerReg, reg, transform, drag, gesture,
60658
- tap, change, hold, outline, bounds, mov, animate, wiggle, expand and cache
61757
+ tap, change, hold, outline, bounds, mov, animate, wiggle, expand, cache, and mouse
60659
61758
  Values of true will give default functionality for all but tap, change, mov, animate and wiggle
60660
61759
  ZIM DUO configuration objects can be set as a value for any of these
60661
61760
  example: drag:true; or drag:{onTop:false}
@@ -60663,6 +61762,7 @@ For animate and wiggle, [] can be put around multiple configuration objects
60663
61762
  to wiggle in the x and y for instance or run multiple animate calls on the object
60664
61763
  The tap, change and hold events are only what function to call - no extra parameters are available
60665
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.
60666
61766
 
60667
61767
  CONVENIENCE STYLES
60668
61768
  add:true - has been provided to add to the stage (use addTo for other containers)
@@ -60752,14 +61852,17 @@ Style.removeGroup(groupName) - removes a group as a string
60752
61852
  same as: delete STYLE.group.groupName
60753
61853
  --*///+50.34
60754
61854
  zim.STYLE = null;
61855
+ zim.GLOBALSTYLE = null;
60755
61856
  zim.getStyle = function(type, group, inherit, groupOnly) {
60756
61857
  if (!zim.STYLECHECK) {z_d("50.34"); zim.STYLECHECK=true;}
60757
61858
 
60758
- 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"];
60759
61860
 
60760
61861
  // called by DisplayObjects
60761
61862
  // ZIM NFT MODULE ADJUST
60762
61863
  var STYLE = WW.STYLE || zim.STYLE;
61864
+ var GLOBALSTYLE = WW.GLOBALSTYLE || zim.GLOBALSTYLE;
61865
+ if (GLOBALSTYLE) STYLE = zim.merge(GLOBALSTYLE, STYLE);
60763
61866
  var DS = STYLE;
60764
61867
  var val;
60765
61868
 
@@ -61007,6 +62110,11 @@ zim.styleTransforms = function(obj, styles) {
61007
62110
  if (styles.noChange && obj.noChange) obj.noChange();
61008
62111
  if (styles.noTap && obj.noTap) obj.noTap();
61009
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();
61010
62118
 
61011
62119
  var STYLE = WW.STYLE || zim.STYLE;
61012
62120
  if (STYLE && (STYLE.once===true || STYLE.once==obj.type)) {
@@ -62013,6 +63121,9 @@ See https://zimjs.com/cat/page.html
62013
63121
  ZIM Cat 03 intruduces the ZIM Arrow() class for an easy previous/next button system.
62014
63122
  See https://zimjs.com/survey.html
62015
63123
 
63124
+ ZIM 017 added continuous pages
63125
+ See https://zimjs.com/017/continuous.html
63126
+
62016
63127
  As of ZIM ZIM 02 a GlobalManager will be added to handle Pages resize for cached transitions.
62017
63128
 
62018
63129
  NOTE: if you have a TextArea, Tag or Loader on a page, ZIM will automatically add and remove it.
@@ -65092,8 +66203,8 @@ obj - |ZIM VEE| (default new Circle()) the display object to tile
65092
66203
  If the obj is a ZIM VEE function (not array, object literal or series) then the Tile clone parameter will default to false
65093
66204
  cols - (default 1 - if no cols and rows then 3) the columns to tile
65094
66205
  rows - (default 1 - if no cols and rows then 3) the rows to tile
65095
- spacingH - (default 0 - if no cols and rows then 3) a spacing between columns - ignored if colSize is set
65096
- 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
65097
66208
  unique - (default false) - set to true if tiling unique items like components with events set or objects with custom properties
65098
66209
  1. this will turn off ZIM VEE for the obj parameter which will accept an array of unique objects
65099
66210
  2. the count parameter will be set to the length of the array
@@ -65181,6 +66292,10 @@ itemUnderPoint(x, y, ignoreSpacing) - gets the item under a global point - (with
65181
66292
  setProps(properties) - sets provided properties (as {prop:val, prop:val}) for each item
65182
66293
  the values accept ZIM VEE - dynamic parameters - see ZIM Pick()
65183
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
65184
66299
  remake(items) - pass in an array of items to tile - see items property for editing current list - returns tile for chaining
65185
66300
  can also change rows and cols and remake()
65186
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
@@ -65223,14 +66338,13 @@ These properties can be changed by calling remake()
65223
66338
  cols - number of columns - can modify - need to call remake() to see changes
65224
66339
  rows - number of rows - can modify - need to call remake() to see changes
65225
66340
  These properties can be changed by calling resize(width, height) - set width or height to 0 for no spreading
65226
- spacingH - horizontal spacing - can modify - need to call resize() to see changes
65227
- spacingV - vertical spacing - can modify - need to call resize() to see changes
65228
66341
  squeezeH - horizontal compression - can modify - need to call resize() to see changes
65229
66342
  squeezeV - vertical compression - can modify - need to call resize() to see changes
65230
66343
  align - (not with ZIM VEE) horizontal alignment - can modify - need to call resize() to see changes
65231
66344
  valign - (not with ZIM VEE) vertical alignment - can modify - need to call resize() to see changes
65232
66345
  mirrorH - horizontal mirroring - can modify - need to call resize() to see changes
65233
66346
  mirrorV - vertical mirroring - can modify - need to call resize() to see changes
66347
+ NOTE: spacingV and spacingH can be adjusted with setSpacing() method
65234
66348
 
65235
66349
  ALSO: see ZIM Container for properties such as:
65236
66350
  width, height, widthOnly, heightOnly, draggable, level, depth, group
@@ -65273,10 +66387,43 @@ note: the item is not the event object target - as that is the tile
65273
66387
 
65274
66388
  if (zot(spacingH)) spacingH = DS.spacingH!=null?DS.spacingH:null;
65275
66389
  if (zot(spacingV)) spacingV = DS.spacingV!=null?DS.spacingV:null;
65276
- var spacingHO = spacingH;
65277
- 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
+
65278
66409
  if (zot(spacingH) || !zot(colSize) || !zot(width)) spacingH = 0; // sizes override spacing
65279
- 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
+ }
65280
66427
  if (zot(squeezeH)) squeezeH = DS.squeezeH!=null?DS.squeezeH:false;
65281
66428
  if (zot(squeezeV)) squeezeV = DS.squeezeV!=null?DS.squeezeV:false;
65282
66429
  if (zot(align)) align = DS.align!=null?DS.align:"left";
@@ -65313,8 +66460,6 @@ note: the item is not the event object target - as that is the tile
65313
66460
  var that = this;
65314
66461
  that.cols = cols = Math.round(cols);
65315
66462
  that.rows = rows = Math.round(rows);
65316
- that.spacingH = spacingH;
65317
- that.spacingV = spacingV;
65318
66463
  that.squeezeH = squeezeH;
65319
66464
  that.squeezeV = squeezeV;
65320
66465
  var VEEAlign = (typeof align=="function");
@@ -65325,6 +66470,9 @@ note: the item is not the event object target - as that is the tile
65325
66470
  that.mirrorH = mirrorH;
65326
66471
  that.mirrorV = mirrorV;
65327
66472
 
66473
+ that.spacingH = spacingHList[0];
66474
+ that.spacingV = spacingVList[0];
66475
+
65328
66476
  // ~~~~~~~~~~~~~~~~~~~ GET ARRAY OF ITEMS ~~~~~~~~~~~~~~~
65329
66477
  // this list could be edited later and passed back into remake()
65330
66478
  // so need to separate this part from the rest
@@ -65339,7 +66487,7 @@ note: the item is not the event object target - as that is the tile
65339
66487
  currentCount++;
65340
66488
  if (!zot(count) && currentCount > count) break outer;
65341
66489
  tile = unique?obj[currentCount-1]:zim.Pick.choose(obj);
65342
- if (typeof tile == "string") tile = WW.asset(tile).centerReg({add:false}).clone();
66490
+ if (typeof tile == "string") tile = WW.asset(tile).reg(CENTER).clone();
65343
66491
  if (zot(tile)) {
65344
66492
  tile = new zim.Container(0,0,0,0);
65345
66493
  }
@@ -65444,6 +66592,8 @@ note: the item is not the event object target - as that is the tile
65444
66592
  if (!rowSize||!zot(height)) h = Math.abs(tB.height);
65445
66593
  // if (!colSize||!zot(width)) w = Math.abs(tile.width);
65446
66594
  // if (!rowSize||!zot(height)) h = Math.abs(tile.height);
66595
+ tile.fW = w;
66596
+ tile.fH = h;
65447
66597
 
65448
66598
  widthHeights[j][i] = [w,h];
65449
66599
  if (zot(widthMax[i])) widthMax[i] = 0;
@@ -65484,11 +66634,10 @@ note: the item is not the event object target - as that is the tile
65484
66634
  var rowTotals;
65485
66635
  var rowSpacings;
65486
66636
  var widthScaling = 1;
65487
- var heightScaling = 1;
65488
-
65489
-
66637
+ var heightScaling = 1;
66638
+
65490
66639
  function resize(width, height) {
65491
-
66640
+
65492
66641
  if (that.normalized) that.resetOriginalReg();
65493
66642
 
65494
66643
  if (!zot(backdropColor) && backdropPadding) {
@@ -65505,25 +66654,25 @@ note: the item is not the event object target - as that is the tile
65505
66654
  overallWidth = width;
65506
66655
  } else if (!zot(width)) {
65507
66656
  if (scaleToH) overallWidth = width;
65508
- else overallWidth = Math.max(widthTotalMax+(that.cols-1)*that.spacingH, width);
66657
+ else overallWidth = Math.max(widthTotalMax+spacingHTotal, width);
65509
66658
  } else {
65510
- if (widthUncompressedMax > 0) overallWidth = widthUncompressedMax+(that.cols-1)*that.spacingH;
65511
- else overallWidth = widthTotalMax+(that.cols-1)*that.spacingH;
66659
+ if (widthUncompressedMax > 0) overallWidth = widthUncompressedMax+spacingHTotal;
66660
+ else overallWidth = widthTotalMax+spacingHTotal;
65512
66661
  }
65513
66662
 
65514
66663
  if (!zot(height)&&that.squeezeV=="full") {
65515
66664
  overallHeight = height;
65516
66665
  } else if (!zot(height)) {
65517
66666
  if (scaleToV) overallHeight = height;
65518
- else overallHeight = Math.max(heightTotalMax+(that.rows-1)*that.spacingV, height);
66667
+ else overallHeight = Math.max(heightTotalMax+spacingVTotal, height);
65519
66668
  } else {
65520
- if (heightUncompressedMax > 0) overallHeight = heightUncompressedMax+(that.rows-1)*that.spacingV;
65521
- else overallHeight = heightTotalMax+(that.rows-1)*that.spacingV;
66669
+ if (heightUncompressedMax > 0) overallHeight = heightUncompressedMax+spacingVTotal;
66670
+ else overallHeight = heightTotalMax+spacingVTotal;
65522
66671
  }
65523
66672
 
65524
66673
  that.setBounds(0,0,overallWidth,overallHeight);
65525
- widthScaling = (overallWidth-(that.cols-1)*spacingHO)/(widthO);
65526
- heightScaling = (overallHeight-(that.rows-1)*spacingVO)/(heightO);
66674
+ widthScaling = (overallWidth-spacingHOTotal)/(widthO);
66675
+ heightScaling = (overallHeight-spacingVOTotal)/(heightO);
65527
66676
 
65528
66677
  // ~~~~~~~~~~~~~~~~~~~ PLACEMENTS ~~~~~~~~~~~~~~~
65529
66678
 
@@ -65533,6 +66682,7 @@ note: the item is not the event object target - as that is the tile
65533
66682
  rowTotals = []; // keep track of current y positions
65534
66683
  rowSpacings = [];
65535
66684
  var rowTops = [];
66685
+
65536
66686
  for (j=0; j<objects.length; j++) {
65537
66687
  rowObjects = objects[j];
65538
66688
  colTotal = 0;
@@ -65549,17 +66699,17 @@ note: the item is not the event object target - as that is the tile
65549
66699
  if (that.squeezeV=="full") {
65550
66700
  rowSpacings[i] = rowCounts[i]>1?((height - heightTotals[i]) / (rowCounts[i]-1)):0;
65551
66701
  } else if (that.squeezeV) {
65552
- 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;
65553
66703
  } else {
65554
- 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;
65555
66705
  }
65556
66706
  }
65557
66707
  if (that.squeezeV) {
65558
66708
  // check for center or bottom valign of whole row
65559
66709
  if (that.valign=="center" || that.valign=="middle") {
65560
- 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;
65561
66711
  } else if (that.valign=="bottom") {
65562
- 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));
65563
66713
  } else {
65564
66714
  rowTops[i] = 0;
65565
66715
  }
@@ -65576,17 +66726,17 @@ note: the item is not the event object target - as that is the tile
65576
66726
  if (that.squeezeH=="full") {
65577
66727
  spreadXspacing = rowObjects.length>1?((width - widthTotals[j]) / (rowObjects.length-1)):0;
65578
66728
  } else if (that.squeezeH) {
65579
- 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;
65580
66730
  } else {
65581
- 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;
65582
66732
  }
65583
66733
  }
65584
66734
  if (that.squeezeH) {
65585
66735
  // check for center or right align of whole row
65586
66736
  if (that.align=="center" || that.align=="middle") {
65587
- 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;
65588
66738
  } else if (that.align=="right") {
65589
- left = overallWidth-(widthTotals[j]+(rowObjects.length-1)*(!zot(width)?spreadXspacing:that.spacingH));
66739
+ left = overallWidth-(widthTotals[j]+(rowObjects.length-1)*(!zot(width)?spreadXspacing:spacingHAve));
65590
66740
  } else {
65591
66741
  left = 0;
65592
66742
  }
@@ -65611,23 +66761,23 @@ note: the item is not the event object target - as that is the tile
65611
66761
  }
65612
66762
  tile.pos(colTotal, null);
65613
66763
 
65614
- if (!that.squeezeH && VEEAlign) {
66764
+ if (!that.squeezeH && VEEAlign) {
65615
66765
  if (zot(width) && (align=="center" || align=="middle")) {
65616
- tile.x += (widthMax[i]-tile.width)/2;
66766
+ tile.x += (widthMax[i]-tile.fW)/2;
65617
66767
  } else if (zot(width) && align=="right") {
65618
- tile.x += widthMax[i]-tile.width;
66768
+ tile.x += widthMax[i]-tile.fW;
65619
66769
  }
65620
- } 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)
65621
66771
  if (zot(width) && (that.align=="center" || that.align=="middle")) {
65622
- tile.x += (widthMax[i]-tile.width)/2;
66772
+ tile.x += (widthMax[i]-tile.fW)/2;
65623
66773
  } else if (zot(width) && that.align=="right") {
65624
- tile.x += widthMax[i]-tile.width;
66774
+ tile.x += widthMax[i]-tile.fW;
65625
66775
  }
65626
66776
  } else {
65627
66777
  if (zot(width) && (that.align=="center" || that.align=="middle")) {
65628
- tile.x += (w-tile.width)/2;
66778
+ tile.x += (w-tile.fW)/2;
65629
66779
  } else if (zot(width) && that.align=="right") {
65630
- tile.x += w-tile.width;
66780
+ tile.x += w-tile.fW;
65631
66781
  }
65632
66782
  }
65633
66783
  if (that.mirrorV && j%2==1) {
@@ -65639,37 +66789,37 @@ note: the item is not the event object target - as that is the tile
65639
66789
  tile.pos(null,rowTotals[i]);
65640
66790
  if (!that.squeezeV && VEEVAlign) {
65641
66791
  if (zot(height) && (finalVAlign=="center" || finalVAlign=="middle")) {
65642
- tile.y += (heightMax[j]-tile.height)/2;
66792
+ tile.y += (heightMax[j]-tile.fH)/2;
65643
66793
  } else if (zot(height) && finalVAlign=="bottom") {
65644
- tile.y += heightMax[j]-tile.height;
66794
+ tile.y += heightMax[j]-tile.fH;
65645
66795
  }
65646
66796
  } else if (!that.squeezeV) { // this allows for dynamic setting of valign (for non-VEE, non squeezeV)
65647
66797
  if (zot(height) && (that.valign=="center" || that.valign=="middle")) {
65648
- tile.y += (heightMax[j]-tile.height)/2;
66798
+ tile.y += (heightMax[j]-tile.fH)/2;
65649
66799
  } else if (zot(height) && that.valign=="bottom") {
65650
- tile.y += heightMax[j]-tile.height;
66800
+ tile.y += heightMax[j]-tile.fH;
65651
66801
  }
65652
66802
  } else {
65653
66803
  if (zot(height) && (that.valign=="center" || that.valign=="middle")) {
65654
- tile.y += (h-tile.height)/2;
66804
+ tile.y += (h-tile.fH)/2;
65655
66805
  } else if (zot(height) && that.valign=="bottom") {
65656
- tile.y += h-tile.height;
66806
+ tile.y += h-tile.fH;
65657
66807
  }
65658
66808
  }
65659
66809
 
65660
66810
  if (that.squeezeH === true || !zot(width)) {
65661
- colTotal += w+(!zot(width)?spreadXspacing:that.spacingH);
66811
+ colTotal += w+(!zot(width)?spreadXspacing:spacingHList[i]);
65662
66812
  } else {
65663
- colTotal += widthMax[i]+(!zot(width)?spreadXspacing:that.spacingH);
66813
+ colTotal += widthMax[i]+(!zot(width)?spreadXspacing:spacingHList[i]);
65664
66814
  }
65665
66815
 
65666
66816
  tile.x += left;
65667
66817
  tile.y += rowTops[i];
65668
66818
 
65669
66819
  if (that.squeezeV === true || !zot(height)) {
65670
- rowTotals[i] += h+(!zot(height)?rowSpacings[i]:that.spacingV);
66820
+ rowTotals[i] += h+(!zot(height)?rowSpacings[i]:spacingVList[j]);
65671
66821
  } else {
65672
- rowTotals[i] += heightMax[j]+(!zot(height)?rowSpacings[i]:that.spacingV);
66822
+ rowTotals[i] += heightMax[j]+(!zot(height)?rowSpacings[i]:spacingVList[j]);
65673
66823
  }
65674
66824
  }
65675
66825
  }
@@ -65683,7 +66833,7 @@ note: the item is not the event object target - as that is the tile
65683
66833
  this.setProps = function(props) {
65684
66834
  zim.setProps(this.items, props);
65685
66835
  return this;
65686
- }
66836
+ }
65687
66837
 
65688
66838
  this.itemUnderPoint = function(x, y, ignoreSpacing) {
65689
66839
  if (zot(ignoreSpacing)) ignoreSpacing = true;
@@ -65694,12 +66844,12 @@ note: the item is not the event object target - as that is the tile
65694
66844
 
65695
66845
  var wT = 0;
65696
66846
  var co = zim.loop(widthMax, function (w, i) {
65697
- wT+=w+that.spacingH;
66847
+ wT+=w+spacingHList[i];
65698
66848
  if (!ignoreSpacing || ignoreSpacing == "vertical") {
65699
66849
  // test for in cracks
65700
- if (x > wT-that.spacingH && x < wT) return false;
66850
+ if (x > wT-spacingHList[i] && x < wT) return false;
65701
66851
  }
65702
- if (x < wT-that.spacingH/2) return i;
66852
+ if (x < wT-spacingHList[i]/2) return i;
65703
66853
  });
65704
66854
  if (co === false) return; // in crack
65705
66855
  if (co === true) co = cols-1;
@@ -65729,6 +66879,13 @@ note: the item is not the event object target - as that is the tile
65729
66879
  return that;
65730
66880
  };
65731
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
+
65732
66889
  this.resize = function(w, h) {
65733
66890
  if (zot(w)) w = width;
65734
66891
  if (zot(h)) h = height;
@@ -65794,7 +66951,7 @@ note: the item is not the event object target - as that is the tile
65794
66951
  var b = t.getBounds();
65795
66952
  var x = t.x - t.regX + b.x + b.width / 2;
65796
66953
  var y = t.y - t.regY + b.y + b.height / 2;
65797
- 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");
65798
66955
  if (index != null) items[index[0]] = t;
65799
66956
  });
65800
66957
  // // slow with hundreds
@@ -65866,8 +67023,8 @@ note: the item is not the event object target - as that is the tile
65866
67023
  if (!resize && !zot(backgroundColor)) backgroundColors = [];
65867
67024
  if (!resize && backing) backings = [];
65868
67025
 
65869
- var lastX = (colSize?spacingHO:0)/2;
65870
- var lastY = (rowSize?spacingVO:0)/2;
67026
+ var lastX = (colSize?spacingHOList[0]:0)/2;
67027
+ var lastY = (rowSize?spacingVOList[0]:0)/2;
65871
67028
  var rect;
65872
67029
  var cou = 0;
65873
67030
  zim.loop(that.items2D, function(c, j) {
@@ -65877,14 +67034,14 @@ note: the item is not the event object target - as that is the tile
65877
67034
  if (resize && !zot(backgroundColor)) {
65878
67035
  color = backgroundColors[cou];
65879
67036
  rect = backgrounds[cou]
65880
- .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)
65881
67038
  .loc(lastX, lastY, that, 0);
65882
67039
  } else {
65883
67040
  color = zik(backgroundColor);
65884
67041
  backgroundColors.push(backgroundColor);
65885
67042
  rect = new zim.Rectangle({
65886
- width:widthMax[i]*widthScaling-(colSize?spacingHO:0)+backgroundPaddingH*2,
65887
- 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,
65888
67045
  color:color,
65889
67046
  style:false,
65890
67047
  scaleDimensions:false,
@@ -65897,7 +67054,7 @@ note: the item is not the event object target - as that is the tile
65897
67054
  item.pos(0,0,align,valign,rect).addTo(that);
65898
67055
  }
65899
67056
 
65900
- lastX = rect.x + rect.width + spacingHO;
67057
+ lastX = rect.x + rect.width + spacingHOList[i];
65901
67058
  if (scaleToH || scaleToV) {
65902
67059
  var sX;
65903
67060
  var sY;
@@ -65921,8 +67078,8 @@ note: the item is not the event object target - as that is the tile
65921
67078
  }
65922
67079
  cou++;
65923
67080
  });
65924
- lastX = (colSize?spacingHO:0)/2;
65925
- lastY += rect.height + spacingVO;
67081
+ lastX = (colSize?spacingHOList[i]:0)/2;
67082
+ lastY += rect.height + spacingVOList[j];
65926
67083
  });
65927
67084
  if (backing && !zot(backgroundColor)) {
65928
67085
  zim.loop(backings, function(bbb) {
@@ -65941,14 +67098,18 @@ note: the item is not the event object target - as that is the tile
65941
67098
  }
65942
67099
 
65943
67100
  if (!zot(backgroundColor) && (colSize || rowSize)) {
65944
- that.loop(function(item) {
65945
- 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);
65946
67103
  });
65947
67104
  var bb = that.getBounds();
65948
- 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))
65949
67106
  bb = that.getBounds();
65950
67107
  }
65951
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);
65952
67113
 
65953
67114
  }
65954
67115
 
@@ -65995,7 +67156,7 @@ note: the item is not the event object target - as that is the tile
65995
67156
  if (backing) exactBackings.push(backings[i].clone(true));
65996
67157
  }
65997
67158
  }
65998
- 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));
65999
67160
  };
66000
67161
  };
66001
67162
  zim.extend(zim.Tile, zim.Container, "clone", "zimContainer", false);
@@ -69031,12 +70192,9 @@ zim.TextureActive = function(width, height, color, color2, angle, borderColor, b
69031
70192
  if (zot(pattern)) pattern=DS.pattern!=null?DS.pattern:null;
69032
70193
  if (zot(scalePattern)) scalePattern=DS.scalePattern!=null?DS.scalePattern:null;
69033
70194
 
69034
- 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);
69035
70196
  this.type = "TextureActive";
69036
70197
 
69037
- if (corner) this.backing.corner = corner;
69038
- if (!zot(borderWidth)) this.backing.borderWidth = borderWidth;
69039
- if (!zot(borderColor)) this.backing.borderColor = borderColor;
69040
70198
  if (borderWidth || !zot(borderColor)) {
69041
70199
  this.backing.siz(this.width-borderWidth, this.height-borderWidth);
69042
70200
  this.backing.center();
@@ -69955,6 +71113,7 @@ zim.TextureActivesManager = function(stage, toggleKey, damp) {
69955
71113
  if (doms.indexOf(obj) < 0) doms.push(obj.renderer.domElement);
69956
71114
  if (!createjs.remotePointers) createjs.addRemotePointers(stage, doms);
69957
71115
  else createjs.remotePointers = doms;
71116
+ // else createjs.remoteTargets = doms; // in looking at this after... I think this is what we meant
69958
71117
  return true;
69959
71118
  }
69960
71119
 
@@ -71188,9 +72347,9 @@ dispatches an "undo" event if a CTRL or META plus the U key is pressed
71188
72347
  }
71189
72348
  };
71190
72349
  var eDown = new createjs.Event("keydown");
71191
- this.eventRemove = eDown.remove;
72350
+ this.downEventRemove = eDown.remove;
71192
72351
  this.keydownEvent = function(e) {
71193
- e.remove = that.eventRemove;
72352
+ e.remove = that.downEventRemove;
71194
72353
  if (that.multipleKey) that.multiple = e[that.multipleKey+"Key"];
71195
72354
  that.ctrlKey = e.ctrlKey;
71196
72355
  that.shiftKey = e.shiftKey;
@@ -71202,12 +72361,14 @@ dispatches an "undo" event if a CTRL or META plus the U key is pressed
71202
72361
  };
71203
72362
  WW.addEventListener("keydown", this.keydownEvent);
71204
72363
 
72364
+ var eUp = new createjs.Event("keyup");
72365
+ this.upEventRemove = eUp.remove;
71205
72366
  this.keyupEvent = function(e) {
72367
+ e.remove = that.upEventRemove;
71206
72368
  if (that.multipleKey) that.multiple = e[that.multipleKey+"Key"];
71207
72369
  that.ctrlKey = e.ctrlKey;
71208
72370
  that.shiftKey = e.shiftKey;
71209
72371
  that.metaKey = e.metaKey;
71210
- e.remove = that.eventRemove;
71211
72372
  that.dispatchEvent(e);
71212
72373
  }
71213
72374
  WW.addEventListener("keyup", this.keyupEvent);
@@ -72725,7 +73886,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
72725
73886
  //-69.5
72726
73887
 
72727
73888
  /*--
72728
- 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)
72729
73890
 
72730
73891
  MotionController
72731
73892
  zim class - extends a createjs EventDispatcher
@@ -72737,6 +73898,7 @@ For instance, you can control a player in a game or a butterfly in field
72737
73898
  SEE: https://zimjs.com/controller for more examples
72738
73899
  SEE: https://zimjs.com/explore/sidescroller.html for keyboard work with Scroller, Sprite, Dynamo, Accelerator
72739
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
72740
73902
 
72741
73903
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
72742
73904
 
@@ -72848,7 +74010,7 @@ firstPerson - (default false) set to true for keydown, gamebutton and gamecontro
72848
74010
  speed will be damped by damp parameter - also, map parameter changes if in firstPerson mode - see map parameter
72849
74011
  turnSpeed - (default speed*.4) - the speed for turning in firstPerson mode - will be damped but damp parameter
72850
74012
  moveThreshold - (default 5) pixels negative or positive to treat damped motion as stopped
72851
- 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
72852
74014
  so consider within +- stickThreshold as no motion 0
72853
74015
  container - (default zimDefaultFrame stage) the Container the target is in - the stage is most likely fine
72854
74016
  if container is specified, it must be on the stage when the MotionController is made
@@ -72868,6 +74030,31 @@ minPercentSpeed - (default 100) if target is an Accelerator, the percentSpeed at
72868
74030
  dampKeyup - (default .3) damping applied to slow down Accelerator with keydown
72869
74031
  rotate - (depreciated) the same as orient - kept for backwards compatibility as of ZIM Cat 01
72870
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
72871
74058
 
72872
74059
  METHODS
72873
74060
  pause(state, time) - state defaults to true and pauses the motionController (sets speed to 0)
@@ -72904,6 +74091,8 @@ moveThreshold - the maximum value (+-) within which movement is considered stopp
72904
74091
  stickThreshold - the maximum value (+-) within which the gamepad stick axes values are considered 0
72905
74092
  mousedownIncludes - an array of objects that the mousedown will work on - along with the stage
72906
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
72907
74096
  enabled - set to false to disable or true to enable MotionController - can toggle with enabled = !enabled
72908
74097
 
72909
74098
  ALSO: adds a motionController property to target referencing the MotionController object
@@ -72915,8 +74104,8 @@ dispatches a "mousedown" event if type is "mousedown" or "pressmove"
72915
74104
  dispatches a "pressing" event if type is "pressmove" - note, this dispatches even if not moving
72916
74105
  dispatches a "moving" event if target is moving and "startmoving" and "stopmoving" events
72917
74106
  --*///+69.7
72918
- 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) {
72919
- 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";
72920
74109
  var duo; if (duo = zob(zim.MotionController, arguments, sig, this)) return duo;
72921
74110
  z_d("69.7");
72922
74111
 
@@ -72956,9 +74145,34 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
72956
74145
  type = "manual";
72957
74146
  if (zot(axis)) axis = dPad.axis;
72958
74147
  if (axis == "all") axis = "both";
74148
+
72959
74149
  dPad.on("change", function() {
72960
- 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
+ }
72961
74170
  });
74171
+ if (tileObj) {
74172
+ dPad.on("pressup", function() {
74173
+ down = [0,0,0,0];
74174
+ });
74175
+ }
72962
74176
  }
72963
74177
  if (zot(type) || (type != "mousemove" && type != "pressmove" && type != "pressdrag" && type != "keydown" && type != "gamebutton" && type != "gamestick" && type != "swipe" && type != "follow" && type != "manual")) type = "mousedown";
72964
74178
  if (zot(axis)) axis = accelerator?"horizontal":"both"; // horizontal, vertical, both
@@ -72986,7 +74200,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
72986
74200
  if (zot(firstPerson)) firstPerson = false;
72987
74201
  if (zot(turnSpeed)) turnSpeed = speed * .4;
72988
74202
  if (zot(moveThreshold)) moveThreshold = 4;
72989
- if (zot(stickThreshold)) stickThreshold = .2;
74203
+ if (zot(stickThreshold)) stickThreshold = tileObj?.3:.2;
72990
74204
  if (zot(mouseMoveOutside)) mouseMoveOutside = true;
72991
74205
  stage.mouseMoveOutside = mouseMoveOutside;
72992
74206
  if (zot(mousedownIncludes)) mousedownIncludes = [];
@@ -73066,6 +74280,8 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73066
74280
  var pressing = false;
73067
74281
  var moveCheck = false;
73068
74282
  var under, i, a, gamepad, first;
74283
+ var down = [0,0,0,0];
74284
+ var wasDown = false;
73069
74285
 
73070
74286
  if (type == "keydown" || type == "gamebutton") {
73071
74287
 
@@ -73075,7 +74291,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73075
74291
  for (i=0; i<4; i++) {
73076
74292
  if (!Array.isArray(map[i])) map[i] = [map[i]];
73077
74293
  }
73078
- var down = [0,0,0,0];
74294
+
73079
74295
  var ord = []; // order the keys are pressed - so when we release, we can set to last currently pressed key
73080
74296
  var way = ["X","X","Y","Y"];
73081
74297
  var dir = [-1,1,-1,1];
@@ -73205,6 +74421,8 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73205
74421
  if (mouseEvent4) zim.Ticker.remove(mouseEvent4);
73206
74422
  if (type=="follow") mouseEvent4 = zim.Ticker.add(moveMe);
73207
74423
  if (target.type == "Pen") {
74424
+ target.zpenY = Math.round(target.y);
74425
+ target.zpenX = Math.round(target.x);
73208
74426
  target.write = true;
73209
74427
  target.paper.noMouse(); // no need to drag others while drawing
73210
74428
  target.zimDragCheck = true;
@@ -73212,6 +74430,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73212
74430
  });
73213
74431
  mouseEvent3 = stage.on("stagemouseup", function(){
73214
74432
  if (target.type == "Pen") {
74433
+ if (target.zpenX==Math.round(target.x) && target.zpenY==Math.round(target.y)) target.x+=2
73215
74434
  target.write = false;
73216
74435
  target.paper.mouse();
73217
74436
  target.zimDragCheck = false;
@@ -73247,6 +74466,24 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73247
74466
  }
73248
74467
  }
73249
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
+
73250
74487
  if (firstPerson) {doFirstPerson(d); return;}
73251
74488
 
73252
74489
  that.x += that.speed*d.dirX;
@@ -73261,7 +74498,10 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73261
74498
  });
73262
74499
  }
73263
74500
 
74501
+
73264
74502
  function doDown(e) {
74503
+ wasDown = true;
74504
+ if (tileObj && !that.keyInterval) makeKeyInterval();
73265
74505
  var key = type=="keydown"?e.keyCode:e.buttonCode;
73266
74506
  var inOrd;
73267
74507
  for (i=0; i<4; i++) {
@@ -73280,6 +74520,10 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73280
74520
 
73281
74521
  function doUp(e) {
73282
74522
  var key = type=="keydown"?e.keyCode:e.buttonCode;
74523
+ if (tileObj) {
74524
+ that.x = currentX;
74525
+ that.y = currentY;
74526
+ }
73283
74527
  var inOrd;
73284
74528
  for (i=0; i<4; i++) {
73285
74529
  if (map[i].indexOf(key) > -1) {
@@ -73388,7 +74632,108 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
73388
74632
  var lastDirX=0;
73389
74633
  var lastDirY=0;
73390
74634
 
73391
- 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;
73392
74737
  if (target.draggingCheck) return;
73393
74738
  if (type == "manual") calculate();
73394
74739
  if (that.boundary && that.boundary.type!="Blob") {
@@ -74140,6 +75485,23 @@ function ready() {
74140
75485
  }
74141
75486
  END EXAMPLE
74142
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
+
74143
75505
  PARAMETERS - FOR PHYSICS
74144
75506
  ** supports DUO - parameters or single object with properties below
74145
75507
  gravity - (default 10) the gravity force in the downward direction
@@ -74357,12 +75719,20 @@ contactEnd(call) - run the call function when object's body ends contacts with a
74357
75719
  Also see sensor parameter to trigger contact but with no physics interaction
74358
75720
  noContact() - remove contact call
74359
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
74360
75729
 
74361
75730
  PROPERTIES - FOR OBJECTS - see also BODY PROPERTIES below
74362
75731
  dynamic - set to true for dynamic and false for static
74363
75732
  there is also kinematic that can be set using the obj.body.SetType(1)
74364
75733
  speed - get or set the speed of an object that is controlled by control()
74365
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
74366
75736
  ** normal x, y, rotation or pos(), loc(), rot() will not work with physics!
74367
75737
  ** see the BODY loc(x,y) METHOD and the rotation PROPERTY below
74368
75738
  ** these should really not be set at all in the physics world
@@ -74421,7 +75791,7 @@ b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
74421
75791
  b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController;
74422
75792
  b2ContactListener = Box2D.Dynamics.b2ContactListener;
74423
75793
  --*///+69.97
74424
- WW.zimContactListener = null; // global so dispose() in physics can access this
75794
+ WW.zimContactListener = null; // global so the dispose() in physics can access this
74425
75795
  var zimContactBeginList;
74426
75796
  var zimContactEndList;
74427
75797
  function setPhysics(obj, dynamic, contract, shape, friction, linear, angular, density, restitution, maskBits, categoryBits, sensor) {
@@ -74569,6 +75939,28 @@ b2ContactListener = Box2D.Dynamics.b2ContactListener;
74569
75939
  zimContactEndList.remove(obj.body);
74570
75940
  return obj;
74571
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
+ };
74572
75964
  if (!obj.hasOwnProperty("dynamic")) {
74573
75965
  Object.defineProperty(obj, 'dynamic', {
74574
75966
  get: function() {
@@ -84886,7 +86278,7 @@ zim.scaY = 1;
84886
86278
  // Zim Frame provides code to help you set up your coding environment
84887
86279
 
84888
86280
  /*--
84889
- 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)
84890
86282
 
84891
86283
  Frame
84892
86284
  zim class - extends a createjs EventDispatcher
@@ -85272,6 +86664,7 @@ loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, cr
85272
86664
  It is recommended to use the Queue any time you use multiple LoadAssets() calls at the same time
85273
86665
  You still access assets with asset() as outlined below whether you use the Queue or not
85274
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()
85275
86668
  file is the string name or url to the file
85276
86669
  if the asset was loaded with a string then use the string (less the path if provided)
85277
86670
  if the asset was loaded with a full URL then use the full URL here
@@ -85497,7 +86890,7 @@ EVENTS
85497
86890
  and then perhaps constrain the value - here the scale is constrained between .5 and 5
85498
86891
  note - when changing scale, it is better to multiply by a factor rather than add to the scale
85499
86892
  eg. circle.scale = constrain(circle.scale*(sign(e.deltaY)>0?.75:1.25), .5, 5);
85500
- "deviceorientation" - MUST SET Frame sensors parameter to true
86893
+ "deviceorientation" - turned on when using ZIM PermissionAsk()
85501
86894
  fired as device orientation changes:
85502
86895
  eventObject.rotation.x (beta in HTML specs) holds rotation about the x axis between -180 and 180 (tipped forward or backward)
85503
86896
  eventObject.rotation.y (gamma in HTML specs) holds rotation about the y axis between -90 and 90 (tipped left or right)
@@ -85506,14 +86899,16 @@ EVENTS
85506
86899
  note also that beta, gamma and alpha from the HTML 5 specs are also provided
85507
86900
  eg.
85508
86901
  var label = new Label().center();
86902
+ // Note: MUST USE PermissionAsk()
85509
86903
  F.on("deviceorientation", function(e) {
85510
86904
  label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
85511
86905
  S.update();
85512
86906
  });
85513
- "devicemotion" - MUST SET Frame sensors parameter to true
86907
+ "devicemotion" - turned on when using ZIM PermissionAsk()
85514
86908
  fired on moving mobile device - like a tilt or shake - eventObject.acceleration holds x, y and z properties of motion
85515
86909
  eg.
85516
86910
  var label = new Label().center();
86911
+ // Note: MUST USE PermissionAsk()
85517
86912
  F.on("devicemotion", function(e) {
85518
86913
  label.text = e.acceleration.x +","+ e.acceleration.y +","+ e.acceleration.z;
85519
86914
  S.update();
@@ -85537,8 +86932,8 @@ NOTE: if loadAssets() queueOnly parameter is true, then only the queue receives
85537
86932
  and if loadAssets() or lazy-load with asset() are used then the error event must be captured outside the complete event
85538
86933
 
85539
86934
  --*///+83
85540
- 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) {
85541
- 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";
85542
86937
  var duo; if (duo = zob(zim.Frame, arguments, sig, this)) return duo;
85543
86938
  z_d("83");
85544
86939
  if (zon) zogg("ZIM FRAME");
@@ -85597,7 +86992,6 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
85597
86992
  if (zot(allowDefault)) allowDefault = false;
85598
86993
  if (zot(loadFailObj)) loadFailObj = "circles";
85599
86994
  this.loadFailObj = loadFailObj;
85600
- if (zot(sensors)) sensors = false;
85601
86995
  if (zot(retina)) retina = true;
85602
86996
  this.retina = retina;
85603
86997
  if (zot(mouseMoveOutside)) mouseMoveOutside = false;
@@ -85857,6 +87251,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
85857
87251
  }
85858
87252
  }
85859
87253
 
87254
+
85860
87255
  // 5. part of TEN PATCH
85861
87256
  // adjusted checkDispatch to check for resize and assets separately
85862
87257
  // previously, it was as long as there were two checks dispatch!
@@ -86281,14 +87676,18 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86281
87676
 
86282
87677
  // ASSETS
86283
87678
  this.loadAssets = function(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, crossOrigin, fileType, queueOnly, maxConnections, maxNum) {
86284
-
86285
87679
  if (zot(assets)) return endEarly();
86286
87680
  if (zot(assets.src)) { // might be sending single parameter of asset object or audiosprite
86287
87681
  var sig = "assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, crossOrigin, fileType, queueOnly, maxConnections, maxNum";
86288
87682
  var duo; if (duo = zob(that.loadAssets, arguments, sig)) return duo;
86289
87683
  }
86290
- if (!zot(path)) WW.PATH = path;
86291
- // 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;
86292
87691
  var timeType = getTIME(time?time:null);
86293
87692
  if (!zot(progress) && progress.type == "ProgressBar" && zot(xhr)) xhr = true;
86294
87693
  if (zot(xhr)) xhr = true;
@@ -86315,15 +87714,20 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86315
87714
  var soundCheck = false;
86316
87715
  var manifest = [];
86317
87716
  var a, ext, i, j, obj;
86318
- var re = /\.([^.]+)$/i; // get extension
87717
+ var re = /\.([^.]+)$/i; // get extension
86319
87718
  var fonts = [];
86320
87719
  var googleFonts = [];
86321
87720
  var imagesNoCORS = [];
86322
87721
  var mainCount = 0;
86323
87722
  var firstSoundCheck = true;
86324
-
87723
+ var emptyAssets = false;
87724
+
86325
87725
  for (i=0; i<assets.length; i++) {
86326
87726
  a = assets[i];
87727
+ if (zim.assets[a]) {
87728
+ if (assets.length==1) emptyAssets = true;
87729
+ continue;
87730
+ }
86327
87731
  if (a.replace) a = a.replace(/gf_/i, "https://fonts.googleapis.com/css?family=");
86328
87732
  // split multi into individual ZIM asset objects and make the first of these
86329
87733
  if (a.assets) {
@@ -86335,7 +87739,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86335
87739
  if (aj.split) {
86336
87740
  var temp = aj.split("?");
86337
87741
  ext = temp[0].match(re);
86338
- }
87742
+ }
86339
87743
  if (ext && fontTypes.indexOf(ext[1]) >= 0) {
86340
87744
  fonts.push((a.path?a.path:"")+aj);
86341
87745
  } else if (aj.match && aj.match(/fonts\.googleapis\.com/i)) {
@@ -86390,6 +87794,8 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86390
87794
  } else if (a.id || a.path) { // ZIM asset object
86391
87795
  if (!a.id) a.id = a.src;
86392
87796
  if (a.path) {
87797
+ a.path = a.path.replace(/\/$/,"");
87798
+ a.path = a.path + "/";
86393
87799
  var url, found;
86394
87800
  if (a.path.match(/http/i)) {
86395
87801
  a.src = a.path+a.src;
@@ -86498,6 +87904,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86498
87904
  mainCount++;
86499
87905
  return ext;
86500
87906
  }
87907
+
86501
87908
  that.loadAssetsCount++;
86502
87909
  that.isLoading = true;
86503
87910
  var queue = new zim.Queue();
@@ -86599,10 +88006,10 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86599
88006
  if (soundCheck) preload.installPlugin(createjs.Sound);
86600
88007
 
86601
88008
  preload.on("progress", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
86602
- preload.on("error", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
88009
+ preload.on("error", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
86603
88010
  preload.on("fileload", function(e) {
86604
88011
  // for some reason, errors are not working on IMG and SVG from PreloadJS
86605
- // so check for rawResult - should really fix this in CreateJS
88012
+ // so check for rawResult - should really fix this in CreateJS
86606
88013
  if (!e.result || ((e.result.nodeName=="IMG" || e.result.nodeName=="SVG") && !e.rawResult && xhr)) {
86607
88014
  var ev = new createjs.Event("error");
86608
88015
  ev = new createjs.Event("error");
@@ -86699,12 +88106,13 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86699
88106
  that.dispatchEvent(ev);
86700
88107
  }
86701
88108
  }
86702
- });
88109
+ });
88110
+
86703
88111
  that.preloadEvent = preload.on("complete", function(e) {
86704
88112
  completeEventObject = e;
86705
88113
  queue.loadAssetsCount--;
86706
88114
  if (queue.loadAssetsCount == 0) endAssetLoad();
86707
- });
88115
+ });
86708
88116
  try {preload.loadManifest(manifest);}catch(err){
86709
88117
  +function(){}()
86710
88118
  }
@@ -86717,6 +88125,11 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86717
88125
 
86718
88126
  } // end non font/noCORSonImage
86719
88127
 
88128
+ // if calling an already preloaded asset
88129
+ if (emptyAssets && queue.loadAssetsCount == 0) {
88130
+ endAssetLoad();
88131
+ }
88132
+
86720
88133
  function endAssetLoad() {
86721
88134
  // setting a time will force the preload to wait at least this amount of time
86722
88135
  // this can be used for testing or if you always want time to show a loading message
@@ -86762,7 +88175,10 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
86762
88175
  // now check auto load assets or broken if second
86763
88176
 
86764
88177
  if (WW.PATH!=null) zim.PATH = WW.PATH;
86765
-
88178
+ if (zim.PATH!=null) {
88179
+ zim.PATH.replace(/\/$/,"");
88180
+ zim.PATH = zim.PATH + "/";
88181
+ }
86766
88182
  if (second) {
86767
88183
  var empty;
86768
88184
  if (that.loadFailObj == "circles") empty = that.makeCircles(14);
@@ -87298,9 +88714,9 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87298
88714
  WW.addEventListener("contextmenu", contextEvent, false);
87299
88715
 
87300
88716
  var eDown = new createjs.Event("keydown");
87301
- this.eventRemove = eDown.remove;
88717
+ this.downEventRemove = eDown.remove;
87302
88718
  function keydownEvent(e) {
87303
- e.remove = that.eventRemove;
88719
+ e.remove = that.downEventRemove;
87304
88720
  that.altKey = e.altKey;
87305
88721
  that.ctrlKey = e.ctrlKey;
87306
88722
  that.metaKey = e.metaKey;
@@ -87311,47 +88727,23 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87311
88727
  }
87312
88728
  // var realWindow = window.parent || window;
87313
88729
  WW.addEventListener("keydown", keydownEvent);
88730
+
88731
+ var eUp = new createjs.Event("keyup");
88732
+ this.upEventRemove = eUp.remove;
87314
88733
  function keyupEvent(e) {
87315
88734
  that.altKey = e.altKey;
87316
88735
  that.ctrlKey = e.ctrlKey;
87317
88736
  that.metaKey = e.metaKey;
87318
88737
  that.shiftKey = e.shiftKey;
87319
- e.remove = that.eventRemove;
88738
+ e.remove = that.upEventRemove;
87320
88739
  that.dispatchEvent(e);
87321
- }
88740
+ }
87322
88741
  WW.addEventListener("keyup", keyupEvent);
87323
- function wheelEvent(e) {
87324
- that.dispatchEvent(e);
87325
- }
87326
- WW.addEventListener("wheel", wheelEvent);
87327
- function devicemotionEvent(e) {
87328
- e.remove = that.eventRemove;
88742
+
88743
+ function wheelEvent(e) {
87329
88744
  that.dispatchEvent(e);
87330
88745
  }
87331
- if (sensors && WW.DeviceMotionEvent) {
87332
- WW.addEventListener("devicemotion",devicemotionEvent);
87333
- }
87334
- function deviceorientationEvent(e) {
87335
- e.remove = that.eventRemove;
87336
- // for some reason, reporting alpha as increasing going counter counterclockwise
87337
- // so this code makes it increase going clockwise
87338
- var z = 360-e.alpha;
87339
- // compass is subtracting 180 if device screen is pointing down
87340
- // in a VR helmet this would be looking slightly up from the horizon...
87341
- // so removing this flip with the following code
87342
- if (Math.abs(z-lastZ) > 180 - 45 && Math.abs(z-lastZ) < 180 + 45) flip = flip == 0 ? 180 : 0;
87343
- lastZ = z;
87344
- e.rotation = {x:e.beta, y:e.gamma, z:(z + flip) % 360};
87345
- that.dispatchEvent(e);
87346
- }
87347
- if (sensors && WW.DeviceOrientationEvent) {
87348
- // zim.timeout(.2, function () {
87349
- // that.dispatchEvent("yes");
87350
- // });
87351
- var lastZ = 0;
87352
- var flip = 0;
87353
- WW.addEventListener("deviceorientation",deviceorientationEvent);
87354
- }
88746
+ WW.addEventListener("wheel", wheelEvent);
87355
88747
 
87356
88748
  this.isFullscreen = document.fullscreenElement?true:false;
87357
88749
  this.htmlobc = zet("html").css("backgroundColor");
@@ -87564,14 +88956,14 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
87564
88956
  WW.removeEventListener("keydown", keydownEvent); // thanks Reinout Mechant for the fix!
87565
88957
  WW.removeEventListener("keyup", keyupEvent);
87566
88958
  WW.removeEventListener("wheel", wheelEvent);
87567
- WW.removeEventListener("devicemotion", devicemotionEvent);
87568
- WW.removeEventListener("deviceorientation", deviceorientationEvent);
88959
+ if (that.zimDevicemotionEvent) WW.removeEventListener("devicemotion", that.zimDevicemotionEvent);
88960
+ if (that.zimDeviceorientationEvent) WW.removeEventListener("deviceorientation", that.zimDeviceorientationEvent);
87569
88961
 
87570
88962
  WW.removeEventListener("mousedown", leftEvent, true);
87571
88963
  WW.removeEventListener("mousemove", leftEvent, true);
87572
88964
  WW.removeEventListener("mouseup", leftEvent);
87573
88965
 
87574
- if (!allowDefault) document.body.style.overflow = "auto";
88966
+ if (!allowDefault) document.body.style.overflow = "athatuto";
87575
88967
  recursiveDispose(stage);
87576
88968
  function recursiveDispose(obj) {
87577
88969
  if (!obj) return;
@@ -88611,6 +90003,11 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
88611
90003
  that.file = file;
88612
90004
 
88613
90005
  if (WW.PATH!=null) zim.PATH = WW.PATH;
90006
+ if (zim.PATH!=null) {
90007
+ zim.PATH.replace(/\/$/,"");
90008
+ zim.PATH = zim.PATH + "/";
90009
+ }
90010
+
88614
90011
  var added = "";
88615
90012
  if (file.split("/").length==1 && zim.PATH) added = zim.PATH;
88616
90013
  this.mouseChildren = false;
@@ -88748,6 +90145,119 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
88748
90145
  }
88749
90146
  zim.extend(zim.Vid, zim.Container, ["clone", "dispose"], "zimContainer", false);//-83.07
88750
90147
 
90148
+ //
90149
+ /*--
90150
+ Dat = function(file)
90151
+
90152
+ Dat
90153
+ zim class - extends a createjs EventDispatcher
90154
+
90155
+ DESCRIPTION
90156
+ Use Dat() to load data files like text, csv, XML and json.
90157
+ Then use the data property to get the data.
90158
+
90159
+ Before ZIM version ZIM 018 the Frame asset() method was used for data
90160
+ and asset(file) can still be used - the Dat() class is a wrapper class to match Pic(), Aud(), etc.
90161
+ It is just a dozen lines long.
90162
+
90163
+ PRELOADING
90164
+ It is recommended that you preload data files using the Frame() assets and path parameters.
90165
+ After the frame loads, data files can also be loaded on demand with F.loadAssets().
90166
+
90167
+ LAZY-LOADING
90168
+ The data file can be lazy loaded at which point the data property will be available in a complete or ready event
90169
+
90170
+ Dat will give a "ready" and a "complete" event when loaded.
90171
+ These events are triggered 20 ms after making the object if the object is already preloaded.
90172
+
90173
+ See: https://zimjs.com/018/dat.html
90174
+
90175
+ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
90176
+
90177
+ EXAMPLE
90178
+ // loading a text file with some text
90179
+ new Frame(FIT, 1024, 768, light, dark, ready, "data.txt", "assets/");
90180
+ function ready() {
90181
+ const data = new Dat("data.txt").data;
90182
+ new Label(data).center();
90183
+ }
90184
+ END EXAMPLE
90185
+
90186
+ EXAMPLE
90187
+ // loading a JSON file with {"test":"complete"}
90188
+ new Frame(FIT, 1024, 768, light, dark, ready, "data.json", "assets/");
90189
+ function ready() {
90190
+ const data = new Dat("data.json").data;
90191
+ new Label(data.test).center(); // will say complete
90192
+ }
90193
+ END EXAMPLE
90194
+
90195
+ EXAMPLE
90196
+ // loading an XML file with <test>complete</test>
90197
+ new Frame(FIT, 1024, 768, light, dark, ready, "data.xml", "assets/");
90198
+ function ready() {
90199
+ const data = new Dat("data.xml").data;
90200
+ // also children property and getAttribute() method, etc.
90201
+ new Label(data.innerHTML).center(); // will say complete
90202
+ }
90203
+ // also see https://zimjs.com/018/dat.html for looping through multiple tags
90204
+ END EXAMPLE
90205
+
90206
+ EXAMPLE
90207
+ // lazy loading a text file with some text
90208
+ new Frame(FIT, 1024, 768, light, dark, ready);
90209
+ function ready() {
90210
+ const text = new Dat("assets/data.txt");
90211
+ data.on("complete", ()=>{
90212
+ new Label(text.data).center();
90213
+ });
90214
+ }
90215
+ END EXAMPLE
90216
+
90217
+ PARAMETERS
90218
+ file - the file provided to the Frame class (or Frame loadAssets method) assets parameter
90219
+ or if not preloaded then the file to lazy load - then must wait for the complete or ready event
90220
+
90221
+ PROPERTIES
90222
+ type - holds the class name as a String
90223
+ data - the data such as the text for a txt file or will be a JSON parsed object for a JSON file
90224
+
90225
+ EVENTS
90226
+ dispatches a "complete" and a "ready" event
90227
+ used primarily for lazy loading of the file
90228
+ if preloaded then the Frame or loadAsssets ready event is all that is needed
90229
+ there will be a complete or ready event on the Dat() dispatched 20 ms later for compatibility
90230
+ --*///+83.08
90231
+ zim.Dat = function(file) {
90232
+ z_d("83.08");
90233
+ this.type = "Dat";
90234
+ var asset = zim.asset(file);
90235
+ var that = this;
90236
+ if (asset && asset.type != "AC") {
90237
+ if (asset.documentElement) asset = asset.documentElement;
90238
+ that.data = asset;
90239
+ setTimeout(function() {
90240
+ that.dispatchEvent("ready");
90241
+ that.dispatchEvent("complete");
90242
+ }, 20);
90243
+ } else {
90244
+ if (WW.PATH!=null) zim.PATH = WW.PATH;
90245
+ if (zim.PATH!=null) {
90246
+ zim.path.replace(/\/$/,"");
90247
+ zim.path = zim.path + "/";
90248
+ }
90249
+ var loader = zdf.loadAssets(file, zim.PATH);
90250
+ loader.on("complete", function() {
90251
+ var asset = zim.asset(file);
90252
+ if (asset.documentElement) asset = asset.documentElement;
90253
+ that.data = asset;
90254
+ that.dispatchEvent("ready");
90255
+ that.dispatchEvent("complete");
90256
+ });
90257
+ }
90258
+ }
90259
+ zim.extend(zim.Dat, createjs.EventDispatcher, null, "cjsEventDispatcher", false);//-83.08
90260
+
88751
90261
  /*--
88752
90262
  SVG = function(svg, width, height, bitmap, splitTypes, geometric, showControls, interactive, style, group, inherit)
88753
90263
 
@@ -88825,6 +90335,23 @@ new Tile(new SVG("file.svg", 100, 100), 4, 4)).center();
88825
90335
  // would be better to preload - see next example
88826
90336
  END EXAMPLE
88827
90337
 
90338
+ EXAMPLE
90339
+ // Adding Physics to an SVG
90340
+ // Must import zim_physics or have Physics checked in the Editor
90341
+ // cannot make a Bitmap until SVG is made:
90342
+ const physics = new Physics();
90343
+ const svg = new SVG("file.svg");
90344
+ svg.on("complete", ()=>{
90345
+ const bitmap = new Bitmap(svg).center();
90346
+ const blob = new Blob({
90347
+ points:simplifyPoints(outlineImage(bitmap), 10),
90348
+ color:faint,
90349
+ interactive:false
90350
+ }).loc(bitmap).addPhysics();
90351
+ bitmap.addTo(blob);
90352
+ });
90353
+ END EXAMPLE
90354
+
88828
90355
  EXAMPLE
88829
90356
  // pre-load and Tile an SVG
88830
90357
  new Frame(FIT, 1024, 768, light, grey, ready, "file.svg", "assets/");
@@ -88944,13 +90471,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
88944
90471
  if (width && height) this.type = "ACWD"; // AssetContainer with Dimensions - does not recall methods
88945
90472
  else this.type = "AC"; // AssetContainer
88946
90473
 
88947
-
90474
+ var svgO = svg;
90475
+ var fromID = zim.assetIDs[svg];
90476
+ if (fromID) svg = fromID;
88948
90477
  var a = zim.assets[svg];
88949
90478
  if (a) {
88950
90479
  that.src = a.src;
88951
90480
  that.file = a.file;
88952
90481
  that.item = a.item;
88953
- that.svg = a.svg;
90482
+ that.svg = a.svgO;
88954
90483
  }
88955
90484
  if (a && a.type=="Bitmap") {
88956
90485
  that.type = "SVG";
@@ -88975,7 +90504,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
88975
90504
  else that.bitmap = a.clone();
88976
90505
  getSVG();
88977
90506
  } else {
88978
- if (svg && svg.match(/<svg/i)) that.svg = svg;
90507
+ if (svgO && svgO.match(/<svg/i)) that.svg = svgO;
88979
90508
  if (that.svg && that.svg.match(/<svg/i)) {
88980
90509
  that.type = "SVG";
88981
90510
  getSVG();
@@ -89070,7 +90599,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89070
90599
 
89071
90600
  if (style!==false) zim.styleTransforms(this, DS);
89072
90601
  that.clone = function (exact) {
89073
- return this.cloneProps(new zim.SVG(exact?svg:originalSVG, width, height, bitmap, splitTypes, geometric, showControls, interactive, style, this.group, inherit));
90602
+ return this.cloneProps(new zim.SVG(exact?svgO:originalSVG, width, height, bitmap, splitTypes, geometric, showControls, interactive, style, this.group, inherit));
89074
90603
  }
89075
90604
  }
89076
90605
  zim.extend(zim.SVG, zim.Container, ["clone"], "zimContainer", false);//-83.09
@@ -89173,9 +90702,10 @@ dispatches "result" when either as each word is spoken if listen() is used (inte
89173
90702
  and a confidence property that is a ratio (0-1) for confidence in the result
89174
90703
  Note: iOS (at this time) does not support the listen() and result event
89175
90704
  dispatches "speechend" events when listen() has detected an end to the talking
90705
+ dispatches "start", "end" events
90706
+ dispatches a "boundary" event between words
89176
90707
  dispatches an "error" event if no words are spoken, etc. the event object has an error property with the error message
89177
- dispatches "start", "end" and "error" on the utterance object returned by talk()
89178
- Note: there are more features to the Web Speech API - see the HTML docs
90708
+ Note: there are more features to the Web Speech API - see the HTML docs
89179
90709
  --*///+83.095
89180
90710
  zim.Speech = function() {
89181
90711
  z_d("83.095");
@@ -89241,6 +90771,7 @@ dispatches "start", "end" and "error" on the utterance object returned by talk()
89241
90771
  var utter = new SpeechSynthesisUtterance();
89242
90772
  utter.addEventListener("start", function(e) {that.dispatchEvent(e);});
89243
90773
  utter.addEventListener("end", function(e) {that.dispatchEvent(e);});
90774
+ utter.addEventListener("boundary", function(e) {that.dispatchEvent(e);});
89244
90775
  utter.addEventListener("error", function(e) {that.dispatchEvent(e);});
89245
90776
 
89246
90777
  if (voice && typeof voice == "string" && that.voiceLookup) voice = that.voiceLookup[voice];
@@ -89370,12 +90901,12 @@ and a keyboardMessage() method to prompt for keyboard interactivity.
89370
90901
  When an app is first loaded it cannot receive keyboard events until it is interacted with.
89371
90902
  Interaction must be a mousedown or click - not just an over or move interaction.
89372
90903
  Often, we will make an intro Pane() or play Button() for a game, for instance, before playing sounds.
89373
- In ZIM 014 we added a keyboardMessage() method to prompt for an interaction so key events are activated.
90904
+ In ZIM 014 we added a keyboardMessage() method to the Frame to prompt for an interaction so key events are activated.
89374
90905
 
89375
90906
  Also see ZIM Keyboard(), TextEditor(), TextInput() and MotionController() for various keyboard functionality.
89376
90907
 
89377
90908
  EXAMPLE
89378
- keyboardMessage(); // will prompt for keyboard control
90909
+ F.keyboardMessage(); // will prompt for keyboard control
89379
90910
  F.on("keydown", e=>{
89380
90911
  zog(e.key) // a string of the keypress
89381
90912
  zog(e.keyCode) // the numeric code of the keypress (older but used in lots of examples)
@@ -89455,6 +90986,7 @@ END EXAMPLE
89455
90986
 
89456
90987
  EXAMPLE
89457
90988
  // on iOS, the sensors must be allowed first - this example works for all devices
90989
+ const label = new Label().center();
89458
90990
  const permissionType = "deviceorientation"; // or "devicemotion"
89459
90991
  const ask = new PermissionAsk(init, permissionType);
89460
90992
  function init(yes) {
@@ -89462,7 +90994,10 @@ function init(yes) {
89462
90994
  const errorPane = new Pane("SENSOR not available",yellow);
89463
90995
  if (yes) {
89464
90996
  // use the sensors
89465
- label.text = decimals(e.rotation.x) +","+ decimals(e.rotation.y) +","+ decimals(e.rotation.z);
90997
+ F.on("deviceorientation", e=>{
90998
+ label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
90999
+ S.update();
91000
+ });
89466
91001
  S.update();
89467
91002
  } else { // answered no to PermissionAsk dialog
89468
91003
  errorPane.show();
@@ -89508,32 +91043,61 @@ A circular confirmation widget to ask the user if they want a permission for iOS
89508
91043
  For some iOS permissions, the app needs to be interactive with first before permission can be asked!
89509
91044
  This is for iOS only - if not in iOS then will just pass through the test.
89510
91045
 
91046
+ Also adds Frame deviceorientation and devicemotion events for a matching permissionType.
91047
+ Pre ZIM 018, this was done with a sensors parameter on the Frame.
91048
+ The sensors parameter has now been removed and the events are handled with PermissionAsk.
91049
+
89511
91050
  NOTE: this started as SensorAsk but the class has been adjusted to handle other permissions and the name has been changed in ZIM 016
89512
91051
 
89513
91052
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
89514
91053
 
89515
91054
  EXAMPLE
89516
- // on iOS, the sensors must be allowed first
89517
- const permissionType = "deviceorientation"; // or "devicemotion"
91055
+ // DEVICE ORIENTATION - gives angle of device in all 3 dimensions
91056
+ // Note: this is NOT an orientation event to see if phone is portrait or landscape (see Frame orientation event)
91057
+ // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
91058
+
91059
+ const permissionType = "deviceorientation";
89518
91060
  const ask = new PermissionAsk(init, permissionType);
89519
- function init(yes) {
89520
- // if the user answers yes to the PermissionAsk
89521
- const errorPane = new Pane("SENSOR not available",yellow);
89522
- if (yes) {
91061
+ function init(yes) {
91062
+ const errorPane = new Pane("SENSOR not available",yellow);
91063
+ if (yes) { // the user answers yes to the PermissionAsk
91064
+ // use the sensors
91065
+ const label = new Label("on mobile").centerReg();
91066
+ F.on("deviceorientation", e=>{
91067
+ // use the sensors
91068
+ label.text = label.text = "x: "+decimals(e.rotation.x) +"\ny: "+ decimals(e.rotation.y) +"\nz: "+ decimals(e.rotation.z);
91069
+ S.update();
91070
+ });
91071
+ } else { // the user answered no to PermissionAsk dialog
91072
+ errorPane.show();
91073
+ }
91074
+ }
91075
+ END EXAMPLE
91076
+
91077
+ EXAMPLE
91078
+ // DEVICE MOTION - gives accelerometer values in all 3 dimensions
91079
+ // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
91080
+
91081
+ const permissionType = "devicemotion";
91082
+ const ask = new PermissionAsk(init, permissionType);
91083
+ function init(yes) {
91084
+ const errorPane = new Pane("SENSOR not available",yellow);
91085
+ if (yes) { // the user answers yes to the PermissionAsk
89523
91086
  // use the sensors
89524
- const label = new Label({text:"test on mobile", align:CENTER}).centerReg();
91087
+ const label = new Label("on mobile").centerReg();
89525
91088
  F.on("devicemotion", e=>{
89526
91089
  // use the sensors
89527
- label.text = decimals(e.rotation.x) +","+ decimals(e.rotation.y) +","+ decimals(e.rotation.z);
91090
+ label.text = "x: "+decimals(e.acceleration.x, 3) +"\ny: "+ decimals(e.acceleration.y, 3) +"\nz: "+ decimals(e.acceleration.z, 3);
89528
91091
  S.update();
89529
- })
89530
- } else { // answered no to PermissionAsk dialog
91092
+ });
91093
+ } else { // the user answered no to PermissionAsk dialog
89531
91094
  errorPane.show();
89532
91095
  }
89533
91096
  }
89534
91097
  END EXAMPLE
89535
91098
 
89536
91099
  EXAMPLE
91100
+ // on iOS, the app must be interacted with before using mic or cam
89537
91101
  // goes right to permissions on computer and android
89538
91102
  // pops up a PermissionAsk Pane on iOS then if yes, goes to permissions on iOS
89539
91103
  new PermissionAsk(init, "cam");
@@ -89549,7 +91113,7 @@ EXAMPLE
89549
91113
  // but pops up a PermissionAsk Pane on iOS then if yes, goes to permissions on iOS
89550
91114
  new PermissionAsk(init, "mic"); // or "cam" or "miccam"
89551
91115
  function init(val) {
89552
- zog(val); // media stream if yes to permissions otherwise false
91116
+ new Label(val).center(); // media stream if yes to permissions otherwise false
89553
91117
  S.update();
89554
91118
  }
89555
91119
  END EXAMPLE
@@ -89601,7 +91165,7 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
89601
91165
  zim.PermissionAsk = function(callback, permissionType, color, backgroundColor, style, group, inherit) {
89602
91166
  var sig = "callback, permissionType, color, backgroundColor, style, group, inherit";
89603
91167
  var duo; if (duo = zob(zim.PermissionAsk, arguments, sig, this)) return duo;
89604
- z_d("83.01");
91168
+ z_d("83.01");
89605
91169
 
89606
91170
  this.group = group;
89607
91171
  var DS = style===false?{}:zim.getStyle("PermissionAsk", this.group, inherit);
@@ -89627,42 +91191,21 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
89627
91191
  borderWidth:2
89628
91192
  });
89629
91193
  var pt = permissionType;
89630
- that.yes = new zim.Button({label:"YES", group:"PermissionAsk"}).sca(.65).pos(0,30,CENTER,TOP,this).tap(function() {
89631
- that.hide(true);
89632
- if (pt == "mic" || pt == "cam" || pt == "miccam") {
89633
- if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
89634
- navigator.mediaDevices.getUserMedia({audio: (pt=="mic" || pt=="miccam"), video:(pt=="cam" || pt=="miccam") })
89635
- .then(function(stream) {
89636
- callback(stream);
89637
- })
89638
- .catch(function(err) {
89639
- callback(false);
89640
- });
89641
- } else callback(false);
89642
- } else {
89643
- var s = DeviceMotionEvent;
89644
- if (pt != "devicemotion") s = DeviceOrientationEvent;
89645
- s.requestPermission().then(function(result) {
89646
- if (result != "denied") callback(true);
89647
- else callback(false);
89648
- });
89649
- }
89650
- });
91194
+ var okay = false;
91195
+ that.yes = new zim.Button({label:"YES", group:"PermissionAsk"}).sca(.65).pos(0,30,CENTER,TOP,this);
89651
91196
  var words = {deviceorientation:"sensors", devicemotion:"sensors", mic:"mic", cam:"cam", miccam:"mic/cam"};
89652
91197
  that.label = new zim.Label("Use " + (words[pt]?words[pt]:"feature") + "?", 30, null, color, null, null, null, "center").sca(.9).centerReg(this);
89653
- that.no = new zim.Button({label:"NO", group:"PermissionAsk"}).sca(.65).pos(0,30,CENTER,BOTTOM,this).tap(function() {
89654
- that.hide(false);
89655
- callback(false);
89656
- });
91198
+ that.no = new zim.Button({label:"NO", group:"PermissionAsk"}).sca(.65).pos(0,30,CENTER,BOTTOM,this);
89657
91199
 
89658
91200
  new zim.Circle(110, zim.clear, color, 1).center(this).alp(.8);
89659
91201
  new zim.Circle(120, zim.clear, color, 1).center(this).alp(.5);
89660
91202
  new zim.Circle(130, zim.clear, color, 1).center(this).alp(.2);
89661
91203
  if (style!==false) zim.styleTransforms(this, DS);
89662
91204
 
91205
+ var frame = WW.zdf;
89663
91206
  if (pt == "mic" || pt == "cam" || pt == "miccam") {
89664
- if (M=="ios") {
89665
- that.show();
91207
+ if (M=="ios") {
91208
+ setPane();
89666
91209
  return;
89667
91210
  }
89668
91211
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
@@ -89679,26 +91222,96 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
89679
91222
 
89680
91223
  // sensors only
89681
91224
  if (typeof DeviceOrientationEvent != "undefined" && DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission == "function") {
89682
- that.show();
91225
+ setPane();
89683
91226
  } else {
89684
91227
  var called = false;
89685
91228
  WW.addEventListener(permissionType, testMe);
89686
91229
  // instead of testing for mobile - some laptops like chromebook have sensors so test for a reading
89687
91230
  function testMe(e) {
91231
+ if (okay) return;
89688
91232
  if (permissionType=="deviceorientation") {
89689
91233
  if (e.alpha==null || (e.alpha==0&&e.beta==0&&e.gamma==0)) callback(false);
89690
- else callback(true);
91234
+ else setEvents();
89691
91235
  } else {
89692
- if (!e.acceleration || e.acceleration.x==null || (e.acceleration.x==0&&e.acceleration.y==0&&e.acceleration.z==0)) callback(false);
89693
- else callback(true);
91236
+ // if (!e.acceleration || e.acceleration.x==null || (e.acceleration.x==0&&e.acceleration.y==0&&e.acceleration.z==0)) callback(false);
91237
+ if (!e.acceleration || e.acceleration.x==null) callback(false);
91238
+ else setEvents();
89694
91239
  }
89695
91240
  called = true;
89696
- WW.removeEventListener(permissionType, testMe);
91241
+ WW.removeEventListener(permissionType, testMe);
89697
91242
  }
89698
91243
  setTimeout(function(){
89699
91244
  if (!called) callback(false);
89700
91245
  }, 100);
89701
91246
  }
91247
+
91248
+ var lastZ = 0;
91249
+ var flip = 0;
91250
+ function deviceorientationEvent(e) {
91251
+ // for some reason, reporting alpha as increasing going counter counterclockwise
91252
+ // so this code makes it increase going clockwise
91253
+ var z = 360-e.alpha;
91254
+ // compass is subtracting 180 if device screen is pointing down
91255
+ // in a VR helmet this would be looking slightly up from the horizon...
91256
+ // so removing this flip with the following code
91257
+ if (Math.abs(z-lastZ) > 180 - 45 && Math.abs(z-lastZ) < 180 + 45) flip = flip == 0 ? 180 : 0;
91258
+ lastZ = z;
91259
+ e.rotation = {x:e.beta, y:e.gamma, z:(z + flip) % 360};
91260
+ frame.dispatchEvent(e);
91261
+ }
91262
+ function devicemotionEvent(e) {
91263
+ frame.dispatchEvent(e);
91264
+ }
91265
+ function setEvents() {
91266
+ if (permissionType=="deviceorientation") {
91267
+ frame.zimDeviceorientationEvent = deviceorientationEvent;
91268
+ WW.addEventListener("deviceorientation", frame.zimDeviceorientationEvent);
91269
+ } else {
91270
+ frame.zimDevicemotionEvent = devicemotionEvent;
91271
+ WW.addEventListener("devicemotion", frame.zimDevicemotionEvent);
91272
+ }
91273
+ callback(true);
91274
+ }
91275
+
91276
+ function setPane() {
91277
+ frame.canvas.style.pointerEvents = "none";
91278
+ that.show();
91279
+ document.addEventListener("mousedown", kmd);
91280
+ }
91281
+
91282
+ function kmd (e) {
91283
+ frame.canvas.style.pointerEvents = "auto";
91284
+ document.removeEventListener("mousedown", kmd);
91285
+ that.hide(true);
91286
+ if (e.clientY-frame.y <= that.y*frame.scale/2) { // yes
91287
+ if (pt == "mic" || pt == "cam" || pt == "miccam") {
91288
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
91289
+ navigator.mediaDevices.getUserMedia({audio: (pt=="mic" || pt=="miccam"), video:(pt=="cam" || pt=="miccam") })
91290
+ .then(function(stream) {
91291
+ callback(stream);
91292
+ })
91293
+ .catch(function(err) {
91294
+ callback(false);
91295
+ });
91296
+ } else callback(false);
91297
+ } else {
91298
+ var s = DeviceMotionEvent;
91299
+ if (pt != "devicemotion") s = DeviceOrientationEvent;
91300
+ s.requestPermission().then(function(result) {
91301
+ if (result != "denied") {
91302
+ setEvents();
91303
+ okay = true;
91304
+ }
91305
+ else callback(false);
91306
+ }).catch(function(e){
91307
+ callback(false);
91308
+ });
91309
+ }
91310
+ } else {
91311
+ callback(false);
91312
+ }
91313
+ }
91314
+
89702
91315
  }
89703
91316
  zim.extend(zim.PermissionAsk, zim.Pane, null, "zimPane", false);//-83.01
89704
91317
 
@@ -89817,7 +91430,7 @@ These DO NOT require the zim namespace, even if zns=true is set or if using node
89817
91430
  These are all equal to strings with lowercase values.
89818
91431
  So using TOP is the same as using "top"
89819
91432
 
89820
- 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
91433
+ 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
89821
91434
  Data: GET, POST, LOCALSTORAGE, SOCKET, TO, FROM, BOTH
89822
91435
  Sound: SINE, SQUARE, TRIANGLE, SAW, ZAP
89823
91436
  Style: IGNORE
@@ -89841,6 +91454,7 @@ END EXAMPLE
89841
91454
  zim.RIGHT = "right";
89842
91455
  zim.CENTER = "center";
89843
91456
  zim.MIDDLE = "middle";
91457
+ zim.JUSTIFY ="justify";
89844
91458
  zim.START = "start";
89845
91459
  zim.END = "end";
89846
91460
  zim.TOP ="top";
@@ -90630,12 +92244,18 @@ function zimify(obj, a, b, c, d, list) {
90630
92244
  hitTestRect:function(b, num, boundsCheck, inside) {
90631
92245
  return zim.hitTestRect(this, b, num, boundsCheck, inside);
90632
92246
  },
92247
+ hitTestRectPoint:function(x, y, margin) {
92248
+ return zim.hitTestRectPoint(this, x, y, margin);
92249
+ },
90633
92250
  hitTestCircle:function(b, num, boundsCheck, inside) {
90634
92251
  return zim.hitTestCircle(this, b, num, boundsCheck, inside);
90635
92252
  },
90636
92253
  hitTestCircleRect:function(b, margin) {
90637
92254
  return zim.hitTestCircleRect(this, b, margin);
90638
92255
  },
92256
+ hitTestCirclePoint:function(x, y, margin) {
92257
+ return zim.hitTestCirclePoint(this, x, y, margin);
92258
+ },
90639
92259
  hitTestCircles:function(b, margin) {
90640
92260
  return zim.hitTestCircles(this, b, margin);
90641
92261
  },
@@ -91757,7 +93377,7 @@ getLatestVersions(function(versions) {
91757
93377
  });
91758
93378
  END EXAMPLE
91759
93379
  --*///+82.1
91760
- zim.VERSION = "017/zim";
93380
+ zim.VERSION = "018/zim";
91761
93381
  //-82.1
91762
93382
 
91763
93383
  /*--
@@ -92169,6 +93789,10 @@ animator - the Gifler animator
92169
93789
  var to;
92170
93790
  var f;
92171
93791
  if (WW.PATH!=null) zim.PATH = WW.PATH;
93792
+ if (zim.PATH!=null) {
93793
+ zim.path.replace(/\/$/,"");
93794
+ zim.path = zim.path + "/";
93795
+ }
92172
93796
  if (file.match(/http/) || file.match(/^\//)) f = file;
92173
93797
  else f = (zim.PATH?zim.PATH:"")+file;
92174
93798
  that.gifler = gifler(f)
@@ -94682,8 +96306,40 @@ zim class - extends a zim.Container which extends a createjs.Container
94682
96306
  DESCRIPTION
94683
96307
  Shows the output from the Webcam after user permits access.
94684
96308
  Will stretch to fit in dimensions and can choose to flip (default) or not.
94685
- Used by ZIM CamMotion, CamCursor, CamAlpha and CamControls classes
94686
96309
 
96310
+ AS OF ZIM 018 - USE ML5 (Machine Learning 5)
96311
+ We recommend using ZIM Cam() with the ML5 Library at https://ml5js.org/
96312
+ Note: the ML5 library must be imported in a script tag.
96313
+
96314
+ HAND TRACKING WITH ZIM CAM AND ML5
96315
+ ZIM Cam has a handTrack(ML5results) method that will replace normal mouse and touch.
96316
+ Each pointer finger is a cursor for mousemove, mouseover and mouseout
96317
+ and pinching the pointer finger and the thumb, triggers mousedown, pressmove, pressup, tap, and click.
96318
+ There is a cursorMode which defaults to AUTO - there are also true and false values.
96319
+ On AUTO, if a hand is detected, then the mouse and touch are replaced by the finger and pinch
96320
+ but if the hand is not detected, then the mouse and touch are used.
96321
+ On true, the mouse and touch are turned off and only the finger and pinch are used.
96322
+ On false, the mouse and touch are active nd the finger and pinch are not used
96323
+ but the cursors for these are still there and they still give events and data which can be used.
96324
+ The cursorMode property can be used to change the mode dynamically.
96325
+ There is also a toggleReplace parameter and property (default true)
96326
+ which lets the user toggle using the hand rather than mouse and press but pinchin thumb and pinky.
96327
+ When a hand replaces the mouse and touch, the cam.replaceCursor is true as is the zim.handCursor.
96328
+ When the mouse and touch are being used then cam.replaceCursor and zim.handCursor are false.
96329
+ The handTrack() method automatically calls a prepareTrack() method if prepareTrack() is not already called.
96330
+ Optionally, the prepareTrack() can be called first to set a variety of options including the cursorMode parameter.
96331
+ The tracking cursors will still show and the cam dispatches "handmove", "handdown", and "handup" events.
96332
+ SEE: https://zimjs.com/018/handtrack.html - replacing the cursor
96333
+
96334
+ GENERAL ML5 FUNCTIONALITY
96335
+ ML5 can give very accurate hand poses, face poses and body poses and results return points.
96336
+ These points can be used to place ZIM objects or with a ZIM Shape to make circles, etc.
96337
+ There are other features too like shape recognition, blurring backgrounds, etc.
96338
+ These can all be used in ZIM - for using ML5 for interaction see the HAND TRACKING section above.
96339
+ SEE: https://zimjs.com/ml5/ - general ML5 integration examples
96340
+
96341
+ BEFORE ZIM 018
96342
+ ZIM CamMotion, CamCursor, CamAlpha and CamControls classes were used instead of ML5 and are still available
94687
96343
  SEE: https://zimjs.com/nft/bubbling/cam.html and use right arrow to see all four examples
94688
96344
  SEE: https://www.youtube.com/watch?v=z_jn6wkX6Ec
94689
96345
  SEE: https://www.youtube.com/watch?v=0vwJ3aodU4U
@@ -94757,6 +96413,75 @@ const ask = new CamAsk().show(yes => {
94757
96413
  });
94758
96414
  END EXAMPLE
94759
96415
 
96416
+ EXAMPLE
96417
+ // use ML5 at https://unpkg.com/ml5@1/dist/ml5.min.js for hand tracking
96418
+ // on a Mac, the canvas must be interacted with first
96419
+ // so would recommend always using CamAsk first:
96420
+ const ask = new CamAsk().show(yes=>{
96421
+ if (yes) {
96422
+ // new Cam() will trigger the Browser asking for permission
96423
+ // unless already have given permission in this session
96424
+ let cam = new Cam(1280,720);
96425
+ cam.on("ready", ()=>{
96426
+ cam.scaleTo().center().alp(.2);
96427
+
96428
+ // optional - use prepareTrack() with the following parameters:
96429
+ // width, height, hand, pinchColor, pinchHide, leftColor, rightColor, handScale, handAlpha, damp, gapTime, tapTime, cursorMode, toggleReplace
96430
+ // cam.prepareTrack()
96431
+
96432
+ // ML5
96433
+ const handPose = ml5.handPose(modelLoaded);
96434
+ function modelLoaded() {
96435
+ handPose.detectStart(cam.getCanvas(), result);
96436
+ function result(results) {
96437
+ // ZIM Cam to replace mouse with hand and provide pinch for interaction
96438
+ cam.handTrack(results); // this will automatically call prepareTrack() if not called already
96439
+ }
96440
+ }
96441
+
96442
+ const slider = new Slider({
96443
+ button:new Button({
96444
+ rollBgColor:purple,
96445
+ corner:30,
96446
+ width:60,
96447
+ height:60,
96448
+ label:""
96449
+ }),
96450
+ vertical:true,
96451
+ min:0,
96452
+ max:1,
96453
+ value:cam.alpha
96454
+ }).center().change(()=>{
96455
+ cam.alpha = slider.value;
96456
+ });
96457
+
96458
+ const tabs = new Tabs({width:400, height:60, tabs:["LEFT", "BOTH", "RIGHT"], index:2})
96459
+ .pos(0,100,CENTER)
96460
+ .tap(()=>{
96461
+ cam.hand = tabs.text.toLowerCase();
96462
+ });
96463
+
96464
+ new Label({
96465
+ 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",
96466
+ color:silver,
96467
+ size:25,
96468
+ backgroundColor:black.toAlpha(.5),
96469
+ lineHeight:40
96470
+ }).pos(50,0,LEFT,CENTER);
96471
+
96472
+ cam.bot();
96473
+
96474
+ });
96475
+ // if the user does not accept the browser asking about cam
96476
+ cam.on("error", ()=>{
96477
+ new Pane("CAM not accepted",yellow).show();
96478
+ });
96479
+ } else { // answered no to CamAsk dialog
96480
+ new Pane("CAM not accepted",yellow).show();
96481
+ }
96482
+ });
96483
+ END EXAMPLE
96484
+
94760
96485
  PARAMETERS
94761
96486
  ** supports DUO - parameters or single object with properties below
94762
96487
  width - (default 640) width of cam output - see also resetSize()
@@ -94788,7 +96513,62 @@ keyOut(color, tolerance, replacement) - remove color from Cam's bitmap and a tol
94788
96513
  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
94789
96514
  setFacingMode(mode) - set to "user", "exact_user", "environment", "exact_environment", "auto" to choose camera on mobile
94790
96515
  see facingMode parameter for more info
96516
+ getCanvas() - caches the cam display and adds updateCache to a cam.canvasTicker
96517
+ use this if a canvas showing what the cam sees is needed
96518
+ for instance with computer vision libraries like ML5 or TenserFlow, etc.
96519
+ forgetCanvas() - turn off getCanvas() cam display cache and Ticker function
94791
96520
  dispose() - close the cam and remove events
96521
+ ** ML5 Hand Cursors **
96522
+ prepareTrack(width, height, hand, pinchColor, pinchHide, leftColor, rightColor, alpha, damp, gapTime, tapTime, cursorMode, toggleReplace)
96523
+ returns a ZIM Container with dots for hand index fingers, thumbs and pinches and adds properties and events
96524
+ Note: this is optional as it will be done with default values when using handTrack() - see below
96525
+ width and height (default W and H of stage) width and height of tracking area
96526
+ hand (default RIGHT) which hand or hands will be tracked - LEFT, BOTH or RIGHT
96527
+ the performance may be a bit better if one hand is track - to avoid the occassional cursor jump from one hand to the other
96528
+ also see the hand property to set the handedness at any time
96529
+ pinchColor (default white) - the color of the dot cursor when pinch is active - will be same for left or right hand
96530
+ pinchHide (default true) - reduce the alpha of finger and thumb dot cursors when pinching - set to false to not reduce the alpha
96531
+ leftColor (default green) the color of the left finger and thumb cursors
96532
+ rightColor (default blue) the color of the right finger and thumb cursors
96533
+ handScale (default 1) the scale of the finger and thumb cursor circles
96534
+ will affect hit area too for pinch
96535
+ may want to decrease scale if people are far from camera
96536
+ also see the handScale property to adjust dynamically - note the pinch cursor circle does not scale
96537
+ to scale the pinch cursor circle dynamically scale the cam leftPinch and rightPinch properties
96538
+ handAlpha (default .5) the alpha of all the dot cursors applied to the dots container
96539
+ to set this dynamically, just set the alpha of the cam dots property
96540
+ damp (default .5) the damp of the cursor movement - .01 is slow, 1 is no damp
96541
+ gapTime (default .5) seconds to wait (after cursor data reads no cursor) until the cursor is reported as up
96542
+ without this, over the several seconds an object is dragged with pinch, the dragging often gets cut off
96543
+ also see tapTime - for initial up report to handle taps
96544
+ note: the gapTime is in effect across the whole time a pinch is active
96545
+ tapTime (default .3) seconds that a cursor up will immediately reported with no gapTime
96546
+ if the pinch cursor is reported up within this time, then it is probably a tap pinch rather than a tap drag
96547
+ note: the tapTime is only measured from the beginning of the pinch
96548
+ cursorMode (default AUTO) if a hand is detected, AUTO will use the hand for interactivity rather than mouse and touch
96549
+ and if there is no hand detected, AUTO will use the mouse and touch for interactivity.
96550
+ Set to true to always use the hand and not the mouse and touch.
96551
+ Set to false to not replace the mouse or touch cursor
96552
+ in all cases, the hand cursors will show hand events will be dispatched
96553
+ when the hand cursor is used, cam.replaceCursor and zim.handCursor will be true
96554
+ when the mouse and touch are used, cam.replaceCursor and zim.handCursor will be false or undefined
96555
+ replaceCursor can be toggled by pinching the thumb and the pinky if the toggleReplace parameter is true
96556
+ also see the replaceCursor property
96557
+ toggleReplace (default true) set to false to not allow toggling of replaceCursor by pinching the thumb and pinky
96558
+ note: the replaceCursor property can still be used to toggle replacing the mouse and touch with a hand cursor
96559
+ handTrack(ML5results) process ML5 HandPose() results
96560
+ this will activate the prepareTrack() with default parameters if handTrack() is not specifically called
96561
+ the results, by default, will replace mouse and touch interactivity if a hand cursor is detected (AUTO)
96562
+ the hand cursor puts a dot at the index finger that will trigger mouseover, mousemove and mouseout
96563
+ and if the index finger and thumb are pinched will act like a mousedown that also activates pressmove
96564
+ and when pinch is released will act like a mouseup that also activates pressup, click and tap
96565
+ there is a hand property that can be tested or set to LEFT, RIGHT (default), or BOTH
96566
+ this will also dispatch events - see hand events below
96567
+ getDistance() - returns an object with left and right properties of the distance between the thumb and the index finger
96568
+ {left:0, right:200} left is probably not active and the right is 200 pixels between thumb and the the index finger
96569
+ getAngle() - returns an object with left and right properties of the angle between the thumb and the index finger
96570
+ the angle is 0 when pointing directly to the right and will be 90 when pointing down, 270 when pointing up, etc.
96571
+ {left:0, right:90} left is probably not active and the right has the thumb at top and finger below
94792
96572
 
94793
96573
  ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
94794
96574
  drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
@@ -94810,6 +96590,36 @@ paused - get or set whether the cam is paused (also see pause() and toggle())
94810
96590
  flipped - get or set whether the cam is mirrored (also see flip())
94811
96591
  facingMode - get which camera is being used - "user", "environment", etc. might be undefined
94812
96592
  see facingMode parameter and setFacingMode() method for more details
96593
+ ** ML5 Hand Cursors **
96594
+ cursorMode - gets and sets if the hand cursor replaces the mouse and touch
96595
+ default is AUTO can also be set to true or false
96596
+ see the cursorMode parameter of prepareTrack()
96597
+ replaceCursor - get or set if ML5 hand tracking is replacing the mouse and touch cursor
96598
+ must import ML5 and use prepareTrack() or handTrack()
96599
+ there is also a read only zim.handCursor property that reports the same as replaceCursor
96600
+ toggleReplace - get or set whether pinching thumb and pinky will toggle replaceCursor (see above)
96601
+ hand - get or set the LEFT, RIGHT (default), or BOTH setting of ML5 hand Cursors (see above)
96602
+ handScale - get or set the scale of the hand cursors - default is 1
96603
+ gapTime - get or set the gapTime - see gapTime parameter
96604
+ tapTime - get or set the tapTime - see tapTime parameter
96605
+ dots - the ZIM Container holding all the hand cursors
96606
+ leftFinger - the ZIM Circle that represents the left index finger - located inside the dots container
96607
+ also includes an active property that is true if active
96608
+ also includes dampX and dampY references to zim Damp object
96609
+ leftThumb - the ZIM Circle that represents the left thumb - located inside the dots container
96610
+ also includes dampX and dampY references to zim Damp object
96611
+ leftPinch - the ZIM Circle that represents the left pinch - located inside the dots container
96612
+ also includes an active property that is true if active
96613
+ also includes dampX and dampY references to zim Damp object
96614
+ rightFinger - the ZIM Circle that represents the right 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
+ rightThumb - the ZIM Circle that represents the right thumb - located inside the dots container
96618
+ also includes dampX and dampY references to zim Damp object
96619
+ rightPinch - the ZIM Circle that represents the right 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
+ pinchTicker - a reference to the Ticker that handles testing the pinches
94813
96623
 
94814
96624
  ALSO: see ZIM Container for properties such as:
94815
96625
  width, height, widthOnly, heightOnly, draggable, level, depth, group
@@ -94827,6 +96637,19 @@ See the CreateJS Easel Docs for Stage events, such as:
94827
96637
  mouseenter, mouseleave, stagemousedown, stagemousemove, stagemouseup, drawstart, drawend, etc.
94828
96638
  and all the Container events such as:
94829
96639
  click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
96640
+ ** ML5 Hand Cursor Events **
96641
+ distpaches a "handmove" event when hand cursor moves
96642
+ dispatches a "handdown" event when index finger and thumb are pinched
96643
+ dispatches a "handup" event when index finger and thumb are no longer pinched
96644
+ this will be immediate if within the tapTime time (default .3 seconds - see prepareTrack() method)
96645
+ this will be delayed by gapTime (default .5 seconds - see prepareTrack() method) if beyond the tapTime
96646
+ gapTime allows for more complete dragging of ZIM objects like slider buttons, general dragging, etc.
96647
+ note: the hand cursors will be removed right as the gapTime is started
96648
+ dispatches a "handon" when a hand cursor is shown - see
96649
+ dispatches a "handoff" when a hand cursor is hidden
96650
+ dispatches a "replaceon" event when hand cursor replaces mouse because thumb and pinky are pinched and toggleReplace is true
96651
+ dispatches a "replaceoff" event when hand cursor no longer replaces mouse because thumb and pinky are pinched and toggleReplace is true
96652
+
94830
96653
  --*///+142
94831
96654
 
94832
96655
  // THE CODE FOR THE CAM MODULE IS LINKED TO AT THE TOP OF THE DOCS
@@ -95845,6 +97668,7 @@ var globalFunctions = [
95845
97668
  ["zogr", zogr],
95846
97669
  ["zogy", zogy],
95847
97670
  ["zogo", zogo],
97671
+ ["zogs", zogs],
95848
97672
  ["zogl", zogl],
95849
97673
  ["zogd", zogd],
95850
97674
  ["zimplify", zimplify],
@@ -95866,6 +97690,7 @@ for (z_i = 0; z_i < globalFunctions.length; z_i++) {
95866
97690
  ["RIGHT", zim.RIGHT],
95867
97691
  ["CENTER", zim.CENTER],
95868
97692
  ["MIDDLE", zim.MIDDLE],
97693
+ ["JUSTIFY", zim.JUSTIFY],
95869
97694
  ["START", zim.START],
95870
97695
  ["END", zim.END],
95871
97696
  ["TOP", zim.TOP],
@@ -96077,6 +97902,7 @@ export let Organizer = zim.Organizer;
96077
97902
  export let Connectors = zim.Connectors;
96078
97903
  export let Marquee = zim.Marquee;
96079
97904
  export let Carousel = zim.Carousel;
97905
+ export let Carousel3D = zim.Carousel3D;
96080
97906
  export let Loader = zim.Loader;
96081
97907
  export let TextArea = zim.TextArea;
96082
97908
  export let localToGlobal = zim.localToGlobal;
@@ -96140,8 +97966,10 @@ export let removePhysics = zim.removePhysics;
96140
97966
  export let hitTestPoint = zim.hitTestPoint;
96141
97967
  export let hitTestReg = zim.hitTestReg;
96142
97968
  export let hitTestRect = zim.hitTestRect;
97969
+ export let hitTestRectPoint = zim.hitTestRectPoint;
96143
97970
  export let hitTestCircle = zim.hitTestCircle;
96144
97971
  export let hitTestCircleRect = zim.hitTestCircleRect;
97972
+ export let hitTestCirclePoint = zim.hitTestCirclePoint;
96145
97973
  export let hitTestCircles = zim.hitTestCircles;
96146
97974
  export let hitTestBounds = zim.hitTestBounds;
96147
97975
  export let hitTestPath = zim.hitTestPath;
@@ -96217,6 +98045,7 @@ export let Frame = zim.Frame;
96217
98045
  export let Pic = zim.Pic;
96218
98046
  export let Aud = zim.Aud;
96219
98047
  export let Vid = zim.Vid;
98048
+ export let Dat = zim.Dat;
96220
98049
  export let SVG = zim.SVG;
96221
98050
  export let Speech = zim.Speech;
96222
98051
  export let PermissionAsk = zim.PermissionAsk;