zimjs 18.0.9 → 18.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/zim.js +104 -48
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "18.0.9",
3
+ "version": "18.1.0",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -2239,7 +2239,7 @@ function myFunction(data){
2239
2239
  // in the php file we would use the following to return JSON:
2240
2240
  <?php
2241
2241
  header('Content-type: text/javascript');
2242
- $data = [test=>"wow", score=>[1,2,3]];
2242
+ $data = ["test"=>"wow", "score"=>[1,2,3]];
2243
2243
  echo "async.myFunction(".JSON_encode($data).")";
2244
2244
  ?>
2245
2245
 
@@ -11354,7 +11354,7 @@ it will still scale when using the corners. This can be turned off by setting s
11354
11354
 
11355
11355
  Properties for the slice lines are available and can be set and animated as can the scalesWidth and scalesHeight.
11356
11356
 
11357
- SEE: https://zimjs.com/slices for the ZIM Slices tool and example of SlicedBitmap
11357
+ SEE: https://zimjs.com/slicer for the ZIM Slices tool and example of SlicedBitmap
11358
11358
 
11359
11359
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
11360
11360
 
@@ -11804,6 +11804,8 @@ but we found the framerate could not be kept
11804
11804
  with other animations or Ticker events running.
11805
11805
  So we recommend using the ZIM Sprite run() method.
11806
11806
 
11807
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
11808
+
11807
11809
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
11808
11810
 
11809
11811
  EXAMPLE
@@ -22641,13 +22643,12 @@ zim class - extends a zim.Container which extends a createjs.Container
22641
22643
 
22642
22644
  DESCRIPTION
22643
22645
  Makes a label - wraps the createjs Text object.
22644
- Can use with Button, CheckBox, RadioButtons and Pane.
22645
- Text seems to come in different sizes so we do our best.
22646
- Have tended to find that left and alphabetic are most consistent across browsers.
22647
- Custom fonts loaded through css can be used as well.
22646
+ Can also use with Button, CheckBox, RadioButtons, Pane, etc.
22647
+ System fonts, Google fonts and custom fonts can be used.
22648
+
22649
+ NOTE: can wrap text at given width using labelWidth (or lineWidth) parameter.
22648
22650
 
22649
- NOTE: can wrap text at given width using lineWidth (or labelWidth) parameter.
22650
- To dynamically change the width without changing the font size use the labelWidth property.
22651
+ NOTE: can make text fit to dimensions by setting both labelWidth and labelHeight parameters.
22651
22652
 
22652
22653
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
22653
22654
 
@@ -22665,6 +22666,16 @@ new Label({
22665
22666
  }).loc(100,100).tap(()=>{zog("tapping");});
22666
22667
  END EXAMPLE
22667
22668
 
22669
+ EXAMPLE
22670
+ // using the Google Font gf_ short cut for "Joti+One"
22671
+ // and also a custom font (Reuben) that would be in the assets folder
22672
+ new Frame(FIT, 1024, 768, ready ["gf_Joti+One", "Reuben.otf"], "assets/");
22673
+ function ready() {
22674
+ new Label("Hello", 100, "Joti One").loc(100,100);
22675
+ new Label("Greets", 50, "Reuben").center();
22676
+ }
22677
+ END EXAMPLE
22678
+
22668
22679
  EXAMPLE
22669
22680
  // with text that wraps at labelWidth
22670
22681
  // can also set this as a property later to dynamically change width of text
@@ -22675,6 +22686,17 @@ new Label({
22675
22686
  }).center();
22676
22687
  END EXAMPLE
22677
22688
 
22689
+ EXAMPLE
22690
+ // with text that fits into labelWidth and labelHeight
22691
+ // will change font size.
22692
+ new Label({
22693
+ text:"Fit this text into the width and height",
22694
+ labelWidth:300,
22695
+ labelHeight:150,
22696
+ align:CENTER
22697
+ }).center().outline();
22698
+ END EXAMPLE
22699
+
22678
22700
  EXAMPLE
22679
22701
  STYLE = {font:"courier"};
22680
22702
  new Label("Hi Courier").center(); // will be courier not arial
@@ -27546,6 +27568,7 @@ Adds a window for alerts, etc.
27546
27568
  You need to call the pane.show() to show the pane and pane.hide() to hide it.
27547
27569
  You do not need to add it to the stage - it adds itself centered.
27548
27570
  You can change the x and y (the origin and registration point are in the middle).
27571
+ Content is added to the pane with the content parameter or the add() method.
27549
27572
 
27550
27573
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
27551
27574
 
@@ -28157,7 +28180,8 @@ zim class - extends a zim.Container which extends a createjs.Container
28157
28180
 
28158
28181
  DESCRIPTION
28159
28182
  A simple panel with titleBar and optional arrow for more panels.
28160
- Panel can be set draggable and can have a collapse button and a close button
28183
+ Panel can be set draggable and can have a collapse button and a close button.
28184
+ Content is added to the panel with the content parameter or the add() method.
28161
28185
  See: https://zimjs.com/explore/panel.html
28162
28186
 
28163
28187
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
@@ -28694,6 +28718,8 @@ zim class - extends a zim.Container which extends a createjs.Container
28694
28718
 
28695
28719
  DESCRIPTION
28696
28720
  Adds a window for content that can be swiped and scrolled.
28721
+ Content is added to the Window with the content parameter or the add() method.
28722
+
28697
28723
  NOTE: if zim namespace zns = true then this overwrites a JS Window - so the JS Window is stored as document.Window
28698
28724
 
28699
28725
  NOTE: set the enable property to false if animating the position of the whole Window
@@ -48724,7 +48750,6 @@ shadowColor - (default null) the shadow color (css color) of a drop shadow
48724
48750
  shadowBlur - (default null) pixels of how blurred the shadow is if the shadow is set - eg. 10
48725
48751
  dashed - (default true) set to false to turn off the dashed for the border
48726
48752
  id - (default null) a string id for the HTML textarea tag for CSS styling, etc.
48727
- placeholder - (default null) a string that is used for the HTML textarea tag placeholder parameter
48728
48753
  readOnly - (default false) set to true to make TextArea read only (still selectable)
48729
48754
  spellCheck - (default true) set to false to turn Browser spell check off
48730
48755
  password - (default false) set to true to turn the field into a password field - single line only (uses input field type=password and not TextArea)
@@ -55506,6 +55531,8 @@ Keep the quality at 1 for animating filters at a decent framerate.
55506
55531
  Consider pre-processing images if effects do not have to be dynamic.
55507
55532
 
55508
55533
  NOTE: when applying effects to rtl fonts make sure the DIR = "rtl" is set.
55534
+
55535
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
55509
55536
 
55510
55537
  EXAMPLE
55511
55538
  // create a Label with a GlowEffect that shows through to the image below
@@ -70244,11 +70271,11 @@ color2 - (default null) a second color which would form a zim.GradientColor() as
70244
70271
  angle - (default 90) the angle for the gradient if there is a gradient
70245
70272
  borderColor - (default null) the stroke color
70246
70273
  borderWidth - (default 1 if stroke is set) the size of the stroke in pixels
70247
- corner - (default 0) the round of corner
70248
- can also be an array of [topLeft, topRight, bottomRight, bottomLeft]
70249
- inside this array can be arrays of [horizontal, vertical] which skews each corner
70250
- can also be a combination array of values and skew arrays
70251
- [topLeft, [horizontal, vertical], bottomRight, [horizontal, vertical]]
70274
+ corner - (default 10) the round of corner
70275
+ can also be an array of [topLeft, topRight, bottomRight, bottomLeft]
70276
+ inside this array can be arrays of [horizontal, vertical] which skews each corner
70277
+ can also be a combination array of values and skew arrays
70278
+ [topLeft, [horizontal, vertical], bottomRight, [horizontal, vertical]]
70252
70279
  interactive - (default true) set to false to not be interactive
70253
70280
  interactive will use raycasting in the TextureActives object
70254
70281
  to provide x and y to CreateJS which is then used by ZIM
@@ -70262,8 +70289,8 @@ pattern - (default null) a DisplayObject that will be added to the TextureActive
70262
70289
  scalePattern - (default "fill") scale the pattern so it fills the window (formerly "bigger" or "outside")
70263
70290
  set to false for no scaling or:
70264
70291
  FIT or "fit" fits inside the TextureActive keeping proportion (formerly "smallest")
70265
- FILL or "fill" fills the TextureActive keeping proportion (formerly "biggest" or "outside")
70266
- FULL or "full" keeps both x and y scales - may stretch object (formerly "both")
70292
+ FILL or "fill" fills the TextureActive keeping proportion (formerly "biggest" or "outside")
70293
+ FULL or "full" keeps both x and y scales - may stretch object (formerly "both")
70267
70294
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
70268
70295
  group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
70269
70296
  inherit - (default null) used internally but can receive an {} of styles directly
@@ -75363,29 +75390,31 @@ SEE: https://zimjs.com/portal/
75363
75390
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
75364
75391
 
75365
75392
  EXAMPLE
75366
- F.loadAssets(["researchbuilding.jpg", "jungle.jpg"]);
75393
+ F.loadAssets(["ai_future03.jpg", "ai_alienplanet01.jpg"], "https://zimjs.org/assets/");
75367
75394
  F.on("complete", ()=>{
75395
+
75368
75396
  const lands = new Container(W, H).addTo();
75369
- const jungle = new Pic("jungle.jpg")
75397
+ const planet = new Pic("ai_alienplanet01.jpg")
75370
75398
  .scaleTo(lands)
75371
75399
  .center(lands);
75372
- const researchBuilding = new Pic("researchbuilding.jpg")
75400
+ const future = new Pic("ai_future03.jpg")
75373
75401
  .scaleTo(lands)
75374
75402
  .center(lands);
75403
+
75375
75404
  const portalObject = new Circle(118, faint, pink, 16, true)
75376
- .addTo(stage)
75377
- .pos(580, 470)
75405
+ .center()
75406
+ .mov(0,90)
75378
75407
  .animate({obj:{rotation:"360"}, time:70, ease:"linear", loop:true});
75408
+
75379
75409
  const portal = new Portal(portalObject, lands);
75380
- portal.on("enter", function() {
75410
+ portal.on("enter", ()=>{
75381
75411
  // play a sound here!
75382
75412
  });
75383
75413
 
75384
75414
  // use enabled to turn on and off portal
75385
- timeout(1, ()=>{portal.enabled = false; portalObject.pauseAnimate(true);});
75386
- timeout(5, ()=>{portal.enabled = true; portalObject.pauseAnimate(false);});
75415
+ // timeout(1, ()=>{portal.enabled = false; portalObject.pauseAnimate(true);});
75416
+ // timeout(5, ()=>{portal.enabled = true; portalObject.pauseAnimate(false);});
75387
75417
 
75388
- S.update();
75389
75418
  }); // assets loaded
75390
75419
  END EXAMPLE
75391
75420
 
@@ -76575,6 +76604,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
76575
76604
  Keep the quality at 1 for animating filters at a decent framerate.
76576
76605
  Consider pre-processing images if effects do not have to be dynamic.
76577
76606
 
76607
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
76608
+
76578
76609
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
76579
76610
 
76580
76611
  EXAMPLE
@@ -76698,6 +76729,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
76698
76729
  Keep the quality at 1 for animating filters at a decent framerate.
76699
76730
  Consider pre-processing images if effects do not have to be dynamic.
76700
76731
 
76732
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
76733
+
76701
76734
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
76702
76735
 
76703
76736
  EXAMPLE
@@ -76944,6 +76977,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
76944
76977
  Keep the quality at 1 for animating filters at a decent framerate.
76945
76978
  Consider pre-processing images if effects do not have to be dynamic.
76946
76979
 
76980
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
76981
+
76947
76982
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
76948
76983
 
76949
76984
  EXAMPLE
@@ -77248,6 +77283,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
77248
77283
  Keep the quality at 1 for animating filters at a decent framerate.
77249
77284
  Consider pre-processing images if effects do not have to be dynamic.
77250
77285
 
77286
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
77287
+
77251
77288
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
77252
77289
 
77253
77290
  EXAMPLE
@@ -77438,6 +77475,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
77438
77475
  Keep the quality at 1 for animating filters at a decent framerate.
77439
77476
  Consider pre-processing images if effects do not have to be dynamic.
77440
77477
 
77478
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
77479
+
77441
77480
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
77442
77481
 
77443
77482
  EXAMPLE
@@ -77570,6 +77609,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
77570
77609
  Keep the quality at 1 for animating filters at a decent framerate.
77571
77610
  Consider pre-processing images if effects do not have to be dynamic.
77572
77611
 
77612
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
77613
+
77573
77614
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
77574
77615
 
77575
77616
  EXAMPLE
@@ -77752,6 +77793,8 @@ to make accessing filters easy - but apps will slow down if they are over-used.
77752
77793
  Keep the quality at 1 for animating filters at a decent framerate.
77753
77794
  Consider pre-processing images if effects do not have to be dynamic.
77754
77795
 
77796
+ NOTE: when applying an effect to a Sprite, put the sprite in a Container and apply the effect on the container
77797
+
77755
77798
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
77756
77799
 
77757
77800
  EXAMPLE
@@ -90016,36 +90059,36 @@ END EXAMPLE
90016
90059
  EXAMPLE
90017
90060
  // getting a preview
90018
90061
  const video = new Vid("video.mp4")
90019
- .scaleTo()
90020
- .center()
90021
- .vis(false);
90062
+ .scaleTo()
90063
+ .center()
90064
+ .vis(false);
90022
90065
 
90023
90066
  new Pane("WELCOME").show(init);
90024
90067
 
90025
90068
  function init() {
90026
- video.play().pause().vis(true);
90069
+ video.play().pause().vis(true);
90027
90070
  // note, to play after this use video.pause(false); // not video.play()
90028
- Ticker.always();
90071
+ Ticker.always();
90029
90072
  }
90030
90073
  END EXAMPLE
90031
90074
 
90032
90075
  EXAMPLE
90033
90076
  // getting a keyed out preview
90034
90077
  const video = new Vid("video.mp4")
90035
- .scaleTo()
90036
- .center()
90037
- .vis(false);
90078
+ .scaleTo()
90079
+ .center()
90080
+ .vis(false);
90038
90081
 
90039
90082
  new Pane("WELCOME").show(init);
90040
90083
 
90041
90084
  function init() {
90042
- video
90043
- .keyOut("#01b03f", .25) // key out the green
90044
- .play();
90045
- timeout(.05, ()=>{
90046
- video.pause().vis(true);
90047
- });
90048
- Ticker.always();
90085
+ video
90086
+ .keyOut("#01b03f", .25) // key out the green
90087
+ .play();
90088
+ timeout(.05, ()=>{
90089
+ video.pause().vis(true);
90090
+ });
90091
+ Ticker.always();
90049
90092
  }
90050
90093
  END EXAMPLE
90051
90094
 
@@ -90228,9 +90271,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
90228
90271
  var replacement = that.keyObj.replacement;
90229
90272
  that.ticker = zim.Ticker.add(function(){
90230
90273
  bitmap.keyOut(color, tolerance, replacement);
90231
- });
90274
+ }, that.stage);
90232
90275
  } else {
90233
- that.ticker = zim.Ticker.add(function(){});
90276
+ that.ticker = zim.Ticker.add(function(){}, that.stage);
90234
90277
  }
90235
90278
  }
90236
90279
  return that;
@@ -91166,7 +91209,7 @@ function init(yes) {
91166
91209
  END EXAMPLE
91167
91210
 
91168
91211
  EXAMPLE
91169
- // for shaking motion - ALSO see the PermissionAsk example above for iOS
91212
+ // for shaking motion - ALSO see the PermissionAsk example above
91170
91213
  // and replace "deviceorientation" with "devicemotion"
91171
91214
  // and replace e.rotation.x, etc. with e.acceleration.x etc.
91172
91215
  // also set Frame sensors parameter to true
@@ -96599,7 +96642,7 @@ const ask = new CamAsk().show(yes => {
96599
96642
  END EXAMPLE
96600
96643
 
96601
96644
  EXAMPLE
96602
- // use ML5 at https://unpkg.com/ml5@1/dist/ml5.min.js for hand tracking
96645
+ // use ML5 at https://unpkg.com/ml5@1.2.1/dist/ml5.min.js for hand tracking
96603
96646
  // on a Mac, the canvas must be interacted with first
96604
96647
  // so would recommend always using CamAsk first:
96605
96648
  const ask = new CamAsk().show(yes=>{
@@ -97279,6 +97322,17 @@ NOTE: make the CamAlpha in the ready event of the Cam() or CamMotion()
97279
97322
 
97280
97323
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
97281
97324
 
97325
+ EXAMPLE
97326
+ // on a Mac, the canvas must be interacted with first
97327
+ // so would recommend always using CamAsk first:
97328
+ const ask = new CamAsk().show(yes=>{
97329
+ if (yes) {
97330
+ const cam = new Cam(W,H).alp(.3).center();
97331
+ new CamAlpha(cam).pos(50,50,LEFT,BOTTOM);
97332
+ }
97333
+ }); // end CamAsk show() - see CamAsk() docs for error checking example
97334
+ END EXAMPLE
97335
+
97282
97336
  EXAMPLE
97283
97337
  // on a Mac, the canvas must be interacted with first
97284
97338
  // so would recommend always using CamAsk first:
@@ -97618,6 +97672,8 @@ resize
97618
97672
  rotate2
97619
97673
  save
97620
97674
  mark
97675
+ pic
97676
+ chart
97621
97677
 
97622
97678
  Pizzazz Icons example:
97623
97679
  https://zimjs.com/bits/view/icons.html
@@ -97633,8 +97689,8 @@ const icon = makeIcon("home", white, 2).pos(40,40,RIGHT);
97633
97689
  var info = new Button({
97634
97690
  width:50,
97635
97691
  height:50,
97636
- color:blue, // or "red", "#666" etc.
97637
- rollColor:pink,
97692
+ backgroundColor:blue, // or "red", "#666" etc.
97693
+ rollBackgroundColor:pink,
97638
97694
  corner:0,
97639
97695
  label:"",
97640
97696
  icon:makeIcon("info", "white")
@@ -97765,7 +97821,7 @@ where various Blob and Squiggle shapes can be selected from a menu
97765
97821
  or custom Blob And Squiggle shapes can be made.
97766
97822
  The code for the shapes can be copied into your app
97767
97823
  as the Blob or Squiggle points parameter.
97768
- Please contact us at https:forum.zimjs.com
97824
+ Please contact us at https://forum.zimjs.com
97769
97825
  and we can perhaps add your Blob or Squiggle in the menu!
97770
97826
 
97771
97827
  Note that PIZZAZZ 04 was created during ZIM NIO (version 9)