zimjs 17.1.0 → 17.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/zim.js +2137 -551
- package/ts-src/typings/zim/index.d.ts +101 -4
package/src/zim.js
CHANGED
|
@@ -9745,6 +9745,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
9745
9745
|
this.setBounds = function(a,b,c,d) {
|
|
9746
9746
|
var n = normalizeBounds(a, b, c, d);
|
|
9747
9747
|
that.cjsContainer_setBounds(n[0],n[1],n[2],n[3]);
|
|
9748
|
+
that.width;
|
|
9748
9749
|
return that;
|
|
9749
9750
|
};
|
|
9750
9751
|
this.getBounds = function(targetSpace) {
|
|
@@ -10197,6 +10198,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
10197
10198
|
this.setBounds = function(a,b,c,d) {
|
|
10198
10199
|
var n = normalizeBounds(a, b, c, d);
|
|
10199
10200
|
this.cjsShape_setBounds(n[0],n[1],n[2],n[3]);
|
|
10201
|
+
this.width;
|
|
10200
10202
|
return this;
|
|
10201
10203
|
};
|
|
10202
10204
|
this.getBounds = function(targetSpace) {
|
|
@@ -10273,9 +10275,10 @@ zim class - extends a createjs.Bitmap
|
|
|
10273
10275
|
|
|
10274
10276
|
DESCRIPTION
|
|
10275
10277
|
Makes a Bitmap object from an image source (image, video or canvas).
|
|
10276
|
-
It is best to
|
|
10277
|
-
|
|
10278
|
-
See the ZIM Frame class and
|
|
10278
|
+
It is best to preload images in the Frame() or with loadAssets() and the path parameter
|
|
10279
|
+
then simply use ZIM Pic() to display the image.
|
|
10280
|
+
See the ZIM Frame class and ZIM Pic in the Docs.
|
|
10281
|
+
But Bitmap() is handy to turn other canvases or any DisplayObject into a picture.
|
|
10279
10282
|
|
|
10280
10283
|
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
10281
10284
|
|
|
@@ -10597,6 +10600,7 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
|
|
|
10597
10600
|
this.setBounds = function(a,b,c,d) {
|
|
10598
10601
|
var n = normalizeBounds(a, b, c, d);
|
|
10599
10602
|
that.cjsBitmap_setBounds(n[0],n[1],n[2],n[3]);
|
|
10603
|
+
that.width;
|
|
10600
10604
|
return that;
|
|
10601
10605
|
};
|
|
10602
10606
|
this.getBounds = function(targetSpace) {
|
|
@@ -10786,6 +10790,424 @@ zim.Bitmap.prototype.dispose = function() {return this.doDispose();};
|
|
|
10786
10790
|
zimify(zim.Bitmap.prototype);
|
|
10787
10791
|
//-50.7
|
|
10788
10792
|
|
|
10793
|
+
/*--
|
|
10794
|
+
zim.SlicedBitmap = function(width, height, obj, slices, types, gap, scale, style, group, inherit)
|
|
10795
|
+
|
|
10796
|
+
SlicedBitmap
|
|
10797
|
+
zim class - extends a zim.Bitmap which extends a createjs.Bitmap
|
|
10798
|
+
|
|
10799
|
+
DESCRIPTION
|
|
10800
|
+
Makes an n-sliced bitmap. This is similar to 9-sliced, and can do 9-sliced,
|
|
10801
|
+
but also can have any number of horizontal or vertical slices.
|
|
10802
|
+
The slices make regions that can be fixed in scale, stretched or tiled.
|
|
10803
|
+
This is handy for graphics that have detailed corners or edges that should not be scaled
|
|
10804
|
+
and then areas that can be scaled or tiled when size is changed.
|
|
10805
|
+
The bitmap can then be sized with slicesWidth and slicesHeight rather than width and height
|
|
10806
|
+
to stretch and tile those regions but leave fixed regions fixed in size.
|
|
10807
|
+
|
|
10808
|
+
The ZIM transform() defaults to using slicesWidth and slicesHeight when resizing the edges
|
|
10809
|
+
it will still scale when using the corners. This can be turned off by setting sliceX and sliceY parameters of transform to false.
|
|
10810
|
+
|
|
10811
|
+
Properties for the slice lines are available and can be set and animated as can the scalesWidth and scalesHeight.
|
|
10812
|
+
|
|
10813
|
+
SEE: https://zimjs.com/slices for the ZIM Slices tool and example of SlicedBitmap
|
|
10814
|
+
|
|
10815
|
+
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
10816
|
+
|
|
10817
|
+
EXAMPLE
|
|
10818
|
+
// slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
|
|
10819
|
+
new SlicedBitmap(1600, pic.height, pic, [0.25,0.75],[0.25,0.75]], [[0,1,0],[0,1,0])
|
|
10820
|
+
.center()
|
|
10821
|
+
.transform({minScaleX:.05, minScaleY:.05});
|
|
10822
|
+
END EXAMPLE
|
|
10823
|
+
|
|
10824
|
+
EXAMPLE
|
|
10825
|
+
// slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
|
|
10826
|
+
const pic = new Pic("car.png"); // preload this in Frame() or loadAssets()
|
|
10827
|
+
const startSlices = [0.25,0.75],[0.25,0.75]];
|
|
10828
|
+
const startTypes = [[0,2,0],[0,1,0]; // middle is tiled horizontally and stretched vertically
|
|
10829
|
+
const slicer = new Slicer({
|
|
10830
|
+
obj:pic.clone(), // slicer will adjust obj so clone the pic so can use it unaffected later
|
|
10831
|
+
scale:.5,
|
|
10832
|
+
slices:startSlices,
|
|
10833
|
+
types:startTypes,
|
|
10834
|
+
upload:false
|
|
10835
|
+
})
|
|
10836
|
+
.pos(30,50)
|
|
10837
|
+
.change(()=>{preview.exchange = slicer.exchange;); // this will update the picture below
|
|
10838
|
+
|
|
10839
|
+
// this will provide slice type options
|
|
10840
|
+
new SlicerTypes(slicer).pos(30,120,RIGHT,TOP);
|
|
10841
|
+
|
|
10842
|
+
// SlicedBitmaps slicesWidth and slicesHeight do not currently scale from the registration point
|
|
10843
|
+
// here we animate the slicesWidth and use a container to animate from the center
|
|
10844
|
+
const holder = new Container(800,400).center();
|
|
10845
|
+
const preview = new SlicedBitmap(1600, pic.height, pic, slicer.slices, slicer.types, 2, .5)
|
|
10846
|
+
.center(holder)
|
|
10847
|
+
.animate({
|
|
10848
|
+
props:{slicesWidth:980},
|
|
10849
|
+
// props:{sH0:.31}, // alternatively, animate the first horizontal slice (vertical line)
|
|
10850
|
+
time:2,
|
|
10851
|
+
ease:"elasticInOut",
|
|
10852
|
+
rewind:true,
|
|
10853
|
+
rewindWait:1,
|
|
10854
|
+
loop:true,
|
|
10855
|
+
loopWait:1,
|
|
10856
|
+
animateCall:()=>{preview.center(holder)} // always recenter the SlicedBitmap in the container
|
|
10857
|
+
});
|
|
10858
|
+
END EXAMPLE
|
|
10859
|
+
|
|
10860
|
+
PARAMETERS
|
|
10861
|
+
** supports DUO - parameters or single object with properties below
|
|
10862
|
+
** supports OCT - parameter defaults can be set with STYLE control (like CSS)
|
|
10863
|
+
width - (default null) the width of the object - this will apply slices and types settings to keep fixed, scale or tile regions
|
|
10864
|
+
height - (default null) the height of the object - this will apply slices and types settings to keep fixed, scale or tile regions
|
|
10865
|
+
obj - (default null) a DisplayObject such as a ZIM Pic, Container, etc. or an HTML image or canvas
|
|
10866
|
+
slices - (default null) an array of horizontal and vertical arrays holding slice percentage
|
|
10867
|
+
[[.25,.75], [.1,.4,.5,.9]]
|
|
10868
|
+
three horizontal regions made from two vertical lines placed at 1/4 and 3/4 the width
|
|
10869
|
+
five vertical regions made from four horizontal lines with 1/10 the picture at left, middle and right
|
|
10870
|
+
types - (default null) an array of horizontal and vertical arrays holding slice types
|
|
10871
|
+
0 - fix - keeps the original width and height of the region. Usually, good for corners.
|
|
10872
|
+
1 - stretch - stretch the region to fill space as an object is stretched
|
|
10873
|
+
2 - tile - tile the region at original scale - currently, will match the first side and sometimes the second side
|
|
10874
|
+
gap - (default 2) pixels to overlap on each side to avoid canvas ditthered edges
|
|
10875
|
+
scale - (default 1) a scale for the caching
|
|
10876
|
+
style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
|
|
10877
|
+
group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
|
|
10878
|
+
inherit - (default null) used internally but can receive an {} of styles directly
|
|
10879
|
+
|
|
10880
|
+
METHODS
|
|
10881
|
+
slicesSca() - like sca() but will call sclicesScaleX and slicesScaleY to operate on regions
|
|
10882
|
+
hasProp(property as String) - returns true if property exists on object else returns false
|
|
10883
|
+
clone() - makes a copy with properties such as x, y, etc. also copied - also copies file and src properties
|
|
10884
|
+
dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
|
|
10885
|
+
if this is a cloned bitmap then the original asset("image.png") will still exist unless it is disposed.
|
|
10886
|
+
|
|
10887
|
+
ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
|
|
10888
|
+
drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
|
|
10889
|
+
addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
|
|
10890
|
+
ALSO: see the ZIM Bitmap methods, such as:
|
|
10891
|
+
keyOut(), cache(), getColorAt(), etc.
|
|
10892
|
+
ALSO: see the CreateJS Easel Docs for Bitmap methods, such as:
|
|
10893
|
+
on(), off(), dispatchEvent(), etc.
|
|
10894
|
+
|
|
10895
|
+
PROPERTIES
|
|
10896
|
+
type - holds the class name as a String
|
|
10897
|
+
slices - get or set slices - see slices parameter and sH, sV properties
|
|
10898
|
+
types - get or set types - see types parameter and tH, tV properties
|
|
10899
|
+
gap - get or set the gap 0 see gap parameter
|
|
10900
|
+
slicesWidth - set the width so slices operate - different than width which will scale in general, not operating the slices
|
|
10901
|
+
slicesHeight - set the height so slices operate - different than height which will scale in general, not operating the slices
|
|
10902
|
+
slicesSale - set the scale so the slices operate - different than scale which will scale in general, not operating the slices
|
|
10903
|
+
slicesScaleX - set the scaleX so the slices operate - different than scaleX which will scale in general, not operating the slices
|
|
10904
|
+
slicesScaleY - set the scaleY so the slices operate - different than scaleY which will scale in general, not operating the slices
|
|
10905
|
+
exchange - set the [slices, types] in one array - used to recieve data from the ZIM Slicer
|
|
10906
|
+
sH - set an individual horizontal slice percent - these are sH0, sH1, sH2, etc. and are properties that can be animated and wiggled as well
|
|
10907
|
+
sV - set an individual vertical slice percent - these are sH0, sH1, sH2, etc. and are properties that can be animated and wiggled as well
|
|
10908
|
+
tH - set an individual horizontal slice type - also see types parameter
|
|
10909
|
+
tV - set an individual vertical slice type - also see types parameter
|
|
10910
|
+
|
|
10911
|
+
ALSO: see ZIM Docs for Bitmap properties, such as:
|
|
10912
|
+
width, height, widthOnly, heightOnly, draggable, level, blendMode, etc.
|
|
10913
|
+
ALSO: see the CreateJS Easel Docs for Bitmap properties, such as:
|
|
10914
|
+
x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
|
|
10915
|
+
alpha, cursor, shadow, mouseEnabled, etc.
|
|
10916
|
+
|
|
10917
|
+
EVENTS
|
|
10918
|
+
See the CreateJS Easel Docs for Bitmap events, such as:
|
|
10919
|
+
added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
|
|
10920
|
+
--*///+50.7
|
|
10921
|
+
zim.SlicedBitmap = function(width, height, obj, slices, types, gap, scale, style, group, inherit) {
|
|
10922
|
+
var sig = "width, height, obj, slices, types, gap, scale, style, group, inherit";
|
|
10923
|
+
var duo; if (duo = zob(zim.SlicedBitmap, arguments, sig, this)) return duo;
|
|
10924
|
+
z_d("50.75");
|
|
10925
|
+
|
|
10926
|
+
this.group = group;
|
|
10927
|
+
var DS = style===false?{}:zim.getStyle("SlicedBitmap", this.group, inherit);
|
|
10928
|
+
|
|
10929
|
+
var objCanvas;
|
|
10930
|
+
var message = "ZIM SlicedBitmap needs DisplayObject";
|
|
10931
|
+
if (zot(obj)) obj = DS.obj!=null?DS.obj:null;
|
|
10932
|
+
if (!obj.getBounds) {zogy(message); return;}
|
|
10933
|
+
var b = obj.getBounds();
|
|
10934
|
+
var w = b.width;
|
|
10935
|
+
var h = b.height;
|
|
10936
|
+
if (zot(width)) width = DS.width!=null?DS.width:500;
|
|
10937
|
+
if (zot(height)) height = DS.height!=null?DS.height:500;
|
|
10938
|
+
if (!obj.cacheCanvas) {
|
|
10939
|
+
if (obj.cache) {
|
|
10940
|
+
obj.cache(b.x,b.y,w,h);
|
|
10941
|
+
objCanvas = obj.cacheCanvas;
|
|
10942
|
+
}
|
|
10943
|
+
else {zogy(message); return;}
|
|
10944
|
+
} else {
|
|
10945
|
+
objCanvas = obj.cacheCanvas;
|
|
10946
|
+
}
|
|
10947
|
+
if (zot(slices)) slices = DS.slices!=null?DS.slices:[[],[]];
|
|
10948
|
+
var defaults = [[1],[1]];
|
|
10949
|
+
zim.loop(slices,function(s,i) {
|
|
10950
|
+
zim.loop(s,function() {
|
|
10951
|
+
defaults[i].push(1);
|
|
10952
|
+
});
|
|
10953
|
+
});
|
|
10954
|
+
if (zot(types)) types = DS.types!=null?DS.types:defaults;
|
|
10955
|
+
if (zot(scale)) scale = DS.scale!=null?DS.scale:1;
|
|
10956
|
+
|
|
10957
|
+
// convert to createjs pixels rather than percent
|
|
10958
|
+
var slicesSend = zim.copy(slices);
|
|
10959
|
+
zim.loop(slicesSend[0], function(s,i) {
|
|
10960
|
+
slicesSend[0][i] = s*w;
|
|
10961
|
+
});
|
|
10962
|
+
zim.loop(slicesSend[1], function(s,i) {
|
|
10963
|
+
slicesSend[1][i] = s*h;
|
|
10964
|
+
});
|
|
10965
|
+
var sb = this.scaleBitmap = new createjs.ScaleBitmap(objCanvas, slicesSend, types, gap);
|
|
10966
|
+
slicesSend = null;
|
|
10967
|
+
sb.setDrawSize(width,height);
|
|
10968
|
+
sb.cache(0,0,width,height,scale);
|
|
10969
|
+
|
|
10970
|
+
|
|
10971
|
+
this.zimBitmap_constructor(sb.cacheCanvas);
|
|
10972
|
+
this.type = "SlicedBitmap";
|
|
10973
|
+
var that = this;
|
|
10974
|
+
|
|
10975
|
+
// METHODS
|
|
10976
|
+
|
|
10977
|
+
that.slicesSca = function(scale, scaleY) {
|
|
10978
|
+
if (zot(scale)) scale = that.slicesScaleX;
|
|
10979
|
+
if (zot(scaleY)) scaleY = scale;
|
|
10980
|
+
obj.slicesScaleX = scale; obj.slicesScaleY = scaleY;
|
|
10981
|
+
return that;
|
|
10982
|
+
};
|
|
10983
|
+
|
|
10984
|
+
// PROPERTIES
|
|
10985
|
+
|
|
10986
|
+
Object.defineProperty(that, 'slicesWidth', {
|
|
10987
|
+
get: function() {
|
|
10988
|
+
return width;
|
|
10989
|
+
},
|
|
10990
|
+
set: function(value) {
|
|
10991
|
+
width = value;
|
|
10992
|
+
sb.setDrawSize(width, height);
|
|
10993
|
+
sb.cache(0,0,width,height,scale);
|
|
10994
|
+
that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
|
|
10995
|
+
that.setBounds(null);
|
|
10996
|
+
if (that.transformControls) that.transformControls.resize();
|
|
10997
|
+
}
|
|
10998
|
+
});
|
|
10999
|
+
Object.defineProperty(that, 'ssW', { // no transformControls resize as was feeding back from transform
|
|
11000
|
+
get: function() {
|
|
11001
|
+
return width;
|
|
11002
|
+
},
|
|
11003
|
+
set: function(value) {
|
|
11004
|
+
width = value;
|
|
11005
|
+
sb.setDrawSize(width, height);
|
|
11006
|
+
sb.cache(0,0,width,height,scale);
|
|
11007
|
+
that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
|
|
11008
|
+
that.setBounds(null);
|
|
11009
|
+
}
|
|
11010
|
+
});
|
|
11011
|
+
|
|
11012
|
+
Object.defineProperty(that, 'slicesHeight', {
|
|
11013
|
+
get: function() {
|
|
11014
|
+
return height;
|
|
11015
|
+
},
|
|
11016
|
+
set: function(value) {
|
|
11017
|
+
height = value;
|
|
11018
|
+
sb.setDrawSize(width, height);
|
|
11019
|
+
sb.cache(0,0,width,height,scale);
|
|
11020
|
+
that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
|
|
11021
|
+
that.setBounds(null);
|
|
11022
|
+
if (that.transformControls) that.transformControls.resize();
|
|
11023
|
+
}
|
|
11024
|
+
});
|
|
11025
|
+
Object.defineProperty(that, 'ssH', { // no transformControls resize as was feeding back from transform
|
|
11026
|
+
get: function() {
|
|
11027
|
+
return height;
|
|
11028
|
+
},
|
|
11029
|
+
set: function(value) {
|
|
11030
|
+
height = value;
|
|
11031
|
+
sb.setDrawSize(width, height);
|
|
11032
|
+
sb.cache(0,0,width,height,scale);
|
|
11033
|
+
that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
|
|
11034
|
+
that.setBounds(null);
|
|
11035
|
+
}
|
|
11036
|
+
});
|
|
11037
|
+
|
|
11038
|
+
var originalWidth = width;
|
|
11039
|
+
Object.defineProperty(that, 'slicesScaleX', {
|
|
11040
|
+
get: function() {
|
|
11041
|
+
return width/originalWidth;
|
|
11042
|
+
},
|
|
11043
|
+
set: function(value) {
|
|
11044
|
+
that.slicesWidth = value?originalWidth*value:0;
|
|
11045
|
+
}
|
|
11046
|
+
});
|
|
11047
|
+
Object.defineProperty(that, 'ssX', { // no transformControls resize as was feeding back from transform
|
|
11048
|
+
get: function() {
|
|
11049
|
+
return width/originalWidth;
|
|
11050
|
+
},
|
|
11051
|
+
set: function(value) {
|
|
11052
|
+
that.ssW = value?originalWidth*value:0;
|
|
11053
|
+
}
|
|
11054
|
+
});
|
|
11055
|
+
|
|
11056
|
+
var originalHeight = height;
|
|
11057
|
+
Object.defineProperty(that, 'slicesScaleY', {
|
|
11058
|
+
get: function() {
|
|
11059
|
+
return height/originalHeight;
|
|
11060
|
+
},
|
|
11061
|
+
set: function(value) {
|
|
11062
|
+
that.slicesHeight = value?originalHeight*value:0;
|
|
11063
|
+
}
|
|
11064
|
+
});
|
|
11065
|
+
Object.defineProperty(that, 'ssY', { // no transformControls resize as was feeding back from transform
|
|
11066
|
+
get: function() {
|
|
11067
|
+
return height/originalHeight;
|
|
11068
|
+
},
|
|
11069
|
+
set: function(value) {
|
|
11070
|
+
that.ssH = value?originalHeight*value:0;
|
|
11071
|
+
}
|
|
11072
|
+
});
|
|
11073
|
+
|
|
11074
|
+
Object.defineProperty(that, 'slicesScale', {
|
|
11075
|
+
get: function() {
|
|
11076
|
+
return width/originalWidth;
|
|
11077
|
+
},
|
|
11078
|
+
set: function(value) {
|
|
11079
|
+
that.slicesWidth = value?originalWidth*value:0;
|
|
11080
|
+
that.slicesHeight = value?originalHeight*value:0;
|
|
11081
|
+
}
|
|
11082
|
+
});
|
|
11083
|
+
|
|
11084
|
+
|
|
11085
|
+
Object.defineProperty(that, 'slices', {
|
|
11086
|
+
get: function() {
|
|
11087
|
+
return slices;
|
|
11088
|
+
},
|
|
11089
|
+
set: function(value) {
|
|
11090
|
+
if (zot(value) || !Array.isArray(value)) value = [[],[]];
|
|
11091
|
+
slices = value;
|
|
11092
|
+
var b = obj.getBounds();
|
|
11093
|
+
var w = b.width;
|
|
11094
|
+
var h = b.height;
|
|
11095
|
+
var slicesSend = zim.copy(slices);
|
|
11096
|
+
zim.loop(slicesSend[0], function(s,i) {
|
|
11097
|
+
slicesSend[0][i] = s*w;
|
|
11098
|
+
});
|
|
11099
|
+
zim.loop(slicesSend[1], function(s,i) {
|
|
11100
|
+
slicesSend[1][i] = s*h;
|
|
11101
|
+
});
|
|
11102
|
+
sb.slices = slicesSend;
|
|
11103
|
+
slicesSend = null;
|
|
11104
|
+
sb.updateCache();
|
|
11105
|
+
}
|
|
11106
|
+
});
|
|
11107
|
+
|
|
11108
|
+
Object.defineProperty(that, 'types', {
|
|
11109
|
+
get: function() {
|
|
11110
|
+
return types;
|
|
11111
|
+
},
|
|
11112
|
+
set: function(value) {
|
|
11113
|
+
if (zot(value) || !Array.isArray(value)) {
|
|
11114
|
+
var defaults = [[1],[1]];
|
|
11115
|
+
zim.loop(slices,function(s,i) {
|
|
11116
|
+
zim.loop(s,function() {
|
|
11117
|
+
defaults[i].push(1);
|
|
11118
|
+
});
|
|
11119
|
+
});
|
|
11120
|
+
value = defaults;
|
|
11121
|
+
}
|
|
11122
|
+
sb.types = types = value;
|
|
11123
|
+
sb.updateCache();
|
|
11124
|
+
}
|
|
11125
|
+
});
|
|
11126
|
+
|
|
11127
|
+
Object.defineProperty(that, 'gap', {
|
|
11128
|
+
get: function() {
|
|
11129
|
+
return gap;
|
|
11130
|
+
},
|
|
11131
|
+
set: function(value) {
|
|
11132
|
+
sb.gap = gap = value;
|
|
11133
|
+
}
|
|
11134
|
+
});
|
|
11135
|
+
|
|
11136
|
+
Object.defineProperty(that, 'exchange', {
|
|
11137
|
+
get: function() {
|
|
11138
|
+
return [slices, types];
|
|
11139
|
+
},
|
|
11140
|
+
set: function(value) {
|
|
11141
|
+
var b = obj.getBounds();
|
|
11142
|
+
var w = b.width;
|
|
11143
|
+
var h = b.height;
|
|
11144
|
+
slices = value[0];
|
|
11145
|
+
var slicesSend = zim.copy(slices);
|
|
11146
|
+
zim.loop(slicesSend[0], function(s,i) {
|
|
11147
|
+
slicesSend[0][i] = s*w;
|
|
11148
|
+
});
|
|
11149
|
+
zim.loop(slicesSend[1], function(s,i) {
|
|
11150
|
+
slicesSend[1][i] = s*h;
|
|
11151
|
+
});
|
|
11152
|
+
sb.slices = slicesSend;
|
|
11153
|
+
slicesSend = null;
|
|
11154
|
+
sb.types = types = value[1];
|
|
11155
|
+
sb.updateCache();
|
|
11156
|
+
}
|
|
11157
|
+
});
|
|
11158
|
+
|
|
11159
|
+
zim.loop(20, function(i) {
|
|
11160
|
+
Object.defineProperty(that, 'sH'+i, {
|
|
11161
|
+
get: function() {
|
|
11162
|
+
return slices[0][i];
|
|
11163
|
+
},
|
|
11164
|
+
set: function(value) {
|
|
11165
|
+
slices[0][i] = value;
|
|
11166
|
+
that.slices = slices;
|
|
11167
|
+
}
|
|
11168
|
+
});
|
|
11169
|
+
});
|
|
11170
|
+
|
|
11171
|
+
zim.loop(20, function(i) {
|
|
11172
|
+
Object.defineProperty(that, 'sV'+i, {
|
|
11173
|
+
get: function() {
|
|
11174
|
+
return slices[1][i];
|
|
11175
|
+
},
|
|
11176
|
+
set: function(value) {
|
|
11177
|
+
slices[1][i] = value;
|
|
11178
|
+
that.slices = slices;
|
|
11179
|
+
}
|
|
11180
|
+
});
|
|
11181
|
+
});
|
|
11182
|
+
|
|
11183
|
+
zim.loop(20, function(i) {
|
|
11184
|
+
Object.defineProperty(that, 'tH'+i, {
|
|
11185
|
+
get: function() {
|
|
11186
|
+
return types[0][i];
|
|
11187
|
+
},
|
|
11188
|
+
set: function(value) {
|
|
11189
|
+
types[0][i] = value;
|
|
11190
|
+
that.types = types;
|
|
11191
|
+
}
|
|
11192
|
+
});
|
|
11193
|
+
});
|
|
11194
|
+
|
|
11195
|
+
zim.loop(20, function(i) {
|
|
11196
|
+
Object.defineProperty(that, 'tV'+i, {
|
|
11197
|
+
get: function() {
|
|
11198
|
+
return types[1][i];
|
|
11199
|
+
},
|
|
11200
|
+
set: function(value) {
|
|
11201
|
+
types[1][i] = value;
|
|
11202
|
+
that.types = types;
|
|
11203
|
+
}
|
|
11204
|
+
});
|
|
11205
|
+
});
|
|
11206
|
+
|
|
11207
|
+
}
|
|
11208
|
+
zim.extend(zim.SlicedBitmap, zim.Bitmap, null, "zimBitmap", false);
|
|
11209
|
+
//-50.75
|
|
11210
|
+
|
|
10789
11211
|
/*--
|
|
10790
11212
|
zim.Sprite = function(image, cols, rows, count, offsetX, offsetY, spacingX, spacingY, width, height, animations, json, id, globalControl, spriteSheet, label, frame, style, group, inherit)
|
|
10791
11213
|
|
|
@@ -11516,6 +11938,7 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
|
|
|
11516
11938
|
this.setBounds = function(a,b,c,d) {
|
|
11517
11939
|
var n = normalizeBounds(a, b, c, d);
|
|
11518
11940
|
that.cjsSprite_setBounds(n[0],n[1],n[2],n[3]);
|
|
11941
|
+
that.width;
|
|
11519
11942
|
return that;
|
|
11520
11943
|
};
|
|
11521
11944
|
this.getBounds = function(targetSpace) {
|
|
@@ -11703,6 +12126,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
11703
12126
|
this.setBounds = function(a,b,c,d) {
|
|
11704
12127
|
var n = normalizeBounds(a, b, c, d);
|
|
11705
12128
|
that.cjsMovieClip_setBounds(n[0],n[1],n[2],n[3]);
|
|
12129
|
+
that.width;
|
|
11706
12130
|
return that;
|
|
11707
12131
|
};
|
|
11708
12132
|
this.getBounds = function(targetSpace) {
|
|
@@ -23083,8 +23507,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
|
|
|
23083
23507
|
|
|
23084
23508
|
PROPERTIES
|
|
23085
23509
|
type - the name of the class as a String
|
|
23086
|
-
text - get
|
|
23087
|
-
See: https://zimjs.com/zapp/Z_VSR9X for updating text
|
|
23510
|
+
text - get or set the text
|
|
23088
23511
|
labels - an array of ZIM Label objects for the letters
|
|
23089
23512
|
numLetters - how many letters (same as numChildren)
|
|
23090
23513
|
|
|
@@ -23126,391 +23549,449 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
23126
23549
|
this.type = "LabelLetters";
|
|
23127
23550
|
|
|
23128
23551
|
var that = this;
|
|
23129
|
-
var letterData = that.letterData = [];
|
|
23130
|
-
var original, data;
|
|
23131
|
-
if (label.type != "Label") {
|
|
23132
|
-
data = parseHTML(label); // returns {text:text, data:data}
|
|
23133
|
-
letterData = data.data;
|
|
23134
|
-
label = new zim.Label(data.text);
|
|
23135
|
-
} else {
|
|
23136
|
-
data = parseHTML(label.text);
|
|
23137
|
-
letterData = data.data;
|
|
23138
|
-
label.text = data.text;
|
|
23139
|
-
}
|
|
23140
|
-
that.text = data.original;
|
|
23141
|
-
that._color = label.color;
|
|
23142
|
-
|
|
23143
|
-
// handle DIR effect
|
|
23144
|
-
if ((WW.DIR && WW.DIR=="rtl") || (!WW.DIR && zim.DIR=="rtl")) {
|
|
23145
|
-
if (lineAlign=="start") lineAlign="right";
|
|
23146
|
-
else if (lineAlign=="end") lineAlign="left";
|
|
23147
|
-
} else {
|
|
23148
|
-
if (lineAlign=="start") lineAlign="left";
|
|
23149
|
-
else if (lineAlign=="end") lineAlign="right";
|
|
23150
|
-
}
|
|
23151
|
-
|
|
23152
|
-
function parseHTML(html) {
|
|
23153
|
-
var data = [];
|
|
23154
|
-
|
|
23155
|
-
// var example = "LabelLetters()<br><br><font group=heading backgroundColor=yellow rollBackgroundColor=green><a href=https://zimjs.com target=_blank>Example</a></font>: <b>strong</b> <i>emphasis</i> <u>underline</u><br><font color=red size=50 family=verdana><strong>big</strong> red verdana</font><br>the next line"
|
|
23156
|
-
// "LabelLetters()Example: strong emphasis underlinebig red verdanathe next line"
|
|
23157
|
-
// "01234567890123456789012345678901234567890123456789012345678901234567890120123456789012"
|
|
23158
|
-
// "0 1 2 3 4 5 6 7"
|
|
23159
|
-
// html = "!Roger הגיע בשבילך משהו בדואר Dan אני לומד עברית";
|
|
23160
|
-
// html = "הגיע בשבילך משהו בדואר.";
|
|
23161
|
-
|
|
23162
|
-
function insert(data) {
|
|
23163
|
-
return data.split("").reverse().join("")
|
|
23164
|
-
}
|
|
23165
|
-
if (rtl) {
|
|
23166
|
-
count = -1;
|
|
23167
|
-
html = html.replace(/[\u0591-\u07FF]+/ig, insert);
|
|
23168
|
-
|
|
23169
|
-
// and there may be tags or LTR characters next to RTL without a space:
|
|
23170
|
-
html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
|
|
23171
|
-
html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space
|
|
23172
|
-
html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
|
|
23173
|
-
html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
|
|
23174
|
-
|
|
23175
|
-
var sp = html.split(/-!!-/g);
|
|
23176
|
-
zim.loop(sp, function(ssp, i){
|
|
23177
|
-
if (ssp.match(/[\u0591-\u07FF]/i)) {
|
|
23178
|
-
sp[i] = ssp.split(" ").reverse().join(" ");
|
|
23179
|
-
}
|
|
23180
|
-
});
|
|
23181
|
-
html = sp.join("");
|
|
23182
|
-
}
|
|
23183
|
-
|
|
23184
23552
|
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
|
|
23190
|
-
|
|
23191
|
-
|
|
23192
|
-
|
|
23193
|
-
|
|
23194
|
-
|
|
23195
|
-
|
|
23196
|
-
|
|
23197
|
-
|
|
23198
|
-
|
|
23199
|
-
|
|
23200
|
-
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
var regs = [
|
|
23204
|
-
/<(a|i|u|f|br|\/a|\/i|\/u|\/f|\/b)[^>]*>/g,
|
|
23205
|
-
/<(a|i|u|f|br|\/a|\/i|\/u|\/f|b)[^>]*>/g,
|
|
23206
|
-
/<(b|i|u|f|br|\/b|\/i|\/u|\/f|\/a)[^>]*>/g,
|
|
23207
|
-
/<(b|i|u|f|br|\/b|\/i|\/u|\/f|a)[^>]*>/g,
|
|
23208
|
-
/<(b|a|u|f|br|\/b|\/a|\/u|\/f|\/i)[^>]*>/g,
|
|
23209
|
-
/<(b|a|u|f|br|\/b|\/a|\/u|\/f|i)[^>]*>/g,
|
|
23210
|
-
/<(b|a|i|f|br|\/b|\/a|\/i|\/f|\/u)[^>]*>/g,
|
|
23211
|
-
/<(b|a|i|f|br|\/b|\/a|\/i|\/f|u)[^>]*>/g,
|
|
23212
|
-
/<(b|a|i|u|br|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,
|
|
23213
|
-
/<(b|a|i|u|br|\/b|\/a|\/i|\/u|f)[^>]*>/g
|
|
23214
|
-
];
|
|
23215
|
-
var types = ["b","a","i","u","font"];
|
|
23216
|
-
var p;
|
|
23217
|
-
zim.loop(types, function(type, i) {
|
|
23218
|
-
p = html.replace(regs[i*2],"");
|
|
23219
|
-
var arr;
|
|
23220
|
-
if (type=="font") {
|
|
23221
|
-
arr = p.split("<font ");
|
|
23222
|
-
} else if (type=="a") {
|
|
23223
|
-
arr = p.split("<a ");
|
|
23224
|
-
} else {
|
|
23225
|
-
arr = p.split("<"+type+">");
|
|
23226
|
-
}
|
|
23227
|
-
process(arr, type, 0); // 0 for add
|
|
23228
|
-
|
|
23229
|
-
p = html.replace(regs[i*2+1],"");
|
|
23230
|
-
arr = p.split("</"+type+">");
|
|
23231
|
-
process(arr, type, 1); // 1 for remove
|
|
23232
|
-
});
|
|
23233
|
-
|
|
23553
|
+
function make() {
|
|
23554
|
+
|
|
23555
|
+
that.disposeAllChildren();
|
|
23556
|
+
|
|
23557
|
+
var letterData = that.letterData = [];
|
|
23558
|
+
var original, data;
|
|
23559
|
+
if (label.type != "Label") {
|
|
23560
|
+
data = parseHTML(label); // returns {text:text, data:data}
|
|
23561
|
+
letterData = data.data;
|
|
23562
|
+
label = new zim.Label(data.text);
|
|
23563
|
+
} else {
|
|
23564
|
+
data = parseHTML(label.text);
|
|
23565
|
+
letterData = data.data;
|
|
23566
|
+
label.text = data.text;
|
|
23567
|
+
}
|
|
23568
|
+
that._text = data.original;
|
|
23569
|
+
that._color = label.color;
|
|
23234
23570
|
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
|
|
23571
|
+
// handle DIR effect
|
|
23572
|
+
if ((WW.DIR && WW.DIR=="rtl") || (!WW.DIR && zim.DIR=="rtl")) {
|
|
23573
|
+
if (lineAlign=="start") lineAlign="right";
|
|
23574
|
+
else if (lineAlign=="end") lineAlign="left";
|
|
23575
|
+
} else {
|
|
23576
|
+
if (lineAlign=="start") lineAlign="left";
|
|
23577
|
+
else if (lineAlign=="end") lineAlign="right";
|
|
23578
|
+
}
|
|
23241
23579
|
|
|
23242
|
-
function
|
|
23243
|
-
|
|
23244
|
-
if ((type=="font" || type=="a") && action==0) {
|
|
23245
|
-
var length = text[0].length;
|
|
23246
|
-
zim.loop(text, function(s, i) {
|
|
23247
|
-
|
|
23248
|
-
if (i==0) return;
|
|
23249
|
-
var d = data[length];
|
|
23250
|
-
if (!d) data[length] = [];
|
|
23251
|
-
d = data[length] ;
|
|
23252
|
-
|
|
23253
|
-
var arr = s.split(">");
|
|
23580
|
+
function parseHTML(html) {
|
|
23581
|
+
var data = [];
|
|
23254
23582
|
|
|
23255
|
-
|
|
23256
|
-
|
|
23583
|
+
// var example = "LabelLetters()<br><br><font group=heading backgroundColor=yellow rollBackgroundColor=green><a href=https://zimjs.com target=_blank>Example</a></font>: <b>strong</b> <i>emphasis</i> <u>underline</u><br><font color=red size=50 family=verdana><strong>big</strong> red verdana</font><br>the next line"
|
|
23584
|
+
// "LabelLetters()Example: strong emphasis underlinebig red verdanathe next line"
|
|
23585
|
+
// "01234567890123456789012345678901234567890123456789012345678901234567890120123456789012"
|
|
23586
|
+
// "0 1 2 3 4 5 6 7"
|
|
23587
|
+
// html = "!Roger הגיע בשבילך משהו בדואר Dan אני לומד עברית";
|
|
23588
|
+
// html = "הגיע בשבילך משהו בדואר.";
|
|
23257
23589
|
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
} else {
|
|
23261
|
-
text.pop();
|
|
23262
|
-
var running = 0;
|
|
23263
|
-
zim.loop(text, function(s) {
|
|
23264
|
-
running += s.length;
|
|
23265
|
-
var d = data[running];
|
|
23266
|
-
if (!d) data[running] = [];
|
|
23267
|
-
d = data[running];
|
|
23268
|
-
if (d[action]) d[action].push(type);
|
|
23269
|
-
else d[action] = [type];
|
|
23270
|
-
});
|
|
23271
|
-
}
|
|
23590
|
+
function insert(data) {
|
|
23591
|
+
return data.split("").reverse().join("")
|
|
23272
23592
|
}
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
|
|
23297
|
-
|
|
23298
|
-
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
23307
|
-
|
|
23308
|
-
|
|
23309
|
-
|
|
23310
|
-
|
|
23311
|
-
|
|
23312
|
-
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
var backgroundColorCheck = false;
|
|
23337
|
-
var rollBackgroundColorCheck = false;
|
|
23338
|
-
|
|
23339
|
-
// ROLLOVER CONTROL
|
|
23340
|
-
that.rolls = [[]];
|
|
23341
|
-
|
|
23342
|
-
for (i=0; i<that.numLetters; i++) {
|
|
23343
|
-
|
|
23344
|
-
// PARSE TAG CHECKS
|
|
23593
|
+
if (rtl) {
|
|
23594
|
+
count = -1;
|
|
23595
|
+
html = html.replace(/[\u0591-\u07FF]+/ig, insert);
|
|
23596
|
+
|
|
23597
|
+
// and there may be tags or LTR characters next to RTL without a space:
|
|
23598
|
+
html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
|
|
23599
|
+
html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space
|
|
23600
|
+
html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
|
|
23601
|
+
html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
|
|
23602
|
+
|
|
23603
|
+
var sp = html.split(/-!!-/g);
|
|
23604
|
+
zim.loop(sp, function(ssp, i){
|
|
23605
|
+
if (ssp.match(/[\u0591-\u07FF]/i)) {
|
|
23606
|
+
sp[i] = ssp.split(" ").reverse().join(" ");
|
|
23607
|
+
}
|
|
23608
|
+
});
|
|
23609
|
+
html = sp.join("");
|
|
23610
|
+
}
|
|
23611
|
+
|
|
23612
|
+
|
|
23613
|
+
// normalize tags
|
|
23614
|
+
html = html.replace(/\n|\r/g,"<br>");
|
|
23615
|
+
html = html.replace(/<strong>|<strong \/>|<strong\/>/gi,"<b>");
|
|
23616
|
+
html = html.replace(/<\/strong>/gi,"</b>");
|
|
23617
|
+
html = html.replace(/<em>|<em \/>|<em\/>/gi,"<i>");
|
|
23618
|
+
html = html.replace(/<\/em>/gi,"</i>");
|
|
23619
|
+
html = html.replace(/\\n|\\r/g,"<br>");
|
|
23620
|
+
html = html.replace(/<br>|<br \/>|<br\/>(<\/br>)?/gi,"<br>");
|
|
23621
|
+
html = html.replace(/<b/gi,"<b");
|
|
23622
|
+
html = html.replace(/<i/gi,"<i");
|
|
23623
|
+
html = html.replace(/<u/gi,"<u");
|
|
23624
|
+
html = html.replace(/<br/gi,"<br");
|
|
23625
|
+
html = html.replace(/<a/gi,"<a");
|
|
23626
|
+
html = html.replace(/<font/gi,"<font");
|
|
23627
|
+
|
|
23628
|
+
// turn all other tags into "" do split on tag and count index for tag
|
|
23629
|
+
// process this and store in data so get index of tags in string with no tags counted
|
|
23630
|
+
|
|
23631
|
+
var regs = [
|
|
23632
|
+
/<(a|i|u|f|br|\/a|\/i|\/u|\/f|\/b)[^>]*>/g,
|
|
23633
|
+
/<(a|i|u|f|br|\/a|\/i|\/u|\/f|b)[^>]*>/g,
|
|
23634
|
+
/<(b|i|u|f|br|\/b|\/i|\/u|\/f|\/a)[^>]*>/g,
|
|
23635
|
+
/<(b|i|u|f|br|\/b|\/i|\/u|\/f|a)[^>]*>/g,
|
|
23636
|
+
/<(b|a|u|f|br|\/b|\/a|\/u|\/f|\/i)[^>]*>/g,
|
|
23637
|
+
/<(b|a|u|f|br|\/b|\/a|\/u|\/f|i)[^>]*>/g,
|
|
23638
|
+
/<(b|a|i|f|br|\/b|\/a|\/i|\/f|\/u)[^>]*>/g,
|
|
23639
|
+
/<(b|a|i|f|br|\/b|\/a|\/i|\/f|u)[^>]*>/g,
|
|
23640
|
+
/<(b|a|i|u|br|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,
|
|
23641
|
+
/<(b|a|i|u|br|\/b|\/a|\/i|\/u|f)[^>]*>/g
|
|
23642
|
+
];
|
|
23643
|
+
var types = ["b","a","i","u","font"];
|
|
23644
|
+
var p;
|
|
23645
|
+
zim.loop(types, function(type, i) {
|
|
23646
|
+
p = html.replace(regs[i*2],"");
|
|
23647
|
+
var arr;
|
|
23648
|
+
if (type=="font") {
|
|
23649
|
+
arr = p.split("<font ");
|
|
23650
|
+
} else if (type=="a") {
|
|
23651
|
+
arr = p.split("<a ");
|
|
23652
|
+
} else {
|
|
23653
|
+
arr = p.split("<"+type+">");
|
|
23654
|
+
}
|
|
23655
|
+
process(arr, type, 0); // 0 for add
|
|
23345
23656
|
|
|
23346
|
-
|
|
23347
|
-
|
|
23657
|
+
p = html.replace(regs[i*2+1],"");
|
|
23658
|
+
arr = p.split("</"+type+">");
|
|
23659
|
+
process(arr, type, 1); // 1 for remove
|
|
23660
|
+
});
|
|
23661
|
+
|
|
23348
23662
|
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23367
|
-
|
|
23368
|
-
|
|
23663
|
+
p = html.replace(/<br>/gi,"@^#");
|
|
23664
|
+
p = p.replace(/<(b|a|i|u|f|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,"");
|
|
23665
|
+
var arr = p.split("@^#");
|
|
23666
|
+
original = arr.join("\n");
|
|
23667
|
+
p = arr.join("");
|
|
23668
|
+
process(arr, "br", 0); // 0 for add
|
|
23669
|
+
|
|
23670
|
+
function process(text, type, action) {
|
|
23671
|
+
if (text.length > 1) {
|
|
23672
|
+
if ((type=="font" || type=="a") && action==0) {
|
|
23673
|
+
var length = text[0].length;
|
|
23674
|
+
zim.loop(text, function(s, i) {
|
|
23675
|
+
|
|
23676
|
+
if (i==0) return;
|
|
23677
|
+
var d = data[length];
|
|
23678
|
+
if (!d) data[length] = [];
|
|
23679
|
+
d = data[length] ;
|
|
23680
|
+
|
|
23681
|
+
var arr = s.split(">");
|
|
23682
|
+
|
|
23683
|
+
if (d[action]) d[action].push(type + " " + arr[0]);
|
|
23684
|
+
else d[action] = [type + " " + arr[0]];
|
|
23685
|
+
|
|
23686
|
+
length += arr[1].length;
|
|
23687
|
+
});
|
|
23688
|
+
} else {
|
|
23689
|
+
text.pop();
|
|
23690
|
+
var running = 0;
|
|
23691
|
+
zim.loop(text, function(s) {
|
|
23692
|
+
running += s.length;
|
|
23693
|
+
var d = data[running];
|
|
23694
|
+
if (!d) data[running] = [];
|
|
23695
|
+
d = data[running];
|
|
23696
|
+
if (d[action]) d[action].push(type);
|
|
23697
|
+
else d[action] = [type];
|
|
23698
|
+
});
|
|
23369
23699
|
}
|
|
23370
|
-
}
|
|
23371
|
-
}
|
|
23700
|
+
}
|
|
23701
|
+
}
|
|
23372
23702
|
|
|
23373
|
-
//
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
if (item=="br") brCheck++;
|
|
23381
|
-
});
|
|
23382
|
-
zim.loop(d[i][0], function (item) {
|
|
23383
|
-
var r, ind;
|
|
23384
|
-
if (item.match(/^font/i)) {
|
|
23385
|
-
r = item.match(/ color\s?=\s?(\S*)/i);
|
|
23386
|
-
if (r) {
|
|
23387
|
-
colorCheck = r[1];
|
|
23388
|
-
ind = zim.colors.indexOf(colorCheck);
|
|
23389
|
-
if (ind>=0) colorCheck = zim.colorsHex[ind];
|
|
23390
|
-
colorCheck = colorCheck.replace(/'/g,"");
|
|
23391
|
-
}
|
|
23392
|
-
r = item.match(/size\s?=\s?(\S*)/i);
|
|
23393
|
-
if (r) sizeCheck = r[1];
|
|
23394
|
-
r = item.match(/backgroundColor\s?=\s?(\S*)/i);
|
|
23395
|
-
if (r) {
|
|
23396
|
-
backgroundColorCheck = r[1];
|
|
23397
|
-
ind = zim.colors.indexOf(backgroundColorCheck);
|
|
23398
|
-
if (ind>=0) backgroundColorCheck = zim.colorsHex[ind];
|
|
23399
|
-
backgroundColorCheck = backgroundColorCheck.replace(/'/g,"");
|
|
23400
|
-
}
|
|
23401
|
-
r = item.match(/rollBackgroundColor\s?=\s?(\S*)/i);
|
|
23402
|
-
if (r) {
|
|
23403
|
-
rollBackgroundColorCheck = r[1];
|
|
23404
|
-
ind = zim.colors.indexOf(rollBackgroundColorCheck);
|
|
23405
|
-
if (ind>=0) rollBackgroundColorCheck = zim.colorsHex[ind];
|
|
23406
|
-
rollBackgroundColorCheck = rollBackgroundColorCheck.replace(/'/g,"");
|
|
23407
|
-
}
|
|
23408
|
-
r = item.match(/group\s?=\s?(\S*)/i);
|
|
23409
|
-
if (r) groupCheck = r[1];
|
|
23410
|
-
r = item.match(/family\s?=\s?(.*)/i);
|
|
23411
|
-
if (r) {
|
|
23412
|
-
familyCheck = r[1];
|
|
23413
|
-
familyCheck = familyCheck.split(/\ssize\s?=|\scolor\s?=|\sgroup\s?=/i)[0];
|
|
23414
|
-
}
|
|
23415
|
-
return;
|
|
23416
|
-
}
|
|
23417
|
-
if (item.match(/^a/i)) {
|
|
23418
|
-
r = item.match(/href\s?=\s?(\S*)/i);
|
|
23419
|
-
if (r) urlCheck = r[1];
|
|
23420
|
-
r = item.match(/target\s?=\s?(\S*)/i);
|
|
23421
|
-
if (r) targetCheck = r[1];
|
|
23422
|
-
return;
|
|
23423
|
-
}
|
|
23424
|
-
});
|
|
23425
|
-
} // end start tag
|
|
23426
|
-
|
|
23427
|
-
} // end all tags
|
|
23703
|
+
// [[adds at index], [removes at index]]
|
|
23704
|
+
// b,i,u,br,a,font
|
|
23705
|
+
// var da = [,, [["b","i"]] ,[,["b"]],,,[["br","font color=red size=10 family=courier"]],["i"]],...];
|
|
23706
|
+
return {text:p, data:data, original:original};
|
|
23707
|
+
}
|
|
23708
|
+
|
|
23709
|
+
that.numLetters = label.text.length;
|
|
23428
23710
|
|
|
23429
|
-
//
|
|
23430
|
-
var
|
|
23431
|
-
if (
|
|
23432
|
-
|
|
23711
|
+
// NORMALIZE SPACINGS
|
|
23712
|
+
var letterSpacingsOriginal = !zot(letterSpacings);
|
|
23713
|
+
if (letterSpacings && !Array.isArray(letterSpacings)) letterSpacings = null;
|
|
23714
|
+
var i;
|
|
23715
|
+
if (!letterSpacings) {
|
|
23716
|
+
letterSpacings = [];
|
|
23717
|
+
for (i = 0; i < that.numLetters; i++) {
|
|
23718
|
+
letterSpacings.push(letterSpacing);
|
|
23719
|
+
}
|
|
23433
23720
|
} else {
|
|
23434
|
-
|
|
23435
|
-
|
|
23721
|
+
for (i = 0; i < that.numLetters; i++) {
|
|
23722
|
+
if (zot(letterSpacings[i])) letterSpacings[i] = letterSpacing;
|
|
23723
|
+
}
|
|
23436
23724
|
}
|
|
23437
|
-
that.
|
|
23438
|
-
|
|
23439
|
-
if (
|
|
23440
|
-
if (
|
|
23441
|
-
|
|
23442
|
-
|
|
23443
|
-
|
|
23444
|
-
|
|
23445
|
-
|
|
23446
|
-
|
|
23447
|
-
|
|
23448
|
-
|
|
23449
|
-
letter.zobc = letter.backgroundColor;
|
|
23450
|
-
that.rolls[letter.rollIndex].push(letter);
|
|
23451
|
-
letter.expand(0);
|
|
23452
|
-
letter.on("mouseover", rollOn);
|
|
23453
|
-
letter.on("mouseout", rollOff);
|
|
23725
|
+
that.letterSpacings = letterSpacings;
|
|
23726
|
+
|
|
23727
|
+
if (lineSpacings && !Array.isArray(lineSpacings)) lineSpacings = null;
|
|
23728
|
+
if (!lineSpacings) {
|
|
23729
|
+
lineSpacings = [];
|
|
23730
|
+
for (i = 0; i < that.numLetters - 1; i++) {
|
|
23731
|
+
lineSpacings.push(lineSpacing);
|
|
23732
|
+
}
|
|
23733
|
+
} else {
|
|
23734
|
+
for (i = 0; i < that.numLetters - 1; i++) {
|
|
23735
|
+
if (zot(lineSpacings[i])) lineSpacings[i] = lineSpacing;
|
|
23736
|
+
}
|
|
23454
23737
|
}
|
|
23738
|
+
that.lineSpacings = lineSpacings;
|
|
23455
23739
|
|
|
23456
|
-
|
|
23457
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23462
|
-
|
|
23463
|
-
|
|
23464
|
-
|
|
23465
|
-
|
|
23466
|
-
|
|
23467
|
-
}
|
|
23468
|
-
if (familyCheck) letter.font = familyCheck;
|
|
23469
|
-
if (sizeCheck) letter.size = sizeCheck;
|
|
23740
|
+
// LINE CONTROL
|
|
23741
|
+
that.labels = [];
|
|
23742
|
+
that.lines = [[]];
|
|
23743
|
+
var lineWidths = [];
|
|
23744
|
+
var lineHeights = [];
|
|
23745
|
+
var linePositionsY = [0];
|
|
23746
|
+
var lineY = 0;
|
|
23747
|
+
var lineW = 0;
|
|
23748
|
+
var lineH = 0;
|
|
23749
|
+
var lineNum = 0;
|
|
23750
|
+
var maxW = 0;
|
|
23470
23751
|
|
|
23752
|
+
// HTML CONTROL
|
|
23753
|
+
var d = letterData;
|
|
23754
|
+
var bCheck = false;
|
|
23755
|
+
var iCheck = false;
|
|
23756
|
+
var uCheck = false;
|
|
23757
|
+
var brCheck = false;
|
|
23758
|
+
var colorCheck = false;
|
|
23759
|
+
var sizeCheck = false;
|
|
23760
|
+
var groupCheck = false;
|
|
23761
|
+
var familyCheck = false;
|
|
23762
|
+
var urlCheck = false;
|
|
23763
|
+
var targetCheck = false;
|
|
23764
|
+
var backgroundColorCheck = false;
|
|
23765
|
+
var rollBackgroundColorCheck = false;
|
|
23471
23766
|
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
linePositionsY.push(lineY);
|
|
23475
|
-
lineHeights.push(zot(lineHeight)?lineH:lineHeight);
|
|
23476
|
-
lineWidths.push(lineW);
|
|
23477
|
-
maxW = Math.max(maxW, lineW);
|
|
23478
|
-
}
|
|
23767
|
+
// ROLLOVER CONTROL
|
|
23768
|
+
that.rolls = [[]];
|
|
23479
23769
|
|
|
23480
|
-
|
|
23481
|
-
|
|
23482
|
-
|
|
23483
|
-
|
|
23484
|
-
|
|
23485
|
-
|
|
23486
|
-
|
|
23487
|
-
|
|
23488
|
-
|
|
23489
|
-
|
|
23770
|
+
for (i=0; i<that.numLetters; i++) {
|
|
23771
|
+
|
|
23772
|
+
// PARSE TAG CHECKS
|
|
23773
|
+
|
|
23774
|
+
brCheck = false;
|
|
23775
|
+
if (d[i]) {
|
|
23776
|
+
|
|
23777
|
+
// end tags - do ends first just in case tag ends at same letter it starts
|
|
23778
|
+
if (d[i][1]) {
|
|
23779
|
+
if (d[i][1].indexOf("b") >= 0) bCheck = false;
|
|
23780
|
+
if (d[i][1].indexOf("i") >= 0) iCheck = false;
|
|
23781
|
+
if (d[i][1].indexOf("u") >= 0) uCheck = false;
|
|
23782
|
+
zim.loop(d[i][1], function (item) {
|
|
23783
|
+
if (item.match(/^font/i)) {
|
|
23784
|
+
colorCheck = false;
|
|
23785
|
+
backgroundColorCheck = false;
|
|
23786
|
+
if (rollBackgroundColorCheck) that.rolls.push([]);
|
|
23787
|
+
rollBackgroundColorCheck = false;
|
|
23788
|
+
sizeCheck = false;
|
|
23789
|
+
familyCheck = false;
|
|
23790
|
+
groupCheck = false;
|
|
23791
|
+
return;
|
|
23792
|
+
}
|
|
23793
|
+
if (item.match(/^a/i)) {
|
|
23794
|
+
urlCheck = false;
|
|
23795
|
+
targetCheck = false;
|
|
23796
|
+
return;
|
|
23797
|
+
}
|
|
23798
|
+
});
|
|
23799
|
+
}
|
|
23800
|
+
|
|
23801
|
+
// start tags
|
|
23802
|
+
if (d[i][0]) {
|
|
23803
|
+
if (d[i][0].indexOf("b") >= 0) bCheck = true;
|
|
23804
|
+
if (d[i][0].indexOf("i") >= 0) iCheck = true;
|
|
23805
|
+
if (d[i][0].indexOf("u") >= 0) uCheck = true;
|
|
23806
|
+
brCheck = 0;
|
|
23807
|
+
zim.loop(d[i][0], function (item) {
|
|
23808
|
+
if (item=="br") brCheck++;
|
|
23809
|
+
});
|
|
23810
|
+
zim.loop(d[i][0], function (item) {
|
|
23811
|
+
var r, ind;
|
|
23812
|
+
if (item.match(/^font/i)) {
|
|
23813
|
+
r = item.match(/ color\s?=\s?(\S*)/i);
|
|
23814
|
+
if (r) {
|
|
23815
|
+
colorCheck = r[1];
|
|
23816
|
+
ind = zim.colors.indexOf(colorCheck);
|
|
23817
|
+
if (ind>=0) colorCheck = zim.colorsHex[ind];
|
|
23818
|
+
colorCheck = colorCheck.replace(/'/g,"");
|
|
23819
|
+
}
|
|
23820
|
+
r = item.match(/size\s?=\s?(\S*)/i);
|
|
23821
|
+
if (r) sizeCheck = r[1];
|
|
23822
|
+
r = item.match(/backgroundColor\s?=\s?(\S*)/i);
|
|
23823
|
+
if (r) {
|
|
23824
|
+
backgroundColorCheck = r[1];
|
|
23825
|
+
ind = zim.colors.indexOf(backgroundColorCheck);
|
|
23826
|
+
if (ind>=0) backgroundColorCheck = zim.colorsHex[ind];
|
|
23827
|
+
backgroundColorCheck = backgroundColorCheck.replace(/'/g,"");
|
|
23828
|
+
}
|
|
23829
|
+
r = item.match(/rollBackgroundColor\s?=\s?(\S*)/i);
|
|
23830
|
+
if (r) {
|
|
23831
|
+
rollBackgroundColorCheck = r[1];
|
|
23832
|
+
ind = zim.colors.indexOf(rollBackgroundColorCheck);
|
|
23833
|
+
if (ind>=0) rollBackgroundColorCheck = zim.colorsHex[ind];
|
|
23834
|
+
rollBackgroundColorCheck = rollBackgroundColorCheck.replace(/'/g,"");
|
|
23835
|
+
}
|
|
23836
|
+
r = item.match(/group\s?=\s?(\S*)/i);
|
|
23837
|
+
if (r) groupCheck = r[1];
|
|
23838
|
+
r = item.match(/family\s?=\s?(.*)/i);
|
|
23839
|
+
if (r) {
|
|
23840
|
+
familyCheck = r[1];
|
|
23841
|
+
familyCheck = familyCheck.split(/\ssize\s?=|\scolor\s?=|\sgroup\s?=/i)[0];
|
|
23842
|
+
}
|
|
23843
|
+
return;
|
|
23844
|
+
}
|
|
23845
|
+
if (item.match(/^a/i)) {
|
|
23846
|
+
r = item.match(/href\s?=\s?(\S*)/i);
|
|
23847
|
+
if (r) urlCheck = r[1];
|
|
23848
|
+
r = item.match(/target\s?=\s?(\S*)/i);
|
|
23849
|
+
if (r) targetCheck = r[1];
|
|
23850
|
+
return;
|
|
23851
|
+
}
|
|
23852
|
+
});
|
|
23853
|
+
} // end start tag
|
|
23854
|
+
|
|
23855
|
+
} // end all tags
|
|
23856
|
+
|
|
23857
|
+
// HANDLE CHECKS AND STORE MAX SIZES
|
|
23858
|
+
var letter;
|
|
23859
|
+
if (groupCheck) {
|
|
23860
|
+
letter = new zim.Label({text:label.text[i], group:groupCheck})
|
|
23861
|
+
} else {
|
|
23862
|
+
letter = label.clone();
|
|
23863
|
+
letter.text = label.text[i];
|
|
23864
|
+
}
|
|
23865
|
+
that.labels.push(letter);
|
|
23866
|
+
|
|
23867
|
+
if (bCheck) letter.bold = true;
|
|
23868
|
+
if (iCheck) letter.italic = true;
|
|
23869
|
+
if (colorCheck) letter.color = colorCheck;
|
|
23870
|
+
if (backgroundColorCheck) letter.backgroundColor = backgroundColorCheck;
|
|
23871
|
+
|
|
23872
|
+
var s = letterSpacingsOriginal?letterSpacings[i]:zot(letter.backgroundColor)?letterSpacings[i]:-.5;
|
|
23873
|
+
|
|
23874
|
+
if (rollBackgroundColorCheck) {
|
|
23875
|
+
letter.rollIndex = that.rolls.length-1;
|
|
23876
|
+
letter.zrbc = rollBackgroundColorCheck;
|
|
23877
|
+
letter.zobc = letter.backgroundColor;
|
|
23878
|
+
that.rolls[letter.rollIndex].push(letter);
|
|
23879
|
+
letter.expand(0);
|
|
23880
|
+
letter.on("mouseover", rollOn);
|
|
23881
|
+
letter.on("mouseout", rollOff);
|
|
23882
|
+
}
|
|
23883
|
+
|
|
23884
|
+
if (urlCheck) {
|
|
23885
|
+
letter.expand(s,0);
|
|
23886
|
+
letter.zurl = urlCheck;
|
|
23887
|
+
letter.ztar = targetCheck;
|
|
23888
|
+
letter.cur();
|
|
23889
|
+
letter.on("click", function (e) {
|
|
23890
|
+
var letter = e.currentTarget;
|
|
23891
|
+
rollOff(e);
|
|
23892
|
+
if (!letter.ztar) letter.ztar = "_self";
|
|
23893
|
+
zgo(letter.zurl, letter.ztar);
|
|
23894
|
+
});
|
|
23895
|
+
}
|
|
23896
|
+
if (familyCheck) letter.font = familyCheck;
|
|
23897
|
+
if (sizeCheck) letter.size = sizeCheck;
|
|
23898
|
+
|
|
23899
|
+
|
|
23900
|
+
if (brCheck) {
|
|
23901
|
+
lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
|
|
23902
|
+
linePositionsY.push(lineY);
|
|
23903
|
+
lineHeights.push(zot(lineHeight)?lineH:lineHeight);
|
|
23904
|
+
lineWidths.push(lineW);
|
|
23905
|
+
maxW = Math.max(maxW, lineW);
|
|
23906
|
+
}
|
|
23907
|
+
|
|
23908
|
+
if (brCheck) {
|
|
23909
|
+
if (brCheck > 1) {
|
|
23910
|
+
zim.loop(brCheck-1, function () {
|
|
23911
|
+
that.lines.push([]);
|
|
23912
|
+
lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
|
|
23913
|
+
linePositionsY.push(lineY);
|
|
23914
|
+
lineHeights.push(zot(lineHeight)?lineH:lineHeight);
|
|
23915
|
+
lineWidths.push(0);
|
|
23916
|
+
lineNum++;
|
|
23917
|
+
});
|
|
23918
|
+
}
|
|
23919
|
+
lineH = 0;
|
|
23920
|
+
lineW = 0;
|
|
23921
|
+
that.lines.push([]);
|
|
23922
|
+
lineNum++;
|
|
23490
23923
|
}
|
|
23491
|
-
|
|
23492
|
-
lineW
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23498
|
-
|
|
23924
|
+
|
|
23925
|
+
lineW += letter.width + s;
|
|
23926
|
+
lineH = Math.max(lineH, letter.height);
|
|
23927
|
+
|
|
23928
|
+
if (i==that.numLetters-1) {
|
|
23929
|
+
lineWidths.push(lineW);
|
|
23930
|
+
lineHeights.push(lineH);
|
|
23931
|
+
maxW = Math.max(maxW, lineW);
|
|
23932
|
+
}
|
|
23933
|
+
|
|
23934
|
+
that.lines[lineNum].push(letter);
|
|
23935
|
+
|
|
23936
|
+
if (uCheck) letter.underline = new zim.Line(letter.width+s+1,1,letter.color).center(letter,that).mov(0,letter.height/2);
|
|
23937
|
+
|
|
23938
|
+
} // end checks
|
|
23499
23939
|
|
|
23500
|
-
|
|
23501
|
-
lineWidths.push(lineW);
|
|
23502
|
-
lineHeights.push(lineH);
|
|
23503
|
-
maxW = Math.max(maxW, lineW);
|
|
23504
|
-
}
|
|
23940
|
+
|
|
23505
23941
|
|
|
23506
|
-
that.lines[lineNum].push(letter);
|
|
23507
23942
|
|
|
23508
|
-
|
|
23943
|
+
// LOOP THROUGH LINES AND APPLY POSITIONS
|
|
23944
|
+
var count = 0;
|
|
23945
|
+
for (var j=0; j<that.lines.length; j++) {
|
|
23946
|
+
var ll = that.lines[j];
|
|
23947
|
+
lineW = lineWidths[j];
|
|
23948
|
+
lineH = lineHeights[j];
|
|
23949
|
+
lineY = linePositionsY[j];
|
|
23950
|
+
|
|
23951
|
+
var startX, startY;
|
|
23952
|
+
if (lineAlign=="left") startX = 0;
|
|
23953
|
+
else if (lineAlign=="right") startX = maxW-lineW;
|
|
23954
|
+
else startX = (maxW-lineW)/2;
|
|
23955
|
+
startY = lineY;
|
|
23956
|
+
|
|
23957
|
+
for (i=0; i<ll.length; i++) {
|
|
23958
|
+
count++;
|
|
23959
|
+
if (cache) letter.cache();
|
|
23960
|
+
letter = ll[i];
|
|
23961
|
+
letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
|
|
23962
|
+
letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
|
|
23509
23963
|
|
|
23510
|
-
|
|
23511
|
-
|
|
23964
|
+
var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
|
|
23965
|
+
if (lineValign=="center" || lineValign=="middle") {
|
|
23966
|
+
sY += (lineHeights[j]-letter.height)/2;
|
|
23967
|
+
} else if (lineValign=="bottom") {
|
|
23968
|
+
sY += lineHeights[j]-letter.height;
|
|
23969
|
+
}
|
|
23970
|
+
s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
|
|
23971
|
+
if (align=="left") {
|
|
23972
|
+
letter.loc(startX, sY, that);
|
|
23973
|
+
startX = letter.x+letter.width+s;
|
|
23974
|
+
} else if (align=="right") {
|
|
23975
|
+
letter.loc(startX+letter.width, sY, that);
|
|
23976
|
+
startX = letter.x+s;
|
|
23977
|
+
} else {
|
|
23978
|
+
letter.loc(startX+letter.width/2, sY, that);
|
|
23979
|
+
startX = letter.x+letter.width/2+s;
|
|
23980
|
+
}
|
|
23981
|
+
|
|
23982
|
+
} // end lines letters
|
|
23983
|
+
} // end lines
|
|
23984
|
+
|
|
23985
|
+
if (!that.getBounds()) that.setBounds(0,0,0,0);
|
|
23986
|
+
that.regX = that.getBounds().x;
|
|
23987
|
+
that.regY = that.getBounds().y;
|
|
23988
|
+
|
|
23989
|
+
}
|
|
23990
|
+
|
|
23991
|
+
make();
|
|
23992
|
+
|
|
23512
23993
|
// ROLL FUNCTIONS
|
|
23513
|
-
|
|
23994
|
+
|
|
23514
23995
|
function rollOn(e) {
|
|
23515
23996
|
var letter = e.currentTarget;
|
|
23516
23997
|
var rolls = that.rolls[letter.rollIndex]
|
|
@@ -23527,58 +24008,22 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
23527
24008
|
});
|
|
23528
24009
|
if (letter.stage) letter.stage.update();
|
|
23529
24010
|
}
|
|
23530
|
-
|
|
23531
|
-
|
|
23532
|
-
// LOOP THROUGH LINES AND APPLY POSITIONS
|
|
23533
|
-
var count = 0;
|
|
23534
|
-
for (var j=0; j<that.lines.length; j++) {
|
|
23535
|
-
var ll = that.lines[j];
|
|
23536
|
-
lineW = lineWidths[j];
|
|
23537
|
-
lineH = lineHeights[j];
|
|
23538
|
-
lineY = linePositionsY[j];
|
|
23539
|
-
|
|
23540
|
-
var startX, startY;
|
|
23541
|
-
if (lineAlign=="left") startX = 0;
|
|
23542
|
-
else if (lineAlign=="right") startX = maxW-lineW;
|
|
23543
|
-
else startX = (maxW-lineW)/2;
|
|
23544
|
-
startY = lineY;
|
|
23545
|
-
|
|
23546
|
-
for (i=0; i<ll.length; i++) {
|
|
23547
|
-
count++;
|
|
23548
|
-
if (cache) letter.cache();
|
|
23549
|
-
letter = ll[i];
|
|
23550
|
-
letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
|
|
23551
|
-
letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
|
|
23552
|
-
|
|
23553
|
-
var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
|
|
23554
|
-
if (lineValign=="center" || lineValign=="middle") {
|
|
23555
|
-
sY += (lineHeights[j]-letter.height)/2;
|
|
23556
|
-
} else if (lineValign=="bottom") {
|
|
23557
|
-
sY += lineHeights[j]-letter.height;
|
|
23558
|
-
}
|
|
23559
|
-
s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
|
|
23560
|
-
if (align=="left") {
|
|
23561
|
-
letter.loc(startX, sY, this);
|
|
23562
|
-
startX = letter.x+letter.width+s;
|
|
23563
|
-
} else if (align=="right") {
|
|
23564
|
-
letter.loc(startX+letter.width, sY, this);
|
|
23565
|
-
startX = letter.x+s;
|
|
23566
|
-
} else {
|
|
23567
|
-
letter.loc(startX+letter.width/2, sY, this);
|
|
23568
|
-
startX = letter.x+letter.width/2+s;
|
|
23569
|
-
}
|
|
23570
|
-
|
|
23571
|
-
} // end lines letters
|
|
23572
|
-
} // end lines
|
|
23573
24011
|
|
|
23574
|
-
if (!this.getBounds()) this.setBounds(0,0,0,0);
|
|
23575
|
-
this.regX = this.getBounds().x;
|
|
23576
|
-
this.regY = this.getBounds().y;
|
|
23577
24012
|
|
|
23578
24013
|
this.setProps = function(props) {
|
|
23579
24014
|
zim.setProps(this.labels, props);
|
|
23580
24015
|
return this;
|
|
23581
24016
|
}
|
|
24017
|
+
|
|
24018
|
+
Object.defineProperty(this, 'text', {
|
|
24019
|
+
get: function () {
|
|
24020
|
+
return this._text;
|
|
24021
|
+
},
|
|
24022
|
+
set: function (value) {
|
|
24023
|
+
label = value;
|
|
24024
|
+
make();
|
|
24025
|
+
}
|
|
24026
|
+
});
|
|
23582
24027
|
|
|
23583
24028
|
Object.defineProperty(this, 'color', {
|
|
23584
24029
|
get: function () {
|
|
@@ -23738,7 +24183,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
|
|
|
23738
24183
|
|
|
23739
24184
|
PROPERTIES
|
|
23740
24185
|
type - the name of the class as a String
|
|
23741
|
-
text - get
|
|
24186
|
+
text - get or set the text
|
|
23742
24187
|
labels - an array of ZIM Label objects for the letters
|
|
23743
24188
|
numWords - how many words in labels (same as numChildren)
|
|
23744
24189
|
|
|
@@ -23778,28 +24223,42 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
23778
24223
|
if (zot(spacingH)) spacingH = DS.spacingH != null ? DS.spacingH : size/2;
|
|
23779
24224
|
if (zot(spacingV)) spacingV = DS.spacingV != null ? DS.spacingV : size/2;
|
|
23780
24225
|
|
|
23781
|
-
|
|
23782
|
-
if (label.type == "Label") sentence = label.text;
|
|
23783
|
-
else sentence = label;
|
|
24226
|
+
var that = this;
|
|
23784
24227
|
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
|
|
23797
|
-
|
|
23798
|
-
|
|
23799
|
-
|
|
24228
|
+
function make(label) {
|
|
24229
|
+
var sentence;
|
|
24230
|
+
if (label.type == "Label") sentence = label.text;
|
|
24231
|
+
else sentence = label;
|
|
24232
|
+
that._text = sentence;
|
|
24233
|
+
var words = sentence.split(' ').filter(Boolean);
|
|
24234
|
+
var labels = that.labels = [];
|
|
24235
|
+
zim.loop(words, function(word) {
|
|
24236
|
+
var lab = label.type=="Label"?label.clone():new zim.Label();
|
|
24237
|
+
lab.text = word;
|
|
24238
|
+
lab.size = zik(size);
|
|
24239
|
+
lab.font = zik(font);
|
|
24240
|
+
lab.color = zik(color);
|
|
24241
|
+
if (!zot(backgroundColor)) lab.backgroundColor = zik(backgroundColor);
|
|
24242
|
+
lab.reg(zik(itemRegX), zik(itemRegY));
|
|
24243
|
+
if (itemCache) lab.cache();
|
|
24244
|
+
labels.push(lab);
|
|
24245
|
+
});
|
|
24246
|
+
}
|
|
24247
|
+
make(label);
|
|
23800
24248
|
|
|
23801
|
-
this.zimWrapper_constructor(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);
|
|
24249
|
+
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);
|
|
23802
24250
|
|
|
24251
|
+
Object.defineProperty(this, 'text', {
|
|
24252
|
+
get: function () {
|
|
24253
|
+
return this._text;
|
|
24254
|
+
},
|
|
24255
|
+
set: function (label) {
|
|
24256
|
+
that.remove();
|
|
24257
|
+
make(label);
|
|
24258
|
+
that.add(that.labels);
|
|
24259
|
+
}
|
|
24260
|
+
});
|
|
24261
|
+
|
|
23803
24262
|
if (style!==false) zim.styleTransforms(this, DS);
|
|
23804
24263
|
this.clone = function () {
|
|
23805
24264
|
return that.cloneProps(new zim.LabelWords(label, width, size, font, color, backgroundColor, itemCache, itemRegX, itemRegY, spacingH, spacingV, wrapperType, align, valign, alignInner, valignInner, flip, reverse, bottomFull, colSize, rowSize, height, minSpreadNum, minStretchNum, percentVoidH, offsetVoidH, percentVoidV, offsetVoidV, minStretchFirst, style, this.group, inherit));
|
|
@@ -24757,13 +25216,13 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
24757
25216
|
if (that.rolled) return;
|
|
24758
25217
|
});
|
|
24759
25218
|
|
|
24760
|
-
this.on("pressup", function () {
|
|
25219
|
+
this.on("pressup", function (e) {
|
|
24761
25220
|
that.pressed = onCheck = pressCheck = false;
|
|
24762
|
-
|
|
25221
|
+
|
|
24763
25222
|
if (reallyOn) buttonOn(); // will recall the roll ZIM01
|
|
24764
25223
|
else if (that.rollPersist) removeRoll();
|
|
24765
25224
|
|
|
24766
|
-
if (
|
|
25225
|
+
if (e.nativeEvent && (e.nativeEvent.type == "touchend" || e.nativeEvent == "touchcancel")) { // touch screen
|
|
24767
25226
|
buttonOff();
|
|
24768
25227
|
}
|
|
24769
25228
|
});
|
|
@@ -27190,6 +27649,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
27190
27649
|
if (replace) that.contentContainer.removeAllChildren();
|
|
27191
27650
|
if (center) obj.center(that.contentContainer, index);
|
|
27192
27651
|
else obj.addTo(that.contentContainer, index);
|
|
27652
|
+
addHTML(that.contentContainer);
|
|
27193
27653
|
return that;
|
|
27194
27654
|
}
|
|
27195
27655
|
|
|
@@ -27334,7 +27794,6 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
27334
27794
|
});
|
|
27335
27795
|
}
|
|
27336
27796
|
|
|
27337
|
-
|
|
27338
27797
|
this.on("removed", hide2);
|
|
27339
27798
|
function hide2() {
|
|
27340
27799
|
var ch,i;
|
|
@@ -27443,6 +27902,8 @@ NOTE: to add ZIM Swipe() to objects in window set the overrideNoSwipe parameter
|
|
|
27443
27902
|
NOTE: if animating the window off screen then either turn optimize:false
|
|
27444
27903
|
or use window.update() in the "animation" event with the animate({events:true})
|
|
27445
27904
|
|
|
27905
|
+
NOTE: if window content has items set to visible false then set optimize false to avoid conflict
|
|
27906
|
+
|
|
27446
27907
|
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
27447
27908
|
|
|
27448
27909
|
EXAMPLE
|
|
@@ -27563,6 +28024,7 @@ optimize - (default true) set to false to not turn DisplayObjects visible false
|
|
|
27563
28024
|
as the Window is scrolled, any objects within the content and any objects within one level of those objects
|
|
27564
28025
|
are set to visible false if their bounds are not hitting the the window bounds + 300 - thanks Ami Hanya for the suggestion
|
|
27565
28026
|
also see optimize property
|
|
28027
|
+
if window content has items set to visible false then set optimize false to avoid conflict
|
|
27566
28028
|
resizeBoundary - (default null) add a ZIM Boundary() object for the resize handle - relative to the resize handle start position
|
|
27567
28029
|
new Boundary(-100, 0, 200, 0) - would allow the resize handle to move to the left or right 100 pixels but not up or down
|
|
27568
28030
|
new Boundary(0, -100, 0, 200) - would allow the resize handle to move to up or down 100 pixels but not left or right
|
|
@@ -27617,7 +28079,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
|
|
|
27617
28079
|
|
|
27618
28080
|
PROPERTIES
|
|
27619
28081
|
type - holds the class name as a String
|
|
27620
|
-
backing -
|
|
28082
|
+
backing - ZIM Shape used for backing of Window
|
|
27621
28083
|
backgroundColor - the color of the backing
|
|
27622
28084
|
borderColor - the color of the border
|
|
27623
28085
|
borderWidth - the width of the border
|
|
@@ -27632,6 +28094,7 @@ content - gives access to the content provided as a parameter to the Window()
|
|
|
27632
28094
|
buttons - an array of the Button objects if provided
|
|
27633
28095
|
config - the original content config object {}
|
|
27634
28096
|
optimize - see optimize parameter - set to true (default) or false to optimize scrolling of Window
|
|
28097
|
+
if window content has items set to visible false then set optimize false to avoid conflict
|
|
27635
28098
|
enabled - get or set whether the Window is enabled
|
|
27636
28099
|
scrollEnabled - get or set whether the Window can be scrolled
|
|
27637
28100
|
scrollBar - data object that holds the following properties (with defaults):
|
|
@@ -27764,6 +28227,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
27764
28227
|
var backing = this.backing = new zim.Shape({style:false});
|
|
27765
28228
|
this.addChild(backing);
|
|
27766
28229
|
|
|
28230
|
+
var htmlList = new zim.Dictionary(true);
|
|
28231
|
+
|
|
27767
28232
|
var mask = new createjs.Shape();
|
|
27768
28233
|
mask.type = "WindowBacking";
|
|
27769
28234
|
var mg = mask.graphics;
|
|
@@ -28163,7 +28628,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
28163
28628
|
titleBarRect.sha(null);
|
|
28164
28629
|
if (resizeHandle) that.resizeHandle.visible = true;
|
|
28165
28630
|
that.setBounds(ob.x, ob.y, ob.width, ob.height);
|
|
28166
|
-
|
|
28631
|
+
show2();
|
|
28632
|
+
that.dispatchEvent("expand");
|
|
28167
28633
|
} else {
|
|
28168
28634
|
collapseIcon.rot(180);
|
|
28169
28635
|
that.backing.visible = false;
|
|
@@ -28176,6 +28642,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
28176
28642
|
titleBarRect.sha(shadowColor, 5,5, shadowBlur);
|
|
28177
28643
|
if (resizeHandle) that.resizeHandle.visible = false;
|
|
28178
28644
|
that.setBounds(ob.x, ob.y, ob.width, titleBar.height);
|
|
28645
|
+
hide2();
|
|
28179
28646
|
that.dispatchEvent("collapse");
|
|
28180
28647
|
}
|
|
28181
28648
|
if (that.stage) that.stage.update();
|
|
@@ -28202,6 +28669,34 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
28202
28669
|
that.collapse(true);
|
|
28203
28670
|
}
|
|
28204
28671
|
});
|
|
28672
|
+
|
|
28673
|
+
}
|
|
28674
|
+
}
|
|
28675
|
+
this.on("removed", hide2);
|
|
28676
|
+
function hide2() {
|
|
28677
|
+
var ch,i;
|
|
28678
|
+
var tar = that.content||that.contentContainer||that;
|
|
28679
|
+
if (tar.type != "Container") tar = that.contentContainer||that;
|
|
28680
|
+
for (i=0; i<tar.numChildren; i++) { // record depths first
|
|
28681
|
+
ch = tar.getChildAt(i);
|
|
28682
|
+
if (ch.type == "TextArea" || ch.type == "Loader" || ch.type == "Tag") {
|
|
28683
|
+
var obj = {obj:ch, depth:tar.getChildIndex(ch)};
|
|
28684
|
+
htmlList.add(ch, obj);
|
|
28685
|
+
}
|
|
28686
|
+
}
|
|
28687
|
+
for (i=tar.numChildren-1; i>=0; i--) { // remove textareas and loaders second
|
|
28688
|
+
ch = tar.getChildAt(i);
|
|
28689
|
+
if (ch.type == "TextArea" || ch.type == "Loader" || ch.type == "Tag") {
|
|
28690
|
+
tar.removeChild(ch);
|
|
28691
|
+
}
|
|
28692
|
+
}
|
|
28693
|
+
}
|
|
28694
|
+
this.on("added", show2);
|
|
28695
|
+
function show2() {
|
|
28696
|
+
var tar = that.content||that.contentContainer||that;
|
|
28697
|
+
if (tar.type != "Container") tar = that.contentContainer||that;
|
|
28698
|
+
for (var i=0; i<htmlList.length; i++) {
|
|
28699
|
+
tar.addChildAt(htmlList.values[i].obj, htmlList.values[i].depth);
|
|
28205
28700
|
}
|
|
28206
28701
|
}
|
|
28207
28702
|
|
|
@@ -28270,7 +28765,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
28270
28765
|
var duo; if (duo = zob(that.add, arguments, sig, that)) return duo;
|
|
28271
28766
|
|
|
28272
28767
|
var c = obj;
|
|
28273
|
-
if (!c.getBounds()) {zogy("Window.add() - please add content with bounds set"); return;}
|
|
28768
|
+
if (!c.getBounds()) {zogy("Window.add() - please add content with bounds set"); return;}
|
|
28274
28769
|
makeDamp(c);
|
|
28275
28770
|
if (zot(index)) index = content.numChildren;
|
|
28276
28771
|
if (replace) {
|
|
@@ -28297,7 +28792,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
28297
28792
|
});
|
|
28298
28793
|
}
|
|
28299
28794
|
if (c.x == 0) c.x = paddingH;
|
|
28300
|
-
if (c.y == 0) c.y = paddingV;
|
|
28795
|
+
if (c.y == 0) c.y = paddingV;
|
|
28301
28796
|
that.update();
|
|
28302
28797
|
return that;
|
|
28303
28798
|
};
|
|
@@ -30737,7 +31232,7 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
|
|
|
30737
31232
|
}
|
|
30738
31233
|
align = handleDIR(align);
|
|
30739
31234
|
|
|
30740
|
-
this.zimWindow_constructor(width, height, null, backgroundColor, borderColor, borderWidth, padding, corner, false, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, false, null, null, false, true, shadowColor, shadowBlur, paddingH, paddingV, true, null, null, null, null, null, false, null, null, null, null, null, null, null, null, null, null, null, null, style, group, zim.copy(DS));
|
|
31235
|
+
this.zimWindow_constructor(width, height, null, backgroundColor, borderColor, borderWidth, padding, corner, false, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, false, null, null, false, true, shadowColor, shadowBlur, paddingH, paddingV, true, null, null, null, null, null, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, style, group, zim.copy(DS));
|
|
30741
31236
|
this.type = "TextInput";
|
|
30742
31237
|
var that = this;
|
|
30743
31238
|
|
|
@@ -30813,7 +31308,16 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
|
|
|
30813
31308
|
label.onDblclick(e);
|
|
30814
31309
|
e.stopImmediatePropagation();
|
|
30815
31310
|
});
|
|
30816
|
-
|
|
31311
|
+
|
|
31312
|
+
|
|
31313
|
+
function vvp() {
|
|
31314
|
+
if (M && !zot(lastHeight) && WW.visualViewport.height > lastHeight) {
|
|
31315
|
+
that.tiBlur();
|
|
31316
|
+
WW.visualViewport.removeEventListener('resize', vvp);
|
|
31317
|
+
}
|
|
31318
|
+
lastHeight = WW.visualViewport.height;
|
|
31319
|
+
}
|
|
31320
|
+
var lastHeight;
|
|
30817
31321
|
that.label.on("focus", function () {
|
|
30818
31322
|
if (WW.M && keyboardShift) {
|
|
30819
31323
|
if (that.re) that.stage.frame.off("resize", that.re);
|
|
@@ -30823,6 +31327,10 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
|
|
|
30823
31327
|
that.stage.update();
|
|
30824
31328
|
}
|
|
30825
31329
|
});
|
|
31330
|
+
if (WW.visualViewport) {
|
|
31331
|
+
WW.visualViewport.removeEventListener('resize', vvp);
|
|
31332
|
+
WW.visualViewport.addEventListener('resize', vvp);
|
|
31333
|
+
}
|
|
30826
31334
|
var h = that.label.localToGlobal(0,0).y;
|
|
30827
31335
|
if (that.stage && h>that.stage.height/4) {
|
|
30828
31336
|
that.stage.y = that.stage.scaleY*(that.stage.height/4-h);
|
|
@@ -30836,10 +31344,11 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
|
|
|
30836
31344
|
that.dispatchEvent("focus");
|
|
30837
31345
|
});
|
|
30838
31346
|
|
|
30839
|
-
that.
|
|
31347
|
+
that.tiBlur = function() {
|
|
30840
31348
|
if (WW.M && keyboardShift) {
|
|
30841
31349
|
if (that.stage) {
|
|
30842
31350
|
if (that.re) that.stage.frame.off("resize", that.re);
|
|
31351
|
+
that.label.hiddenInput.blur();
|
|
30843
31352
|
that.stage.y = sYO;
|
|
30844
31353
|
that.stage.update();
|
|
30845
31354
|
}
|
|
@@ -30849,7 +31358,8 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
|
|
|
30849
31358
|
if (that.stage) that.stage.update();
|
|
30850
31359
|
}
|
|
30851
31360
|
that.dispatchEvent("blur");
|
|
30852
|
-
}
|
|
31361
|
+
}
|
|
31362
|
+
that.label.on("blur", that.tiBlur);
|
|
30853
31363
|
|
|
30854
31364
|
that.label.on("input", function (e) {
|
|
30855
31365
|
doPlaceholder();
|
|
@@ -35879,6 +36389,993 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
35879
36389
|
zim.extend(zim.Selector, zim.Container, ["clone","dispose"], "zimContainer", false);
|
|
35880
36390
|
//-62.5
|
|
35881
36391
|
|
|
36392
|
+
/*--
|
|
36393
|
+
zim.Slicer = function(obj, objScale, slices, types, titleBar, remember, upload, selection, multiple, proportion, resize, style, group, inherit);
|
|
36394
|
+
|
|
36395
|
+
Slicer
|
|
36396
|
+
zim class - extends a zim.Window which extends a zim.Container which extends a createjs.Container
|
|
36397
|
+
|
|
36398
|
+
DESCRIPTION
|
|
36399
|
+
A Slicer provides a tool to break a DisplayObject such as a Pic() into horizontal and vertical regions.
|
|
36400
|
+
|
|
36401
|
+
See: https://zimjs.com/slicer which shows how a Slicer can be used to create data for a ZIM SlicedBitmap
|
|
36402
|
+
|
|
36403
|
+
The component has a horizontal track at the top which can be pressed to make editable vertical lines
|
|
36404
|
+
and a vertical track at the left that can be pressed to make editable horizontal lines.
|
|
36405
|
+
The sections can be selected or multiple selected and properties applied.
|
|
36406
|
+
The lines can be dragged and deleted and their percentages retrieved with the slices property.
|
|
36407
|
+
A new picture can be uploaded with the pic icon at the bottom right.
|
|
36408
|
+
The interface can be hidden, the window resized at bottom right and collapsed at top right.
|
|
36409
|
+
|
|
36410
|
+
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
36411
|
+
|
|
36412
|
+
EXAMPLE
|
|
36413
|
+
// slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
|
|
36414
|
+
const pic = new Pic("car.png"); // preload this in Frame() or loadAssets()
|
|
36415
|
+
const slicer = new Slicer({
|
|
36416
|
+
obj:pic.clone(), // slicer will adjust obj so clone the pic so can use it unaffected later
|
|
36417
|
+
scale:.5,
|
|
36418
|
+
upload:false
|
|
36419
|
+
})
|
|
36420
|
+
.pos(30,50)
|
|
36421
|
+
.change(()=>{preview.exchange = slicer.exchange;); // this will update the picture below
|
|
36422
|
+
|
|
36423
|
+
slicer.on("loaded", ()=>{
|
|
36424
|
+
if (preview) preview.dispose();
|
|
36425
|
+
preview = new zim.SlicedBitmap(1600, 600, slicer.obj.clone(), slicer.slices, slicer.types, 2, .5)
|
|
36426
|
+
.pos(0,100,CENTER,BOTTOM)
|
|
36427
|
+
.transform({minScaleX:.05, minScaleY:.05});
|
|
36428
|
+
});
|
|
36429
|
+
|
|
36430
|
+
// this will provide slice type options
|
|
36431
|
+
new SlicerTypes(slicer).pos(30,120,RIGHT,TOP);
|
|
36432
|
+
|
|
36433
|
+
// slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
|
|
36434
|
+
let preview = new SlicedBitmap(1600, pic.height, pic)
|
|
36435
|
+
.center()
|
|
36436
|
+
.transform({minScaleX:.05, minScaleY:.05});
|
|
36437
|
+
END EXAMPLE
|
|
36438
|
+
|
|
36439
|
+
PARAMETERS
|
|
36440
|
+
** supports DUO - parameters or single object with properties below
|
|
36441
|
+
** supports OCT - parameter defaults can be set with STYLE control (like CSS)
|
|
36442
|
+
obj - (default new Tile()) a DisplayObject to slice
|
|
36443
|
+
objScale - (default 1) set the scale of the object in the Slicer
|
|
36444
|
+
slices - (default null) an array of horizontal and vertical arrays holding slice percentage
|
|
36445
|
+
[[.25,.75], [.1,.4,.5,.9]]
|
|
36446
|
+
three horizontal regions made from two vertical lines placed at 1/4 and 3/4 the width
|
|
36447
|
+
five vertical regions made from four horizontal lines with 1/10 the picture at left, middle and right
|
|
36448
|
+
types - (default null) an array of horizontal and vertical arrays holding slice types
|
|
36449
|
+
0 - fix - keeps the original width and height of the region. Usually, good for corners.
|
|
36450
|
+
1 - stretch - stretch the region to fill space as an object is stretched
|
|
36451
|
+
2 - tile - tile the region at original scale - currently, will match the first side and sometimes the second side
|
|
36452
|
+
titleBar - (default "Slicer") the title of the window as a String or ZIM Label
|
|
36453
|
+
remember - (default true) use localStorage(zimSlicer) to store the last settings of the lines - see clear() method
|
|
36454
|
+
upload - (default true) provide a pic button at bottom right to upload a pic
|
|
36455
|
+
selection - (default true) let the sliced regions be selected
|
|
36456
|
+
multiple - (default true) if selection then let shift or the multiple button be used to select multiple regions - set to false for single selection
|
|
36457
|
+
proportion - (default true) when resized (or on upload) keep the percentages - set to false to keep lines at pixel setting
|
|
36458
|
+
resize - (default true) roll over bottom right corner to resize - set to false to not provide resizing - also can use resizeVisible as STYLE to keep visible
|
|
36459
|
+
style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
|
|
36460
|
+
group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
|
|
36461
|
+
inherit - (default null) used internally but can receive an {} of styles directly
|
|
36462
|
+
|
|
36463
|
+
METHODS
|
|
36464
|
+
hasProp(property as String) - returns true if property exists on object else returns false
|
|
36465
|
+
setObject(newObj, scale) - change the object in the slicer and set the scale of the object
|
|
36466
|
+
updateLines(slices) - remake lines with slices data - see slices parameter
|
|
36467
|
+
setSlicerTypes(slicerTypes) - add a ZIM SlicerTypes object to control slicer types
|
|
36468
|
+
clearSelection() - clears all highlights - not the line selections but the region selections
|
|
36469
|
+
clear() - clears remembered data stored in localStorage(zimSlicer)
|
|
36470
|
+
clone() - makes a copy with properties such as x, y, etc. also copied
|
|
36471
|
+
dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
|
|
36472
|
+
|
|
36473
|
+
ALSO: All Window methods such as resize()
|
|
36474
|
+
|
|
36475
|
+
ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
|
|
36476
|
+
drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
|
|
36477
|
+
addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
|
|
36478
|
+
ALSO: see the CreateJS Easel Docs for Container methods, such as:
|
|
36479
|
+
on(), off(), getBounds(), setBounds(), cache(), uncache(), updateCache(), dispatchEvent(),
|
|
36480
|
+
addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChildren(), etc.
|
|
36481
|
+
|
|
36482
|
+
PROPERTIES
|
|
36483
|
+
type - holds the class name as a String
|
|
36484
|
+
obj - get a reference to the object being sliced - see setObject() to set the object
|
|
36485
|
+
slices - get or set the slices array - see the slices parameter
|
|
36486
|
+
types - get or set the types array - see the types parameter
|
|
36487
|
+
exchange - get or set [slices, types] as a single array - used to set a SlicedBitmap
|
|
36488
|
+
selectedIndexH - get the selected index of the current horizontal slice
|
|
36489
|
+
selectedIndexV - get the selected index of the current vertical slice
|
|
36490
|
+
currentLineH - get the selected horizontal slice line (a vertical line)
|
|
36491
|
+
currentLineV - get the selected vertical slice line (a horizontal line)
|
|
36492
|
+
selection - get an array of currently highlighted regions - also see highLightContainer
|
|
36493
|
+
box - a reference to the box Rectangle that directly surrounds the obj
|
|
36494
|
+
trackH - a reference to the top track Rectangle
|
|
36495
|
+
trackV - a reference to the left track Rectangle
|
|
36496
|
+
deleteH - a reference to the delete Button at top right
|
|
36497
|
+
deleteV - a reference to the delete Button at bottom left
|
|
36498
|
+
hide - a reference to the hide Button at top left
|
|
36499
|
+
loader - a reference to the Loader button at bottom right
|
|
36500
|
+
linesHContainer - a reference to the Container of horizontal slice lines (vertical lines)
|
|
36501
|
+
linesVContainer - a reference to the Container of vertical slice lines (vertical lines)
|
|
36502
|
+
highlightContainer - a reference to the left track Rectangle
|
|
36503
|
+
|
|
36504
|
+
ALSO: see ZIM Window for properties - like titleBar, titleBarLabel, resizeHandle, etc.
|
|
36505
|
+
|
|
36506
|
+
ALSO: see ZIM Container for properties such as:
|
|
36507
|
+
width, height, widthOnly, heightOnly, draggable, level, depth, group
|
|
36508
|
+
blendMode, hue, saturation, brightness, contrast, etc.
|
|
36509
|
+
|
|
36510
|
+
ALSO: see the CreateJS Easel Docs for Container properties, such as:
|
|
36511
|
+
x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
|
|
36512
|
+
alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, etc.
|
|
36513
|
+
|
|
36514
|
+
EVENTS
|
|
36515
|
+
change - dispatched when a line is added, deleted or moved
|
|
36516
|
+
selection - dispatched when a region is selected or deselected
|
|
36517
|
+
delete - dispatched when a line is deleted
|
|
36518
|
+
loaded - dispatched when an image is loaded
|
|
36519
|
+
|
|
36520
|
+
ALSO: all Window events including "collapse", "expand", "resize"
|
|
36521
|
+
|
|
36522
|
+
ALSO: see the CreateJS Easel Docs for Container events such as:
|
|
36523
|
+
added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
|
|
36524
|
+
--*///+62.7
|
|
36525
|
+
zim.Slicer = function(obj, objScale, slices, types, titleBar, remember, upload, selection, multiple, proportion, resize, style, group, inherit) {
|
|
36526
|
+
var sig = "obj, objScale, slices, types, titleBar, remember, upload, selection, multiple, proportion, resize, style, group, inherit";
|
|
36527
|
+
var duo; if (duo = zob(zim.Slicer, arguments, sig, this)) return duo;
|
|
36528
|
+
z_d("62.7");
|
|
36529
|
+
this.group = group;
|
|
36530
|
+
var DS = style===false?{}:zim.getStyle("Slicer", this.group, inherit);
|
|
36531
|
+
|
|
36532
|
+
if (zot(obj)) obj = DS.obj!=null?DS.obj:new zim.Tile();
|
|
36533
|
+
if (zot(objScale)) objScale = DS.objScale!=null?DS.objScale:1;
|
|
36534
|
+
var scale = objScale;
|
|
36535
|
+
var empty = slices;
|
|
36536
|
+
if (zot(slices)) slices = DS.slices!=null?DS.slices:[[0,1],[0,1]];
|
|
36537
|
+
var defaults = [[1],[1]];
|
|
36538
|
+
zim.loop(slices,function(s,i) {
|
|
36539
|
+
zim.loop(s,function() {
|
|
36540
|
+
defaults[i].push(1);
|
|
36541
|
+
});
|
|
36542
|
+
});
|
|
36543
|
+
slices = zim.copy(slices);
|
|
36544
|
+
if (zot(types)) types = DS.slices!=null?DS.slices:defaults;
|
|
36545
|
+
types = zim.copy(types);
|
|
36546
|
+
if (zot(titleBar)) titleBar = DS.titleBar!=null?DS.titleBar:"Slicer";
|
|
36547
|
+
if (zot(remember)) remember = DS.remember!=null?DS.remember:true;
|
|
36548
|
+
if (zot(upload)) upload = DS.upload!=null?DS.upload:true;
|
|
36549
|
+
if (zot(selection)) selection = DS.selection!=null?DS.selection:true;
|
|
36550
|
+
if (zot(multiple)) multiple = DS.multiple!=null?DS.multiple:true;
|
|
36551
|
+
if (zot(proportion)) proportion = DS.proportion!=null?DS.proportion:true;
|
|
36552
|
+
if (zot(resize)) resize = DS.resize!=null?DS.resize:true;
|
|
36553
|
+
|
|
36554
|
+
// WINDOW
|
|
36555
|
+
var wW = obj.width*scale+60;
|
|
36556
|
+
var wH = obj.height*scale+60+(titleBar?30:0);
|
|
36557
|
+
var oWW = wW;
|
|
36558
|
+
var oWH = wH;
|
|
36559
|
+
this.zimWindow_constructor(wW, wH,
|
|
36560
|
+
null, null, null, null, null, null, false, null, null, null, null, null, false, false, false, null, null, null, null, null, null, null, null, null, null,
|
|
36561
|
+
titleBar, dark, moon, null, true, null, null, null, null, null, null, null, resize, true
|
|
36562
|
+
);
|
|
36563
|
+
this.type = "Slicer";
|
|
36564
|
+
var that = this;
|
|
36565
|
+
if (that.collapseIcon) that.collapseIcon.mov(2);
|
|
36566
|
+
if (that.titleBar) {
|
|
36567
|
+
that.titleBarLabel.mov(26,1);
|
|
36568
|
+
zdf.makeIcon(tin, clear, [tin, tin, tin, tin, tin]).scaleTo(that.titleBar,87,87).loc(5,2,that.titleBar);
|
|
36569
|
+
}
|
|
36570
|
+
|
|
36571
|
+
that.obj = obj;
|
|
36572
|
+
that.data = slices;
|
|
36573
|
+
that.dataTypes = types;
|
|
36574
|
+
// CONTAINERS
|
|
36575
|
+
var hh = that.height-(titleBar?30:0);
|
|
36576
|
+
var content = new zim.Container(that.width, hh);
|
|
36577
|
+
var sc = that.splitterContent = new zim.Container(that.width-60, hh-60).pos(30,30,LEFT,TOP,content);
|
|
36578
|
+
|
|
36579
|
+
// OBJECT
|
|
36580
|
+
var w = obj.width*scale;
|
|
36581
|
+
var h = obj.height*scale;
|
|
36582
|
+
obj.sca(scale).addTo(sc);
|
|
36583
|
+
|
|
36584
|
+
|
|
36585
|
+
// CONTENT
|
|
36586
|
+
var box = that.box = new zim.Rectangle({width:w, height:h, borderColor:black, scaleDimensions:false}).alp(.5).pos(30,30,LEFT,TOP,content).expand(0)
|
|
36587
|
+
box.on("mousedown", doClear);
|
|
36588
|
+
function doClear() {
|
|
36589
|
+
linesH.loop(function(l) {
|
|
36590
|
+
l.triangle.color = faint;
|
|
36591
|
+
});
|
|
36592
|
+
currentH = null;
|
|
36593
|
+
linesV.loop(function(l) {
|
|
36594
|
+
l.triangle.color = faint;
|
|
36595
|
+
});
|
|
36596
|
+
currentV = null;
|
|
36597
|
+
that.stage.update();
|
|
36598
|
+
}
|
|
36599
|
+
|
|
36600
|
+
var hide = that.hide = new zim.Button({width:30, height:30, label:"-", toggle:"+", color:silver, backgroundColor:darker, rollBackgroundColor:lighter, rollColor:granite, corner:0, shadowColor:-1, style:false}).sca(1).loc(0,0,content);
|
|
36601
|
+
hide.label.mov(0,-2)
|
|
36602
|
+
hide.on("click", function(){
|
|
36603
|
+
if (hide.toggled) {
|
|
36604
|
+
hide.label.mov(0,3);
|
|
36605
|
+
box.visible = trackH.visible = trackV.visible = linesH.visible = linesV.visible = deleteH.visible = deleteV.visible = highlights.visible = false;
|
|
36606
|
+
if (multi) multi.vis(false);
|
|
36607
|
+
if (upload) loader.removeFrom();
|
|
36608
|
+
} else {
|
|
36609
|
+
hide.label.mov(0,-3);
|
|
36610
|
+
box.visible = trackH.visible = trackV.visible = linesH.visible = linesV.visible = deleteH.visible = deleteV.visible = highlights.visible = true;
|
|
36611
|
+
if (multi) multi.vis(true);
|
|
36612
|
+
if (upload) loader.addTo(that.contentContainer);
|
|
36613
|
+
}
|
|
36614
|
+
});
|
|
36615
|
+
|
|
36616
|
+
var trackH = that.trackH = new zim.Rectangle(w, 30, white).alp(.1).loc(box.x, box.y-30, content).cur();
|
|
36617
|
+
var trackV = that.trackV = new zim.Rectangle(30, h, white).alp(.1).loc(box.x-30, box.y, content).cur();
|
|
36618
|
+
var deleteH = that.deleteH = new zim.Button({width:60, height:60, label:"X", backgroundColor:red, corner:0, shadowColor:-1, style:false}).sca(.5).pos(0,0,RIGHT,TOP,content);
|
|
36619
|
+
var deleteV = that.deleteV = deleteH.clone().pos(0,0,LEFT,BOTTOM,content);
|
|
36620
|
+
|
|
36621
|
+
if (selection && multiple) var multi = that.toggle = new zim.Toggle({height:18, width:30, backgroundColor:grey, corner:9, label:"multiple", color:tin})
|
|
36622
|
+
.loc(deleteV.x + 45, deleteV.y+6, content);
|
|
36623
|
+
|
|
36624
|
+
if (upload) {
|
|
36625
|
+
var icon1 = new zim.Circle(6,silver).reg(CENTER,3);
|
|
36626
|
+
new zim.Circle({radius:9, color:silver, percent:40}).center(icon1).mov(0,8);
|
|
36627
|
+
var icon2 = new zim.Circle(6,grey).reg(CENTER,3);
|
|
36628
|
+
new zim.Circle({radius:9, color:grey, percent:40}).center(icon2).mov(0,8);
|
|
36629
|
+
var loader = that.loader = new zim.Loader({
|
|
36630
|
+
width:30,
|
|
36631
|
+
height:30,
|
|
36632
|
+
backgroundColor:darker,
|
|
36633
|
+
rollBackgroundColor:lighter,
|
|
36634
|
+
corner:3,
|
|
36635
|
+
borderColor:-1,
|
|
36636
|
+
label:"",
|
|
36637
|
+
icon:icon1,
|
|
36638
|
+
rollIcon:icon2
|
|
36639
|
+
});
|
|
36640
|
+
loader.on("loaded", function(e) {
|
|
36641
|
+
obj.dispose();
|
|
36642
|
+
loader.removeRoll();
|
|
36643
|
+
var f = e.bitmap.fit(0,0,oWW-60, oWH-60-(titleBar?30:0));
|
|
36644
|
+
scale = f.scale;
|
|
36645
|
+
e.bitmap.sca(1);
|
|
36646
|
+
wW = e.bitmap.width*scale+60;
|
|
36647
|
+
wH = e.bitmap.height*scale+60;
|
|
36648
|
+
that.resize(wW, wH);
|
|
36649
|
+
obj = e.bitmap.sca(scale).loc(0,0,sc,0);
|
|
36650
|
+
that.obj = obj;
|
|
36651
|
+
doResize();
|
|
36652
|
+
that.dispatchEvent("loaded");
|
|
36653
|
+
});
|
|
36654
|
+
}
|
|
36655
|
+
|
|
36656
|
+
var instruct = that.instruct = new zim.Container(content.width, content.height).addTo(content).animate({
|
|
36657
|
+
wait:1,
|
|
36658
|
+
from:true,
|
|
36659
|
+
props:{alpha:0},
|
|
36660
|
+
rewind:true,
|
|
36661
|
+
rewindWait:2,
|
|
36662
|
+
call:function(){instruct.dispose(); instruct=null;}
|
|
36663
|
+
}).noMouse();
|
|
36664
|
+
new zim.Label("Add slices here", 15, null, blue).pos(0,8,CENTER,TOP,instruct);
|
|
36665
|
+
new zim.Label("Add slices here", 15, null, blue).rot(-90).pos(8,0,LEFT,CENTER,instruct);
|
|
36666
|
+
|
|
36667
|
+
// ADD CONTENT TO WINDOW
|
|
36668
|
+
that.add(content);
|
|
36669
|
+
that.add(loader, null, true);
|
|
36670
|
+
loader.pos(0,0,RIGHT,BOTTOM)
|
|
36671
|
+
|
|
36672
|
+
|
|
36673
|
+
// LINES
|
|
36674
|
+
var linesH = that.linesHContainer = new zim.Container(w,h).loc(box, null, content);
|
|
36675
|
+
var linesV = that.linesVContainer = new zim.Container(w,h).loc(box, null, content);
|
|
36676
|
+
var currentH;
|
|
36677
|
+
var currentV;
|
|
36678
|
+
|
|
36679
|
+
// axis is direction of line, so VERTICAL will use linesH, etc.
|
|
36680
|
+
that.makeLine = function(axis, ratio, selected) {
|
|
36681
|
+
if (ratio > 1) ratio /= 100;
|
|
36682
|
+
var line;
|
|
36683
|
+
if (axis == "vertical") {
|
|
36684
|
+
var x = ratio*box.width;
|
|
36685
|
+
line = new zim.Container(30,h+30).reg(15,30).loc(x, 0, linesH);
|
|
36686
|
+
line.triangle = new zim.Triangle(30,30,30,selected?blue:faint,blue).rot(180).pos(0,4,CENTER,TOP,line);
|
|
36687
|
+
line.line = new zim.Rectangle(1,box.height,red).ble().expand(3).reg(0,0).pos(0,30,CENTER,TOP,line);
|
|
36688
|
+
line.drag({all:true, boundary:new zim.Boundary(0,0,box.width,0), localBoundary:true});
|
|
36689
|
+
line.on("mousedown", function() {
|
|
36690
|
+
linesH.loop(function(l) {
|
|
36691
|
+
if (l==line) l.triangle.color = blue;
|
|
36692
|
+
else l.triangle.color = faint;
|
|
36693
|
+
});
|
|
36694
|
+
currentH = that.currentLineH = line;
|
|
36695
|
+
that.stage.update();
|
|
36696
|
+
});
|
|
36697
|
+
line.on("pressmove", dataLinesH);
|
|
36698
|
+
} else {
|
|
36699
|
+
var y = ratio*box.height;
|
|
36700
|
+
line = new zim.Container(w+30,30).reg(30,15).loc(0, y, linesV);
|
|
36701
|
+
line.triangle = new zim.Triangle(30,30,30,selected?blue:faint,blue).rot(90).pos(4,0,LEFT,CENTER,line);
|
|
36702
|
+
line.line = new zim.Rectangle(box.width,1,red).ble().expand(3).reg(0,0).pos(30,0,LEFT,CENTER,line);
|
|
36703
|
+
line.drag({all:true, boundary:new zim.Boundary(0,0,0,box.height), localBoundary:true});
|
|
36704
|
+
line.on("mousedown", function() {
|
|
36705
|
+
linesV.loop(function(l) {
|
|
36706
|
+
if (l==line) l.triangle.color = blue;
|
|
36707
|
+
else l.triangle.color = faint;
|
|
36708
|
+
});
|
|
36709
|
+
currentV = that.currentLineV = line;
|
|
36710
|
+
that.stage.update();
|
|
36711
|
+
});
|
|
36712
|
+
line.on("pressmove", dataLinesV);
|
|
36713
|
+
}
|
|
36714
|
+
return line;
|
|
36715
|
+
}
|
|
36716
|
+
|
|
36717
|
+
// HORIZONTAL
|
|
36718
|
+
// across the top - will make vertical lines but slices into horizontal regions
|
|
36719
|
+
trackH.on("mousedown", function() {
|
|
36720
|
+
if (instruct) instruct.dispose();
|
|
36721
|
+
linesH.loop(function(l) {
|
|
36722
|
+
l.triangle.color = faint;
|
|
36723
|
+
});
|
|
36724
|
+
var point = linesH.globalToLocal(F.mouseX, F.mouseY);
|
|
36725
|
+
that.currentLineH = currentH = that.makeLine(VERTICAL, point.x/box.width, true);
|
|
36726
|
+
|
|
36727
|
+
// move any selections past the line forward one
|
|
36728
|
+
var c = that.selectedIndexH = getIndexH(currentH);
|
|
36729
|
+
selected.sort(function (a, b) {
|
|
36730
|
+
return a[0] - b[0];
|
|
36731
|
+
});
|
|
36732
|
+
loop(selected, function (s, i) {
|
|
36733
|
+
if (s[0] >= c) s[0]++;
|
|
36734
|
+
}, true); // true for backwards
|
|
36735
|
+
|
|
36736
|
+
// adding dataTypes to columns in each row
|
|
36737
|
+
if (that.dataTypes) {
|
|
36738
|
+
that.dataTypes[0].splice(c-1, 0, that.dataTypes[0][c-1]); // take types from next door
|
|
36739
|
+
// zim.loop(that.dataTypes, function(row,j){
|
|
36740
|
+
// row.splice(c-1, 0, [row[c-1][0], row[c-1][1]]); // take types from next door
|
|
36741
|
+
// });
|
|
36742
|
+
}
|
|
36743
|
+
|
|
36744
|
+
dataLinesH();
|
|
36745
|
+
that.stage.update();
|
|
36746
|
+
})
|
|
36747
|
+
|
|
36748
|
+
deleteH.on("click", function(){
|
|
36749
|
+
if (currentH) {
|
|
36750
|
+
|
|
36751
|
+
// move any selections past the line including the line back one
|
|
36752
|
+
var c = getIndexH(currentH);
|
|
36753
|
+
selected.sort(function (a, b) {
|
|
36754
|
+
return a[0] - b[0];
|
|
36755
|
+
});
|
|
36756
|
+
loop(selected, function (s, i) {
|
|
36757
|
+
if (s[0] >= c - 1) s[0]--;
|
|
36758
|
+
}, true); // true for backwards
|
|
36759
|
+
|
|
36760
|
+
// remove duplicates of one less than c
|
|
36761
|
+
var already = [];
|
|
36762
|
+
loop(selected, function(s, i) {
|
|
36763
|
+
if (s[0] == c-2 && already.indexOf(JSON.stringify(s)) >= 0) selected.splice(i,1);
|
|
36764
|
+
else already.push(JSON.stringify(s));
|
|
36765
|
+
}, true);
|
|
36766
|
+
already = null;
|
|
36767
|
+
|
|
36768
|
+
// remove data from types
|
|
36769
|
+
if (that.dataTypes) that.dataTypes[0].splice(c-1, 1);
|
|
36770
|
+
|
|
36771
|
+
currentH.dispose();
|
|
36772
|
+
that.currentLineH = currentH = null;
|
|
36773
|
+
|
|
36774
|
+
dataLinesH();
|
|
36775
|
+
that.dispatchEvent("delete");
|
|
36776
|
+
that.stage.update();
|
|
36777
|
+
}
|
|
36778
|
+
});
|
|
36779
|
+
|
|
36780
|
+
function dataLinesH() {
|
|
36781
|
+
that.data[0] = [0,1];
|
|
36782
|
+
linesH.loop(function(l) {
|
|
36783
|
+
that.data[0].push(zim.decimals(l.x/box.width,3));
|
|
36784
|
+
})
|
|
36785
|
+
that.data[0].sort(function(a, b){return a-b});
|
|
36786
|
+
adjustBoxes();
|
|
36787
|
+
}
|
|
36788
|
+
|
|
36789
|
+
function getIndexH(line) {
|
|
36790
|
+
var c = zim.loop(that.data[0], function(x,i) {
|
|
36791
|
+
if (zim.decimals(line.x/box.width,3) < x) return i;
|
|
36792
|
+
});
|
|
36793
|
+
return c;
|
|
36794
|
+
}
|
|
36795
|
+
|
|
36796
|
+
// VERTICAL
|
|
36797
|
+
// same as horizontal but along left will make vertical lines but slices into vertical regions
|
|
36798
|
+
trackV.on("mousedown", function() {
|
|
36799
|
+
if (instruct) instruct.dispose();
|
|
36800
|
+
linesV.loop(function(l) {
|
|
36801
|
+
l.triangle.color = faint;
|
|
36802
|
+
});
|
|
36803
|
+
var point = linesV.globalToLocal(F.mouseX, F.mouseY);
|
|
36804
|
+
|
|
36805
|
+
var point = linesH.globalToLocal(F.mouseX, F.mouseY);
|
|
36806
|
+
that.currentLineV = currentV = that.makeLine(HORIZONTAL, point.y/box.height, true);
|
|
36807
|
+
|
|
36808
|
+
// move any selections past the line forward one
|
|
36809
|
+
var r = that.selectedIndexV = getIndexV(currentV);
|
|
36810
|
+
selected.sort(function (a, b) {
|
|
36811
|
+
return a[1] - b[1];
|
|
36812
|
+
});
|
|
36813
|
+
loop(selected, function (s, i) {
|
|
36814
|
+
if (s[1] >= r) s[1]++;
|
|
36815
|
+
}, true); // true for backwards
|
|
36816
|
+
|
|
36817
|
+
// adding row with columns
|
|
36818
|
+
if (that.dataTypes) that.dataTypes[1].splice(r-1, 0, that.dataTypes[1][r-1]); // take types from next door
|
|
36819
|
+
|
|
36820
|
+
dataLinesV();
|
|
36821
|
+
that.stage.update();
|
|
36822
|
+
})
|
|
36823
|
+
|
|
36824
|
+
deleteV.on("click", function(){
|
|
36825
|
+
if (currentV) {
|
|
36826
|
+
// move any selections past the line including the line back one
|
|
36827
|
+
var r = getIndexV(currentV);
|
|
36828
|
+
selected.sort(function (a, b) {
|
|
36829
|
+
return a[1] - b[1];
|
|
36830
|
+
});
|
|
36831
|
+
loop(selected, function (s, i) {
|
|
36832
|
+
if (s[1] >= r - 1) s[1]--;
|
|
36833
|
+
}, true); // true for backwards
|
|
36834
|
+
|
|
36835
|
+
// remove duplicates of less than r
|
|
36836
|
+
var already = [];
|
|
36837
|
+
loop(selected, function(s, i) {
|
|
36838
|
+
if (s[1] == r-2 && already.indexOf(JSON.stringify(s)) >= 0) selected.splice(i,1);
|
|
36839
|
+
else already.push(JSON.stringify(s));
|
|
36840
|
+
}, true);
|
|
36841
|
+
already = null;
|
|
36842
|
+
|
|
36843
|
+
// remove data from types
|
|
36844
|
+
if (that.dataTypes) that.dataTypes[1].splice(r-1, 1);
|
|
36845
|
+
|
|
36846
|
+
currentV.dispose();
|
|
36847
|
+
that.currentLineV = currentV = null;
|
|
36848
|
+
|
|
36849
|
+
dataLinesV();
|
|
36850
|
+
that.dispatchEvent("delete");
|
|
36851
|
+
that.stage.update();
|
|
36852
|
+
}
|
|
36853
|
+
});
|
|
36854
|
+
|
|
36855
|
+
function dataLinesV() {
|
|
36856
|
+
that.data[1] = [0,1];
|
|
36857
|
+
linesV.loop(function(l) {
|
|
36858
|
+
that.data[1].push(zim.decimals(l.y/box.height,3));
|
|
36859
|
+
})
|
|
36860
|
+
that.data[1].sort(function(a, b){return a-b});
|
|
36861
|
+
adjustBoxes();
|
|
36862
|
+
}
|
|
36863
|
+
|
|
36864
|
+
function getIndexV(line) {
|
|
36865
|
+
var r = zim.loop(that.data[1], function(y,i) {
|
|
36866
|
+
if (zim.decimals(line.y/box.height,3) < y) return i;
|
|
36867
|
+
});
|
|
36868
|
+
return r;
|
|
36869
|
+
}
|
|
36870
|
+
|
|
36871
|
+
// HIGHLIGHTS
|
|
36872
|
+
function adjustBoxes(dispatch) {
|
|
36873
|
+
if (zot(dispatch)) dispatch = true;
|
|
36874
|
+
highlights.disposeAllChildren();
|
|
36875
|
+
zim.loop(selected, function(s) {
|
|
36876
|
+
that.selectTile(s[0],s[1]);
|
|
36877
|
+
});
|
|
36878
|
+
if (dispatch) that.dispatchEvent("change");
|
|
36879
|
+
if (localStorage) localStorage.zimSlicer = JSON.stringify(that.exchange);
|
|
36880
|
+
}
|
|
36881
|
+
|
|
36882
|
+
var selected = that.selected = [];
|
|
36883
|
+
|
|
36884
|
+
var highlights = that.highlightsContainer = new zim.Container(W,H).loc(box, null, content).noMouse();
|
|
36885
|
+
var gap = 5;
|
|
36886
|
+
that.selectTile = function(c,r,d) {
|
|
36887
|
+
if (d) highlights.disposeAllChildren();
|
|
36888
|
+
c = zim.constrain(c,0,that.data[0].length-1);
|
|
36889
|
+
r = zim.constrain(r,0,that.data[1].length-1);
|
|
36890
|
+
that.selection = new zim.Rectangle(that.data[0][c+1]*box.width-that.data[0][c]*box.width-gap*2, that.data[1][r+1]*box.height-that.data[1][r]*box.height-gap*2, white.toAlpha(.2), white, 2, 0, true)
|
|
36891
|
+
.loc(that.data[0][c]*box.width+gap, that.data[1][r]*box.height+gap, highlights)
|
|
36892
|
+
.ble();
|
|
36893
|
+
}
|
|
36894
|
+
|
|
36895
|
+
if (selection) {
|
|
36896
|
+
box.cur();
|
|
36897
|
+
box.on("mousedown", function(){
|
|
36898
|
+
var point = box.globalToLocal(that.stage.frame.mouseX, that.stage.frame.mouseY);
|
|
36899
|
+
var c = zim.loop(that.data[0], function(x,i) {
|
|
36900
|
+
if (point.x < x*box.width) return i-1;
|
|
36901
|
+
});
|
|
36902
|
+
var r = zim.loop(that.data[1], function(y,i) {
|
|
36903
|
+
if (point.y < y*box.height) return i-1;
|
|
36904
|
+
});
|
|
36905
|
+
|
|
36906
|
+
var empty = zim.loop(selected, function(s,i) {
|
|
36907
|
+
if (JSON.stringify(s) == JSON.stringify([c,r])) {
|
|
36908
|
+
if (selected.length > 1 && multiple && !F.shiftKey && !multi.toggled) return true; // if others just clear others
|
|
36909
|
+
selected.splice(i,1); // else toggling a selected
|
|
36910
|
+
return false;
|
|
36911
|
+
}
|
|
36912
|
+
});
|
|
36913
|
+
|
|
36914
|
+
if (!multiple || (!F.shiftKey && !multi.toggled)) selected = that.selected = [];
|
|
36915
|
+
if (empty) {
|
|
36916
|
+
selected.push([c,r]); // could put the above like in this conditional
|
|
36917
|
+
}
|
|
36918
|
+
|
|
36919
|
+
adjustBoxes(false);
|
|
36920
|
+
that.dispatchEvent("selection");
|
|
36921
|
+
});
|
|
36922
|
+
}
|
|
36923
|
+
|
|
36924
|
+
// RESIZE
|
|
36925
|
+
that.on("resize", doResize);
|
|
36926
|
+
function doResize() {
|
|
36927
|
+
hh = that.height-(titleBar?30:0);
|
|
36928
|
+
var boxH = box.width;
|
|
36929
|
+
var boxV = box.height;
|
|
36930
|
+
that.box.siz(that.width-60, hh-60).expand(0);
|
|
36931
|
+
deleteH.loc(box.x+box.width,box.y-30);
|
|
36932
|
+
deleteV.loc(box.x-30,box.y+box.height);
|
|
36933
|
+
trackH.widthOnly = box.width;
|
|
36934
|
+
trackV.heightOnly = box.height;
|
|
36935
|
+
linesH.loop(function(line, i) {
|
|
36936
|
+
line.line.heightOnly = box.height;
|
|
36937
|
+
if (proportion) line.x = line.x*box.width/boxH;
|
|
36938
|
+
line.dragBoundary(new zim.Boundary(0,0,box.width,0));
|
|
36939
|
+
});
|
|
36940
|
+
linesV.loop(function(line) {
|
|
36941
|
+
line.line.widthOnly = box.width;
|
|
36942
|
+
if (proportion) line.y = line.y*box.height/boxV;
|
|
36943
|
+
line.dragBoundary(new zim.Boundary(0,0,0,box.height));
|
|
36944
|
+
});
|
|
36945
|
+
if (multi) multi.loc(deleteV.x + 45, deleteV.y+6, content);
|
|
36946
|
+
if (upload) {
|
|
36947
|
+
loader.loc(that.box.width+30,that.box.height+30);
|
|
36948
|
+
loader.resize();
|
|
36949
|
+
}
|
|
36950
|
+
adjustBoxes();
|
|
36951
|
+
if (obj.width) {
|
|
36952
|
+
obj.scaleTo(that.box,100,100).loc(0,0,sc,0);
|
|
36953
|
+
that.stage.update();
|
|
36954
|
+
} else {
|
|
36955
|
+
setTimeout(function() {
|
|
36956
|
+
obj.scaleTo(that.box,100,100).loc(0,0,sc,0);
|
|
36957
|
+
that.stage.update();
|
|
36958
|
+
}, 50);
|
|
36959
|
+
}
|
|
36960
|
+
}
|
|
36961
|
+
if (resize) {
|
|
36962
|
+
that.resizeHandle.on("pressup", function() {
|
|
36963
|
+
var wW = obj.width+60;
|
|
36964
|
+
var wH = obj.height+60;
|
|
36965
|
+
that.resize(wW,wH);
|
|
36966
|
+
that.stage.update()
|
|
36967
|
+
});
|
|
36968
|
+
}
|
|
36969
|
+
|
|
36970
|
+
|
|
36971
|
+
|
|
36972
|
+
// METHODS
|
|
36973
|
+
that.setObject = function(newObj, scale) {
|
|
36974
|
+
obj.dispose();
|
|
36975
|
+
obj = newObj;
|
|
36976
|
+
if (zot(scale)) {
|
|
36977
|
+
var f = e.bitmap.fit(0,0,oWW-60, oWH-60-(titleBar?30:0));
|
|
36978
|
+
scale = f.scale;
|
|
36979
|
+
}
|
|
36980
|
+
obj.sca(1);
|
|
36981
|
+
wW = obj.width*scale+60;
|
|
36982
|
+
wH = obj.height*scale+60;
|
|
36983
|
+
that.resize(wW, wH);
|
|
36984
|
+
obj = obj.sca(scale).loc(0,0,sc,0);
|
|
36985
|
+
that.obj = obj;
|
|
36986
|
+
doResize();
|
|
36987
|
+
that.dispatchEvent("loaded");
|
|
36988
|
+
return that;
|
|
36989
|
+
}
|
|
36990
|
+
|
|
36991
|
+
that.updateLines = function(slices) {
|
|
36992
|
+
that.data = slices;
|
|
36993
|
+
// clear all lines and remake them to the data
|
|
36994
|
+
linesH.disposeAllChildren();
|
|
36995
|
+
linesV.disposeAllChildren();
|
|
36996
|
+
zim.loop(slices[0], function(x,i,t) {if (i!=0 && i!=t-1) {that.makeLine(VERTICAL, x)};});
|
|
36997
|
+
zim.loop(slices[1], function(y,i,t) {if (i!=0 && i!=t-1) {that.makeLine(HORIZONTAL, y)};});
|
|
36998
|
+
that.selectedIndexH = that.selectedIndexV = that.currentLineH = that.currentLineV = null;
|
|
36999
|
+
if (that.stage) that.stage.update();
|
|
37000
|
+
return that;
|
|
37001
|
+
}
|
|
37002
|
+
|
|
37003
|
+
that.setSlicerTypes = function(slicerTypes) {
|
|
37004
|
+
if (!that.dataTypes) that.dataTypes = [[1],[1]];
|
|
37005
|
+
var st = that.slicerTypes = slicerTypes;
|
|
37006
|
+
that.on("select", function() {
|
|
37007
|
+
if (selected.length > 0) {
|
|
37008
|
+
st.shield.vis(false);
|
|
37009
|
+
|
|
37010
|
+
// loop through all selected and if the same types
|
|
37011
|
+
var lastH;
|
|
37012
|
+
var lastV;
|
|
37013
|
+
zim.loop(selected, function(s) {
|
|
37014
|
+
var type = that.dataTypes[0][s[0]];
|
|
37015
|
+
if (lastH != "bad" && (lastH==null || lastH==type)) lastH = type;
|
|
37016
|
+
else lastH = "bad";
|
|
37017
|
+
type = that.dataTypes[1][s[1]];
|
|
37018
|
+
if (lastV != "bad" && (lastV==null || lastV==type)) lastV = type;
|
|
37019
|
+
else lastV = "bad";
|
|
37020
|
+
if (lastH == "bad" && lastV == "bad") return false; // exits loop
|
|
37021
|
+
});
|
|
37022
|
+
|
|
37023
|
+
// if not the same types then yellow the box and remove selection
|
|
37024
|
+
if (lastH == "bad") {
|
|
37025
|
+
st.radioH.selectedIndex = -1;
|
|
37026
|
+
st.tile.backgrounds[1].color = brown;
|
|
37027
|
+
} else {
|
|
37028
|
+
st.radioH.selectedIndex = lastH;
|
|
37029
|
+
st.tile.backgrounds[1].color = light;
|
|
37030
|
+
}
|
|
37031
|
+
|
|
37032
|
+
if (lastV == "bad") {
|
|
37033
|
+
st.radioV.selectedIndex = -1;
|
|
37034
|
+
st.tile.backgrounds[3].color = brown;
|
|
37035
|
+
} else {
|
|
37036
|
+
st.radioV.selectedIndex = lastV;
|
|
37037
|
+
st.tile.backgrounds[3].color = light;
|
|
37038
|
+
}
|
|
37039
|
+
|
|
37040
|
+
} else {
|
|
37041
|
+
st.radioH.selectedIndex = -1;
|
|
37042
|
+
st.radioV.selectedIndex = -1;
|
|
37043
|
+
st.shield.vis(true);
|
|
37044
|
+
}
|
|
37045
|
+
});
|
|
37046
|
+
that.stage.update();
|
|
37047
|
+
return that;
|
|
37048
|
+
}
|
|
37049
|
+
|
|
37050
|
+
that.clearSelection = function() {
|
|
37051
|
+
selected = that.selected = [];
|
|
37052
|
+
highlights.disposeAllChildren();
|
|
37053
|
+
if (that.slicerTypes) {
|
|
37054
|
+
var st = that.slicerTypes;
|
|
37055
|
+
st.radioH.selectedIndex = -1;
|
|
37056
|
+
st.radioV.selectedIndex = -1;
|
|
37057
|
+
st.shield.vis(true);
|
|
37058
|
+
}
|
|
37059
|
+
that.stage.update();
|
|
37060
|
+
return that;
|
|
37061
|
+
}
|
|
37062
|
+
|
|
37063
|
+
that.clear = function() {
|
|
37064
|
+
if (localStorage) localStorage.removeItem("zimSlicer");
|
|
37065
|
+
that.exchange = [[[],[]],[[1],[1]]];
|
|
37066
|
+
that.clearSelection();
|
|
37067
|
+
that.dispatchEvent("change");
|
|
37068
|
+
return that;
|
|
37069
|
+
}
|
|
37070
|
+
|
|
37071
|
+
|
|
37072
|
+
// PROPERTIES
|
|
37073
|
+
Object.defineProperty(that, 'slices', {
|
|
37074
|
+
get: function() {
|
|
37075
|
+
var temp = zim.copy(that.data);
|
|
37076
|
+
temp[0].shift();
|
|
37077
|
+
temp[0].pop();
|
|
37078
|
+
temp[1].shift();
|
|
37079
|
+
temp[1].pop();
|
|
37080
|
+
return temp;
|
|
37081
|
+
},
|
|
37082
|
+
set: function(value) {
|
|
37083
|
+
var slices = zim.copy(value);
|
|
37084
|
+
slices[0].unshift(0);
|
|
37085
|
+
slices[0].push(1);
|
|
37086
|
+
slices[1].unshift(0);
|
|
37087
|
+
slices[1].push(1);
|
|
37088
|
+
that.updateLines(slices);
|
|
37089
|
+
}
|
|
37090
|
+
});
|
|
37091
|
+
|
|
37092
|
+
Object.defineProperty(that, 'types', {
|
|
37093
|
+
get: function() {
|
|
37094
|
+
return zim.copy(that.dataTypes);
|
|
37095
|
+
},
|
|
37096
|
+
set: function(value) {
|
|
37097
|
+
that.dataTypes = zim.copy(value);
|
|
37098
|
+
}
|
|
37099
|
+
});
|
|
37100
|
+
|
|
37101
|
+
Object.defineProperty(that, 'exchange', {
|
|
37102
|
+
get: function() {
|
|
37103
|
+
var temp = zim.copy(that.data);
|
|
37104
|
+
temp[0].shift();
|
|
37105
|
+
temp[0].pop();
|
|
37106
|
+
temp[1].shift();
|
|
37107
|
+
temp[1].pop();
|
|
37108
|
+
return [temp, zim.copy(that.dataTypes)];
|
|
37109
|
+
},
|
|
37110
|
+
set: function(value) {
|
|
37111
|
+
var slices = zim.copy(value[0]);
|
|
37112
|
+
var types = zim.copy(value[1]);
|
|
37113
|
+
slices[0].unshift(0);
|
|
37114
|
+
slices[0].push(1);
|
|
37115
|
+
slices[1].unshift(0);
|
|
37116
|
+
slices[1].push(1);
|
|
37117
|
+
that.updateLines(slices);
|
|
37118
|
+
that.dataTypes = types;
|
|
37119
|
+
}
|
|
37120
|
+
});
|
|
37121
|
+
|
|
37122
|
+
// MEMORY
|
|
37123
|
+
if (remember && localStorage && localStorage.zimSlicer) {
|
|
37124
|
+
that.exchange = JSON.parse(localStorage.zimSlicer);
|
|
37125
|
+
instruct.dispose();
|
|
37126
|
+
} else if (empty) {
|
|
37127
|
+
that.exchange =[slices, types];
|
|
37128
|
+
instruct.dispose();
|
|
37129
|
+
}
|
|
37130
|
+
setTimeout(function(){that.dispatchEvent("change");},20);
|
|
37131
|
+
|
|
37132
|
+
if (style!==false) zim.styleTransforms(this, DS);
|
|
37133
|
+
this.clone = function() {
|
|
37134
|
+
return that.cloneProps(new zim.Slicer(obj.clone(), objScale, zim.copy(slices), zim.copy(types), titleBar, remember, upload, selection, multiple, proportion, resize, style, this.group, inherit));
|
|
37135
|
+
};
|
|
37136
|
+
|
|
37137
|
+
}
|
|
37138
|
+
zim.extend(zim.Slicer, zim.Window, ["clone"], "zimWindow", false);
|
|
37139
|
+
//-62.7
|
|
37140
|
+
|
|
37141
|
+
//
|
|
37142
|
+
/*--
|
|
37143
|
+
zim.SlicerTypes = function(slicer, titleBar, sliceType, style, group, inherit);
|
|
37144
|
+
|
|
37145
|
+
SlicerTypes
|
|
37146
|
+
zim class - extends a zim.Window which extends a zim.Container which extends a createjs.Container
|
|
37147
|
+
|
|
37148
|
+
DESCRIPTION
|
|
37149
|
+
SlicerTypes works with ZIM Slicer to provide slice types for ZIM SlicedBitmap.
|
|
37150
|
+
The component is not to be used on its own.
|
|
37151
|
+
Pass a ZIM Slicer object to the slicer parameter - the Slicer should be made first.
|
|
37152
|
+
There are fixed, stretch and tile radio buttons for horizontal and vertical
|
|
37153
|
+
and import and export buttons to work with [slices, types] used in Slicer and SlicedBitmap parameters and exchange property.
|
|
37154
|
+
|
|
37155
|
+
See: https://zimjs.com/slicer which shows how a Slicer can be used to create data for a ZIM SlicedBitmap
|
|
37156
|
+
|
|
37157
|
+
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
37158
|
+
|
|
37159
|
+
EXAMPLE
|
|
37160
|
+
// slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
|
|
37161
|
+
const pic = new Pic("car.png"); // preload this in Frame() or loadAssets()
|
|
37162
|
+
const slicer = new Slicer({
|
|
37163
|
+
obj:pic.clone(), // slicer will adjust obj so clone the pic so can use it unaffected later
|
|
37164
|
+
scale:.5,
|
|
37165
|
+
upload:false
|
|
37166
|
+
})
|
|
37167
|
+
.pos(30,50)
|
|
37168
|
+
.change(()=>{preview.exchange = slicer.exchange;); // this will update the picture below
|
|
37169
|
+
|
|
37170
|
+
slicer.on("loaded", ()=>{
|
|
37171
|
+
if (preview) preview.dispose();
|
|
37172
|
+
preview = new zim.SlicedBitmap(1600, 600, slicer.obj.clone(), slicer.slices, slicer.types, 2, .5)
|
|
37173
|
+
.pos(0,100,CENTER,BOTTOM)
|
|
37174
|
+
.transform({minScaleX:.05, minScaleY:.05});
|
|
37175
|
+
});
|
|
37176
|
+
|
|
37177
|
+
// this will provide slice type options
|
|
37178
|
+
new SlicerTypes(slicer).pos(30,120,RIGHT,TOP);
|
|
37179
|
+
|
|
37180
|
+
// slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
|
|
37181
|
+
let preview = new SlicedBitmap(1600, pic.height, pic)
|
|
37182
|
+
.center()
|
|
37183
|
+
.transform({minScaleX:.05, minScaleY:.05});
|
|
37184
|
+
END EXAMPLE
|
|
37185
|
+
|
|
37186
|
+
PARAMETERS
|
|
37187
|
+
** supports DUO - parameters or single object with properties below
|
|
37188
|
+
** supports OCT - parameter defaults can be set with STYLE control (like CSS)
|
|
37189
|
+
slicer - (default null) pass in the ZIM Slicer object to work with - required
|
|
37190
|
+
titleBar - (default "Slicer Types") string or Label for slicerTypes
|
|
37191
|
+
sliceType - (default "stretch") set the default slice type - fixed, stretch, tile
|
|
37192
|
+
style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
|
|
37193
|
+
group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
|
|
37194
|
+
inherit - (default null) used internally but can receive an {} of styles directly
|
|
37195
|
+
|
|
37196
|
+
METHODS
|
|
37197
|
+
hasProp(property as String) - returns true if property exists on object else returns false
|
|
37198
|
+
clone() - makes a copy with properties such as x, y, etc. also copied
|
|
37199
|
+
dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
|
|
37200
|
+
|
|
37201
|
+
ALSO: All Window methods such as resize()
|
|
37202
|
+
|
|
37203
|
+
ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
|
|
37204
|
+
drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
|
|
37205
|
+
addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
|
|
37206
|
+
ALSO: see the CreateJS Easel Docs for Container methods, such as:
|
|
37207
|
+
on(), off(), getBounds(), setBounds(), cache(), uncache(), updateCache(), dispatchEvent(),
|
|
37208
|
+
addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChildren(), etc.
|
|
37209
|
+
|
|
37210
|
+
PROPERTIES
|
|
37211
|
+
type - holds the class name as a String
|
|
37212
|
+
slicer - read slicer used
|
|
37213
|
+
sliceType - get or set default slice type - fixed, stretch, tile
|
|
37214
|
+
radioH - access RadioButtons for horizontal
|
|
37215
|
+
radioV - access RadioButtons for horizontal
|
|
37216
|
+
importButton - access import Button
|
|
37217
|
+
exportButton - access export Button
|
|
37218
|
+
importPane - access import Pane
|
|
37219
|
+
exportPane - access export Pane
|
|
37220
|
+
submitButton - access import pane submit Button
|
|
37221
|
+
shield - access shield that darkens radio buttons
|
|
37222
|
+
|
|
37223
|
+
ALSO: see ZIM Window for properties - like titleBar, titleBarLabel, resizeHandle, etc.
|
|
37224
|
+
|
|
37225
|
+
ALSO: see ZIM Container for properties such as:
|
|
37226
|
+
width, height, widthOnly, heightOnly, draggable, level, depth, group
|
|
37227
|
+
blendMode, hue, saturation, brightness, contrast, etc.
|
|
37228
|
+
|
|
37229
|
+
ALSO: see the CreateJS Easel Docs for Container properties, such as:
|
|
37230
|
+
x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
|
|
37231
|
+
alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, etc.
|
|
37232
|
+
|
|
37233
|
+
EVENTS
|
|
37234
|
+
ALSO: all Window events including "collapse", "expand", "resize"
|
|
37235
|
+
|
|
37236
|
+
ALSO: see the CreateJS Easel Docs for Container events such as:
|
|
37237
|
+
added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
|
|
37238
|
+
--*///+62.75
|
|
37239
|
+
zim.SlicerTypes = function(slicer, titleBar, sliceType, style, group, inherit) {
|
|
37240
|
+
var sig = "slicer, titleBar, sliceType, style, group, inherit";
|
|
37241
|
+
var duo; if (duo = zob(zim.SlicerTypes, arguments, sig, this)) return duo;
|
|
37242
|
+
z_d("62.75");
|
|
37243
|
+
this.group = group;
|
|
37244
|
+
var DS = style===false?{}:zim.getStyle("SlicerTypes", this.group, inherit);
|
|
37245
|
+
|
|
37246
|
+
if (zot(slicer)) slicer = DS.slicer!=null?DS.slicer:null;
|
|
37247
|
+
if (zot(slicer)) {zogy("ZIM SlicerTypes - needs a Slicer Object"); return;}
|
|
37248
|
+
|
|
37249
|
+
if (zot(titleBar)) titleBar = DS.titleBar!=null?DS.titleBar:"Slicer Types";
|
|
37250
|
+
if (zot(sliceType)) sliceType = DS.sliceType!=null?DS.sliceType:"stretch";
|
|
37251
|
+
|
|
37252
|
+
var types = ["fixed", "stretch", "tile"];
|
|
37253
|
+
if (types.indexOf(sliceType) < 0) sliceType = "stretch";
|
|
37254
|
+
|
|
37255
|
+
this.zimWindow_constructor(470,150, null, null, null, null, null, null, false, null, null, null, null, null, false, false, null, null, null, null, null, null, null, null, null, null, null,
|
|
37256
|
+
titleBar, dark, moon, null, true, null, null, null, null, null, null, null, null, true);
|
|
37257
|
+
var that = this;
|
|
37258
|
+
that.collapseIcon.mov(2);
|
|
37259
|
+
that.titleBarLabel.mov(25,1)
|
|
37260
|
+
zdf.makeIcon(tin, clear, [tin, tin, tin, tin, tin]).scaleTo(that.titleBar,87,87).loc(5,2,that.titleBar);
|
|
37261
|
+
|
|
37262
|
+
that.slicer = slicer;
|
|
37263
|
+
that.sliceType = sliceType;
|
|
37264
|
+
that.defaultIndex = types.indexOf(sliceType);
|
|
37265
|
+
|
|
37266
|
+
var holder = new zim.Container();
|
|
37267
|
+
var radioH = that.radioH = new zim.RadioButtons({size:20, buttons:["fixed","stretch","tile"], vertical:false, selectedIndex:-1}).change(doChangeH);
|
|
37268
|
+
var radioV = that.radioV = radioH.clone().change(doChangeV);
|
|
37269
|
+
Style.remember("slicer");
|
|
37270
|
+
STYLE = {align:CENTER, valign:CENTER, backgroundColor:light, backgroundPaddingH:5};
|
|
37271
|
+
var tile = that.tile = new zim.Tile([new Label("Horizontal", 20).alp(.5), radioH, new Label("Vertical", 20).alp(.5),radioV], 2,2, 5,5, true)
|
|
37272
|
+
.sca(.8)
|
|
37273
|
+
.addTo(holder);
|
|
37274
|
+
Style.recall("slicer");
|
|
37275
|
+
|
|
37276
|
+
function doChangeH() {
|
|
37277
|
+
zim.loop(slicer.selected, function(s) {
|
|
37278
|
+
slicer.dataTypes[0][s[0]] = radioH.selectedIndex;
|
|
37279
|
+
});
|
|
37280
|
+
slicer.dispatchEvent("change");
|
|
37281
|
+
tile.backgrounds[1].color = light;
|
|
37282
|
+
that.stage.update();
|
|
37283
|
+
if (localStorage) localStorage.zimSlicer = JSON.stringify(slicer.exchange);
|
|
37284
|
+
}
|
|
37285
|
+
function doChangeV() {
|
|
37286
|
+
zim.loop(slicer.selected, function(s) {
|
|
37287
|
+
slicer.dataTypes[1][s[1]] = radioV.selectedIndex;
|
|
37288
|
+
});
|
|
37289
|
+
slicer.dispatchEvent("change");
|
|
37290
|
+
tile.backgrounds[3].color = light;
|
|
37291
|
+
that.stage.update();
|
|
37292
|
+
if (localStorage) localStorage.zimSlicer = JSON.stringify(slicer.exchange);
|
|
37293
|
+
}
|
|
37294
|
+
|
|
37295
|
+
var importText = new zim.TextArea({width:600, height:300, wrap:true, spellCheck:false})
|
|
37296
|
+
var importPane = that.importPane = new zim.Pane({content:importText, close:true, closeColor:red});
|
|
37297
|
+
importPane.content.mov(0,-20);
|
|
37298
|
+
var submit = that.submitButton = new zim.Button({
|
|
37299
|
+
width:220,
|
|
37300
|
+
label:"IMPORT",
|
|
37301
|
+
wait:"CONFIRM",
|
|
37302
|
+
waitTime:2,
|
|
37303
|
+
waitBackgroundColor:red,
|
|
37304
|
+
rollWaitBackgroundColor:red
|
|
37305
|
+
}).sca(.6).pos(0,-60,CENTER,BOTTOM,importPane.content);
|
|
37306
|
+
submit.on("mousedown", function(){
|
|
37307
|
+
if (submit.waiting) {
|
|
37308
|
+
importPane.hide();
|
|
37309
|
+
submit.clearWait();
|
|
37310
|
+
slicer.clearSelection();
|
|
37311
|
+
var data = importText.text.trim().split("\n");
|
|
37312
|
+
// JSON does not accept decimals without a leading 0 - sigh
|
|
37313
|
+
data = data.pop().replace(/([^0])\./g, "$10."); // $1 is the match of whatever is before the .
|
|
37314
|
+
data = JSON.parse("[" + data + "]");
|
|
37315
|
+
that.updateData(data[0], data[1]);
|
|
37316
|
+
}
|
|
37317
|
+
});
|
|
37318
|
+
submit.on("close", function() {
|
|
37319
|
+
submit.clearWait();
|
|
37320
|
+
});
|
|
37321
|
+
|
|
37322
|
+
var exportText = new zim.TextArea({width:600, height:300, wrap:true, spellCheck:false});
|
|
37323
|
+
var exportPane = that.exportPane = new zim.Pane({content:exportText, close:true, closeColor:red});
|
|
37324
|
+
|
|
37325
|
+
var importButton = that.importButton = new zim.Button({width:220, label:"IMPORT"}).tap(function() {
|
|
37326
|
+
var temp = zim.copy(slicer.data);
|
|
37327
|
+
temp[0].shift();
|
|
37328
|
+
temp[0].pop();
|
|
37329
|
+
temp[1].shift();
|
|
37330
|
+
temp[1].pop();
|
|
37331
|
+
importText.text = "// replace this current data with desired slices, types data:\n\n" + JSON.stringify(temp) +", "+ JSON.stringify(slicer.dataTypes);
|
|
37332
|
+
importPane.show();
|
|
37333
|
+
});
|
|
37334
|
+
var exportButton = that.exportButton = new zim.Button({width:220, label:"EXPORT"}).tap(function() {
|
|
37335
|
+
var temp = zim.copy(slicer.data);
|
|
37336
|
+
temp[0].shift();
|
|
37337
|
+
temp[0].pop();
|
|
37338
|
+
temp[1].shift();
|
|
37339
|
+
temp[1].pop();
|
|
37340
|
+
exportText.text = "// use as slices, types parameters in ZIM SlicedBitmap()\n// can also modify and IMPORT into Slicer Types tool\n\n" + JSON.stringify(temp) +", "+ JSON.stringify(slicer.dataTypes);
|
|
37341
|
+
exportPane.show();
|
|
37342
|
+
})
|
|
37343
|
+
new zim.Tile([importButton,exportButton],1,2,0,20,true).siz(null,tile.height).loc(tile.width+4*5+20, 0, holder);
|
|
37344
|
+
that.add(holder, 0, true);
|
|
37345
|
+
|
|
37346
|
+
that.shield = new zim.Rectangle(tile.width+20, tile.height, dark).alp(.7).loc(tile, null, tile.parent);
|
|
37347
|
+
|
|
37348
|
+
Object.defineProperty(that, 'sliceType', {
|
|
37349
|
+
get: function() {
|
|
37350
|
+
return sliceType;
|
|
37351
|
+
},
|
|
37352
|
+
set: function(value) {
|
|
37353
|
+
sliceType = value;
|
|
37354
|
+
if (types.indexOf(sliceType) < 0) sliceType = "stretch";
|
|
37355
|
+
that.defaultIndex = types.indexOf(sliceType);
|
|
37356
|
+
}
|
|
37357
|
+
});
|
|
37358
|
+
|
|
37359
|
+
if (slicer) slicer.setSlicerTypes(that);
|
|
37360
|
+
|
|
37361
|
+
that.updateData = function(slices, types) {
|
|
37362
|
+
slices[0].unshift(0);
|
|
37363
|
+
slices[0].push(1);
|
|
37364
|
+
slices[1].unshift(0);
|
|
37365
|
+
slices[1].push(1);
|
|
37366
|
+
slicer.updateLines(slices);
|
|
37367
|
+
slicer.dataTypes = types;
|
|
37368
|
+
}
|
|
37369
|
+
|
|
37370
|
+
if (style!==false) zim.styleTransforms(this, DS);
|
|
37371
|
+
this.clone = function() {
|
|
37372
|
+
return that.cloneProps(new zim.SlicerTypes(slicer, titleBar, sliceType, style, this.group, inherit));
|
|
37373
|
+
};
|
|
37374
|
+
|
|
37375
|
+
}
|
|
37376
|
+
zim.extend(zim.SlicerTypes, zim.Window, ["clone"], "zimWindow", false);
|
|
37377
|
+
//-62.75
|
|
37378
|
+
|
|
35882
37379
|
/*--
|
|
35883
37380
|
zim.Dial = function(min, max, step, width, backgroundColor, indicatorColor, indicatorScale, indicatorType, useTicks, innerTicks, tickColor, tickStep, semiTicks, tickScale, semiTickScale, innerCircle, innerScale, innerColor, inner2Color, accentSize, accentOffset, accentColor, accentBackgroundColor, accentDifference, sound, linear, gap, limit, keyArrows, keyArrowsStep, keyArrowsH, keyArrowsV, continuous, continuousMin, continuousMax, damp, value, useLabels, labelMargin, addZero, currentValue, style, group, inherit);
|
|
35884
37381
|
|
|
@@ -37166,7 +38663,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
37166
38663
|
if (b && currentSelected) {
|
|
37167
38664
|
var ti = b.tabInfo;
|
|
37168
38665
|
if (ti && zot(ti.wait)) {
|
|
37169
|
-
// should be rollBackgroundColor but
|
|
38666
|
+
// should be rollBackgroundColor but setting it seems to stick after rolloff
|
|
37170
38667
|
if (ti.selectedBackgroundColor) b.backgroundColor = that.selected==b?ti.selectedBackgroundColor:ti.backgroundColor
|
|
37171
38668
|
if (ti.selectedColor && b.label) b.color = that.selected==b?ti.selectedColor:ti.color;
|
|
37172
38669
|
}
|
|
@@ -40338,8 +41835,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
40338
41835
|
if (zot(collapseColor)) collapseColor = DS.collapseColor!=null?DS.collapseColor:!zot(titleBarColor)?titleBarColor:zim.grey;
|
|
40339
41836
|
if (zot(collapsed)) collapsed=DS.collapsed!=null?DS.collapsed:false;
|
|
40340
41837
|
|
|
40341
|
-
// width, height, content, backgroundColor, borderColor, borderWidth, padding, corner, swipe, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, slide, slideFactor, slideSnap, slideSnapDamp, interactive, shadowColor, shadowBlur, paddingH, paddingV, scrollWheel, damp, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, draggable, boundary, onTop, close, closeColor, cancelCurrentDrag, fullSize, fullSizeColor, resizeHandle, collapse, collapseColor, collapsed, optimize, resizeBoundary, resizeVisible, continuous,
|
|
40342
|
-
this.zimWindow_constructor(width, height, null, backgroundColor, null, DS.borderWidth!=null?DS.borderWidth:2, DS.padding!=null?DS.padding:10, DS.corner!=null?DS.corner:10, null, DS.scrollBarActive!=null?DS.scrollBarActive:true, DS.scrollBarDrag!=null?DS.scrollBarDrag:true, null, null, null, false, null, null, null, null, null, true, null, null, null, null, null, null, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, DS.draggable!=null?DS.draggable:true, null, null, DS.close!=null?DS.close:true, null, null, DS.fullSize!=null?DS.fullSize:false, null, DS.resizeHandle!=null?DS.resizeHandle:false, collapse, collapseColor, collapsed, null, null, style, group, zim.copy(DS));
|
|
41838
|
+
// width, height, content, backgroundColor, borderColor, borderWidth, padding, corner, swipe, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, slide, slideFactor, slideSnap, slideSnapDamp, interactive, shadowColor, shadowBlur, paddingH, paddingV, scrollWheel, damp, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, draggable, boundary, onTop, close, closeColor, cancelCurrentDrag, fullSize, fullSizeColor, resizeHandle, collapse, collapseColor, collapsed, optimize, resizeBoundary, resizeVisible, continuous, style, group, inherit
|
|
41839
|
+
this.zimWindow_constructor(width, height, null, backgroundColor, null, DS.borderWidth!=null?DS.borderWidth:2, DS.padding!=null?DS.padding:10, DS.corner!=null?DS.corner:10, null, DS.scrollBarActive!=null?DS.scrollBarActive:true, DS.scrollBarDrag!=null?DS.scrollBarDrag:true, null, null, null, false, null, null, null, null, null, true, null, null, null, null, null, null, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, DS.draggable!=null?DS.draggable:true, null, null, DS.close!=null?DS.close:true, null, null, DS.fullSize!=null?DS.fullSize:false, null, DS.resizeHandle!=null?DS.resizeHandle:false, collapse, collapseColor, collapsed, null, null, null, null, style, group, zim.copy(DS));
|
|
40343
41840
|
this.type = "EmojiPicker";
|
|
40344
41841
|
var that = this;
|
|
40345
41842
|
|
|
@@ -45382,7 +46879,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
45382
46879
|
if (accept) uploadTag.setAttribute("accept", accept);
|
|
45383
46880
|
uploadTag.hidden = true;
|
|
45384
46881
|
uploadTag.zimDisplay = uploadTag.style.display || "inline-block";
|
|
45385
|
-
uploadTag.style.cssText = "border:thin solid grey; z-index:2; width:" +
|
|
46882
|
+
uploadTag.style.cssText = "border:thin solid grey; z-index:2; width:" + 0 + "px; height:" + 0 + "px; overflow:hidden; outline:none;"
|
|
45386
46883
|
+ "position:absolute; left:0px; top:0px; display:none; cursor:pointer; opacity: 0; filter: alpha(opacity=0);";
|
|
45387
46884
|
|
|
45388
46885
|
this.addEventListener('mousedown', function() { // added for zim.Accessibility
|
|
@@ -45975,19 +47472,48 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
45975
47472
|
}
|
|
45976
47473
|
var lastText = that.text;
|
|
45977
47474
|
var sYO = that.y;
|
|
47475
|
+
var lastHeight;
|
|
47476
|
+
that.taBlur = function() {
|
|
47477
|
+
if (WW.M && keyboardShift) {
|
|
47478
|
+
if (that.stage) {
|
|
47479
|
+
if (that.re) that.stage.frame.off("resize", that.re);
|
|
47480
|
+
that.stage.y = sYO;
|
|
47481
|
+
textareaTag.blur();
|
|
47482
|
+
that.resize();
|
|
47483
|
+
that.stage.update();
|
|
47484
|
+
}
|
|
47485
|
+
}
|
|
47486
|
+
if (that.stage) frame = that.stage.frame;
|
|
47487
|
+
if (frame.zil) WW.addEventListener("keydown", frame.zil[0]);
|
|
47488
|
+
that.dispatchEvent("blur");
|
|
47489
|
+
if (that.text != lastText) that.dispatchEvent("change");
|
|
47490
|
+
}
|
|
47491
|
+
function vvp() {
|
|
47492
|
+
if (M && !zot(lastHeight) && WW.visualViewport.height > lastHeight) {
|
|
47493
|
+
that.taBlur();
|
|
47494
|
+
WW.visualViewport.removeEventListener('resize', vvp);
|
|
47495
|
+
}
|
|
47496
|
+
lastHeight = WW.visualViewport.height;
|
|
47497
|
+
}
|
|
45978
47498
|
that.taFocus = function() {
|
|
45979
|
-
lastText = that.text;
|
|
47499
|
+
lastText = that.text;
|
|
45980
47500
|
if (WW.M && keyboardShift) {
|
|
45981
47501
|
if (that.re) that.stage.frame.off("resize", that.re);
|
|
45982
47502
|
that.re = that.stage.frame.on("resize", function(){
|
|
45983
47503
|
if (that.stage && h>that.stage.height/4) {
|
|
45984
47504
|
that.stage.y = that.stage.scaleY*(that.stage.height/4-h);
|
|
47505
|
+
that.resize();
|
|
45985
47506
|
that.stage.update();
|
|
45986
47507
|
}
|
|
45987
|
-
});
|
|
47508
|
+
});
|
|
47509
|
+
if (WW.visualViewport) {
|
|
47510
|
+
WW.visualViewport.removeEventListener('resize', vvp);
|
|
47511
|
+
WW.visualViewport.addEventListener('resize', vvp);
|
|
47512
|
+
}
|
|
45988
47513
|
var h = that.localToGlobal(0,0).y;
|
|
45989
47514
|
if (that.stage && h>that.stage.height/4) {
|
|
45990
47515
|
that.stage.y = that.stage.scaleY*(that.stage.height/4-h);
|
|
47516
|
+
that.resize();
|
|
45991
47517
|
that.stage.update();
|
|
45992
47518
|
}
|
|
45993
47519
|
}
|
|
@@ -45995,19 +47521,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
45995
47521
|
if (frame.zil) WW.removeEventListener("keydown", frame.zil[0]);
|
|
45996
47522
|
that.dispatchEvent("focus");
|
|
45997
47523
|
}
|
|
45998
|
-
|
|
45999
|
-
if (WW.M && keyboardShift) {
|
|
46000
|
-
if (that.stage) {
|
|
46001
|
-
if (that.re) that.stage.frame.off("resize", that.re);
|
|
46002
|
-
that.stage.y = sYO;
|
|
46003
|
-
that.stage.update();
|
|
46004
|
-
}
|
|
46005
|
-
}
|
|
46006
|
-
if (that.stage) frame = that.stage.frame;
|
|
46007
|
-
if (frame.zil) WW.addEventListener("keydown", frame.zil[0]);
|
|
46008
|
-
that.dispatchEvent("blur");
|
|
46009
|
-
if (that.text != lastText) that.dispatchEvent("change");
|
|
46010
|
-
}
|
|
47524
|
+
|
|
46011
47525
|
textareaTag.addEventListener('input', that.taInput);
|
|
46012
47526
|
textareaTag.addEventListener('focus', that.taFocus);
|
|
46013
47527
|
textareaTag.addEventListener('blur', that.taBlur);
|
|
@@ -46041,13 +47555,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
46041
47555
|
var displayProps = that.getConcatenatedMatrix().decompose();
|
|
46042
47556
|
var point = that.localToGlobal(padding, padding);
|
|
46043
47557
|
if (frame.retina) {
|
|
46044
|
-
var sc = zim.browserZoom();
|
|
47558
|
+
var sc = zim.browserZoom();
|
|
46045
47559
|
if (frame.tag) {
|
|
46046
47560
|
textarea.x = point.x/pRatio/sc;
|
|
46047
47561
|
textarea.y = point.y/pRatio/sc;
|
|
46048
47562
|
} else {
|
|
46049
|
-
|
|
46050
|
-
|
|
47563
|
+
var shiftX = (stage.x-stage.x/pRatio/sc)/frame.scale;
|
|
47564
|
+
var shiftY = (stage.y-stage.y/pRatio/sc)/frame.scale;
|
|
47565
|
+
textarea.x = frame.x/stage.scaleX + point.x/pRatio/sc - shiftX;
|
|
47566
|
+
textarea.y = frame.y/stage.scaleY + point.y/pRatio/sc - shiftY;
|
|
46051
47567
|
}
|
|
46052
47568
|
// CreateJS DOMElement is scaling tag as stage scales
|
|
46053
47569
|
zim.sca(textarea, displayProps.scaleX/pRatio/stage.scaleX/sc, displayProps.scaleY/pRatio/stage.scaleY/sc);
|
|
@@ -50546,7 +52062,7 @@ RETURNS obj for chaining
|
|
|
50546
52062
|
};//-33.18
|
|
50547
52063
|
|
|
50548
52064
|
/*--
|
|
50549
|
-
obj.transform = function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container)
|
|
52065
|
+
obj.transform = function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY)
|
|
50550
52066
|
|
|
50551
52067
|
transform
|
|
50552
52068
|
zim DisplayObject method
|
|
@@ -50639,6 +52155,12 @@ container (default stage) - set to a container to keep transforms within that co
|
|
|
50639
52155
|
normally leave as default so transforms will stay above other objects
|
|
50640
52156
|
but on occasion such as when using with ZIM TextureActives, a container is required
|
|
50641
52157
|
as the container is cached and used on a texture
|
|
52158
|
+
minScaleX (default null) - set a min scale in the x for the transform
|
|
52159
|
+
maxScaleX (default null) - set a max scale in the x for the transform
|
|
52160
|
+
minScaleY (default null) - set a min scale in the y for the transform
|
|
52161
|
+
maxScaleY (default null) - set a max scale in the y for the transform
|
|
52162
|
+
sliceX (default true) - this is for transforming ScaledBitmap objects in x - to use slicesWidth on edges. Set to false to use width.
|
|
52163
|
+
sliceY (default true) - this is for transforming ScaledBitmap objects in y - to use slicesWidth on edges. Set to false to use width.
|
|
50642
52164
|
|
|
50643
52165
|
PROPERTIES
|
|
50644
52166
|
toggled - adds a read-only Boolean to the object that is true if controls are showing otherwise false
|
|
@@ -50698,8 +52220,8 @@ If TransformManager() is used there are more events available such as "persistse
|
|
|
50698
52220
|
|
|
50699
52221
|
RETURNS obj for chaining
|
|
50700
52222
|
--*///+33.5
|
|
50701
|
-
zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container) {
|
|
50702
|
-
var sig = "obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container";
|
|
52223
|
+
zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY) {
|
|
52224
|
+
var sig = "obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY";
|
|
50703
52225
|
var duo; if (duo = zob(zim.transform, arguments, sig)) return duo;
|
|
50704
52226
|
if (obj.type=="AC"&&WW.zdf) {WW.zdf.ac("transform", arguments); return obj;}
|
|
50705
52227
|
z_d("33.5");
|
|
@@ -50745,6 +52267,14 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
50745
52267
|
if (zot(events)) events = false;
|
|
50746
52268
|
if (obj.type == "Tag" || obj.type == "TextArea" || obj.type == "Loader") events = true;
|
|
50747
52269
|
|
|
52270
|
+
if (zot(minScaleX)) minScaleX = -Number.MAX_VALUE;
|
|
52271
|
+
if (zot(maxScaleX)) maxScaleX = Number.MAX_VALUE;
|
|
52272
|
+
if (zot(minScaleY)) minScaleY = -Number.MAX_VALUE;
|
|
52273
|
+
if (zot(maxScaleY)) maxScaleY = Number.MAX_VALUE;
|
|
52274
|
+
|
|
52275
|
+
if (zot(sliceX)) sliceX = true;
|
|
52276
|
+
if (zot(sliceY)) sliceY = true;
|
|
52277
|
+
|
|
50748
52278
|
obj.zimMCO = obj.mouseChildren;
|
|
50749
52279
|
obj.mouseChildren = false;
|
|
50750
52280
|
var con = obj.getConcatenatedMatrix().decompose();
|
|
@@ -51034,6 +52564,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51034
52564
|
if (frame.ctrlKey && obj.transformControls.visible) {
|
|
51035
52565
|
obj.scaleX = 1;
|
|
51036
52566
|
obj.scaleY = 1;
|
|
52567
|
+
if (obj.type=="SlicedBitmap") {
|
|
52568
|
+
if (sliceX) obj.slicesScaleX = 1;
|
|
52569
|
+
if (sliceY) obj.slicesScaleY = 1;
|
|
52570
|
+
}
|
|
51037
52571
|
obj.rotation = 0;
|
|
51038
52572
|
// if (customCursors) moveCursor.rot(obj.rotation);
|
|
51039
52573
|
makeControls();
|
|
@@ -51090,6 +52624,8 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51090
52624
|
var startY; // target start y
|
|
51091
52625
|
var startSX;
|
|
51092
52626
|
var startSY;
|
|
52627
|
+
var startSSX; // for SlicedBitmap
|
|
52628
|
+
var startSSY;
|
|
51093
52629
|
var startR; // rotation of object to start
|
|
51094
52630
|
var startAngle; // angle of mouse down to x axis
|
|
51095
52631
|
var diffX;
|
|
@@ -51212,6 +52748,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51212
52748
|
objStartY = obj.y;
|
|
51213
52749
|
startSX = obj.scaleX;
|
|
51214
52750
|
startSY = obj.scaleY;
|
|
52751
|
+
if (obj.type=="SlicedBitmap") {
|
|
52752
|
+
startSSX = obj.slicesScaleX;
|
|
52753
|
+
startSSY = obj.slicesScaleY;
|
|
52754
|
+
}
|
|
51215
52755
|
var pp = container.globalToLocal(e.stageX/zim.scaX, e.stageY/zim.scaY);
|
|
51216
52756
|
if (e.target.controlType == "rotate") {
|
|
51217
52757
|
rotateCheck = true;
|
|
@@ -51264,11 +52804,13 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51264
52804
|
}
|
|
51265
52805
|
|
|
51266
52806
|
if (e.target.controlType == "corner") {
|
|
51267
|
-
obj.scaleX = scale * startSX;
|
|
51268
|
-
obj.scaleY = scale * startSY;
|
|
52807
|
+
obj.scaleX = zim.constrain(scale * startSX, minScaleX, maxScaleX);
|
|
52808
|
+
obj.scaleY = zim.constrain(scale * startSY, minScaleY, maxScaleY);
|
|
51269
52809
|
} else {
|
|
51270
|
-
obj.scaleX = (e.target.cu == "e-resize") ? scale * startSX : startSX;
|
|
51271
|
-
obj.
|
|
52810
|
+
if (obj.type != "SlicedBitmap" || !sliceX) obj.scaleX = zim.constrain((e.target.cu == "e-resize") ? scale * startSX : startSX, minScaleX, maxScaleX);
|
|
52811
|
+
else obj.ssX = zim.constrain((e.target.cu == "e-resize") ? scale * startSSX : startSSX, minScaleX, maxScaleX);
|
|
52812
|
+
if (obj.type != "SlicedBitmap" || !sliceY) obj.scaleY = zim.constrain((e.target.cu == "n-resize") ? scale * startSY : startSY, minScaleY, maxScaleY);
|
|
52813
|
+
else obj.ssY = zim.constrain((e.target.cu == "n-resize") ? scale * startSSY : startSSY, minScaleY, maxScaleY);
|
|
51272
52814
|
}
|
|
51273
52815
|
makeControls();
|
|
51274
52816
|
var pp = container.globalToLocal(e.stageX/zim.scaX, e.stageY/zim.scaY);
|
|
@@ -51343,7 +52885,12 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51343
52885
|
}
|
|
51344
52886
|
if (cursors) tCheck = squares.hitTestPoint(pp.x, pp.y);
|
|
51345
52887
|
} else if (type == "side") {
|
|
51346
|
-
if (
|
|
52888
|
+
if (
|
|
52889
|
+
obj.scaleX != startProperties.scaleX ||
|
|
52890
|
+
obj.scaleY != startProperties.scaleY ||
|
|
52891
|
+
(sliceX && obj.type=="SlicedBitmap" && obj.slicesScaleX != startProperties.slicesScaleX) ||
|
|
52892
|
+
(sliceY && obj.type=="SlicedBitmap" && obj.slicesScaleY != startProperties.slicesScaleY)
|
|
52893
|
+
) {
|
|
51347
52894
|
transformEvent = new createjs.Event("transformed");
|
|
51348
52895
|
transformEvent.transformType = "stretch";
|
|
51349
52896
|
}
|
|
@@ -51573,6 +53120,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51573
53120
|
|
|
51574
53121
|
function getStartProperies() {
|
|
51575
53122
|
startProperties = {x:obj.x, y:obj.y, rotation:obj.rotation, regX:obj.regX, regY:obj.regY, scaleX:obj.scaleX, scaleY:obj.scaleY};
|
|
53123
|
+
if (obj.type=="SlicedBitmap") {
|
|
53124
|
+
if (sliceX) startProperties.slicesScaleX = obj.slicesScaleX;
|
|
53125
|
+
if (sliceY) startProperties.slicesScaleY = obj.slicesScaleY;
|
|
53126
|
+
}
|
|
51576
53127
|
}
|
|
51577
53128
|
var startProperties;
|
|
51578
53129
|
getStartProperies();
|
|
@@ -51710,6 +53261,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51710
53261
|
regY:obj.regY,
|
|
51711
53262
|
controls:obj.transformControls.visible
|
|
51712
53263
|
};
|
|
53264
|
+
if (obj.type=="SlicedBitmap") {
|
|
53265
|
+
if (sliceX) data.slicesScaleX = obj.slicesScaleX;
|
|
53266
|
+
if (sliceY) data.slicesScaleY = obj.slicesScaleY;
|
|
53267
|
+
}
|
|
51713
53268
|
return toJSON ? JSON.stringify(data) : data;
|
|
51714
53269
|
},
|
|
51715
53270
|
setData:function(data, fromJSON) {
|
|
@@ -51770,7 +53325,7 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
|
|
|
51770
53325
|
makeControls();
|
|
51771
53326
|
drawDragger();
|
|
51772
53327
|
setRotators();
|
|
51773
|
-
if (visible) obj.transformControls.show(); // bring on top
|
|
53328
|
+
if (obj.transformControls.visible) obj.transformControls.show(); // bring on top
|
|
51774
53329
|
if (dispatch) {
|
|
51775
53330
|
var transformEvent = new createjs.Event("transformed");
|
|
51776
53331
|
transformEvent.pressup = true;
|
|
@@ -54189,6 +55744,11 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
54189
55744
|
}
|
|
54190
55745
|
sequenceTarget = target;
|
|
54191
55746
|
target = newTarget;
|
|
55747
|
+
sequenceTarget.animating = true;
|
|
55748
|
+
}
|
|
55749
|
+
function sequenceDone() {
|
|
55750
|
+
sequenceTarget.animating = false;
|
|
55751
|
+
if (call) call(params||sequenceTarget);
|
|
54192
55752
|
}
|
|
54193
55753
|
|
|
54194
55754
|
// PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
|
|
@@ -54232,8 +55792,10 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
54232
55792
|
rrr = rate + (tar.ratio?tar.ratio:0);
|
|
54233
55793
|
}
|
|
54234
55794
|
var seqTime = i*sequence;
|
|
54235
|
-
if (i==0 && sequence!=0) seqTime = timeType=="s"?.02:20; // patched in 10.7.0 and 10.7.1
|
|
54236
|
-
|
|
55795
|
+
if (i==0 && sequence!=0) seqTime = timeType=="s"?.02:20; // patched in 10.7.0 and 10.7.1
|
|
55796
|
+
|
|
55797
|
+
// zim.animate(tar, tar.zimObj, time, ease, (i==target.length-1?call:null), (i==target.length-1?params:null)
|
|
55798
|
+
zim.animate(tar, tar.zimObj, time, ease, (i==target.length-1?sequenceDone:null), null, wait, waitedCall, waitedParams, null, null, null, null, null, null, null, loopPick, null, null, null, null, null, null, rewindTime, rewindEase, startCall, startParams, animateCall, animateParams, null, sequenceCall, sequenceParams, null, null, ticker, zim.copy(cjsProps), css, protect, override, null, set, id, events, sequenceTarget, dynamic, drag, clamp, startPaused, clean, obj, seriesWait, seqTime, rrr, pauseOnBlur, easeAmount, easeFrequency, timeUnit, timeCheck, noAnimateCall, pathDamp); // do not send from!
|
|
54237
55799
|
|
|
54238
55800
|
}
|
|
54239
55801
|
return sequenceTarget;
|
|
@@ -54645,7 +56207,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
54645
56207
|
if (typeof target.zimLastObj[o] == "string" && o != "transform") {
|
|
54646
56208
|
target.zimLastObj[o] = target[o] + Number(target.zimLastObj[o].replace(/\s/g,""));
|
|
54647
56209
|
}
|
|
54648
|
-
setValue(target, o, target.zimLastObj[o]);
|
|
56210
|
+
setValue(target, o, target.zimLastObj[o]);
|
|
54649
56211
|
});
|
|
54650
56212
|
// zim.loop(obj, function (o) {
|
|
54651
56213
|
// if (typeof obj[o] == "string") {
|
|
@@ -54770,6 +56332,22 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
54770
56332
|
}
|
|
54771
56333
|
}
|
|
54772
56334
|
|
|
56335
|
+
|
|
56336
|
+
// moved these to before protect (to catch scale convert) - ZIM Cat
|
|
56337
|
+
// PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
|
|
56338
|
+
// moved to before color code - ZIM 017
|
|
56339
|
+
var savedPicks = {};
|
|
56340
|
+
for (i in obj) {
|
|
56341
|
+
// zogb(i)
|
|
56342
|
+
if (extraTypes.indexOf(i) >= 0) continue; // skip for extras
|
|
56343
|
+
savedPicks[i] = zim.copy(obj[i]); // store pre picked to use if loopPick is true
|
|
56344
|
+
obj[i] = zim.Pick.choose(obj[i], null, target);
|
|
56345
|
+
}
|
|
56346
|
+
if (!zot(obj.scale)) {
|
|
56347
|
+
obj.scaleX = obj.scaleY = zim.Pick.choose(obj.scale, null, target);
|
|
56348
|
+
delete obj.scale;
|
|
56349
|
+
}
|
|
56350
|
+
|
|
54773
56351
|
// convert color tween - added protect for colorRange in ZIM 016
|
|
54774
56352
|
var colorBusy = target.zimBusy && target.zimBusy.colorRange;
|
|
54775
56353
|
if (!colorBusy) {
|
|
@@ -54822,19 +56400,6 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
54822
56400
|
}
|
|
54823
56401
|
|
|
54824
56402
|
|
|
54825
|
-
// moved these to before protect (to catch scale convert) - ZIM Cat
|
|
54826
|
-
// PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
|
|
54827
|
-
var savedPicks = {};
|
|
54828
|
-
for (i in obj) {
|
|
54829
|
-
// zogb(i)
|
|
54830
|
-
if (extraTypes.indexOf(i) >= 0) continue; // skip for extras
|
|
54831
|
-
savedPicks[i] = zim.copy(obj[i]); // store pre picked to use if loopPick is true
|
|
54832
|
-
obj[i] = zim.Pick.choose(obj[i], null, target);
|
|
54833
|
-
}
|
|
54834
|
-
if (!zot(obj.scale)) {
|
|
54835
|
-
obj.scaleX = obj.scaleY = zim.Pick.choose(obj.scale, null, target);
|
|
54836
|
-
delete obj.scale;
|
|
54837
|
-
}
|
|
54838
56403
|
|
|
54839
56404
|
|
|
54840
56405
|
// PROTECT LOOPS AND REWINDS WITH BUSY
|
|
@@ -56265,18 +57830,24 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
56265
57830
|
return;
|
|
56266
57831
|
} else {
|
|
56267
57832
|
if (rewind) {
|
|
56268
|
-
if (target.set) target.set(startObj);
|
|
57833
|
+
if (target.set) target.set(startObj);
|
|
56269
57834
|
} else {
|
|
56270
57835
|
if (target.set) target.set(obj);
|
|
56271
57836
|
}
|
|
56272
57837
|
}
|
|
56273
|
-
} else {
|
|
57838
|
+
} else {
|
|
56274
57839
|
if (wait3>0) target.waiting = true;
|
|
56275
57840
|
doLoopWaitCall();
|
|
56276
57841
|
return;
|
|
56277
57842
|
}
|
|
56278
|
-
}
|
|
56279
|
-
|
|
57843
|
+
} else {
|
|
57844
|
+
if (rewind) {
|
|
57845
|
+
if (target.set) target.set(startObj);
|
|
57846
|
+
} else {
|
|
57847
|
+
if (target.set) target.set(obj);
|
|
57848
|
+
}
|
|
57849
|
+
}
|
|
57850
|
+
|
|
56280
57851
|
// ZIM 015 - this was the first thing we tried to scrub a series with percentComplete
|
|
56281
57852
|
// there were lots of other things too to make it work.
|
|
56282
57853
|
// Leaving the seriesTween test in here... but probably not doing much
|
|
@@ -56299,7 +57870,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
56299
57870
|
|
|
56300
57871
|
function getStart() {
|
|
56301
57872
|
// for rewind, we need to know the start value
|
|
56302
|
-
// which could be modified by the set parameter
|
|
57873
|
+
// which could be modified by the set parameter
|
|
56303
57874
|
for (var i in obj) {
|
|
56304
57875
|
if (css && target.style) {
|
|
56305
57876
|
if (!zot(set[i]) && !from) {
|
|
@@ -56310,7 +57881,6 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
56310
57881
|
}
|
|
56311
57882
|
} else {
|
|
56312
57883
|
if (!zot(set[i]) && !from) {
|
|
56313
|
-
// !!!!!! maybe fix for dot plugin
|
|
56314
57884
|
startObj[i] = set[i];
|
|
56315
57885
|
} else {
|
|
56316
57886
|
if (i.substr(0,1) == ".") {
|
|
@@ -60774,13 +62344,20 @@ EXAMPLE
|
|
|
60774
62344
|
new Arrow({type:"thick"}).pos(30,30,RIGHT,BOTTOM).tap(next);
|
|
60775
62345
|
END EXAMPLE
|
|
60776
62346
|
|
|
60777
|
-
EXAMPLE
|
|
60778
|
-
|
|
60779
|
-
|
|
60780
|
-
|
|
60781
|
-
|
|
60782
|
-
|
|
60783
|
-
|
|
62347
|
+
EXAMPLE
|
|
62348
|
+
const page2 = new Page(W,H,orange);
|
|
62349
|
+
const page3 = new Page(W,H,yellow);
|
|
62350
|
+
const pages = new Pages([page1,page2,page3], "slide").addTo();
|
|
62351
|
+
|
|
62352
|
+
const left = new Arrow({
|
|
62353
|
+
pages:pages,
|
|
62354
|
+
direction:LEFT
|
|
62355
|
+
}).rot(180).pos(50,50,LEFT,BOTTOM);
|
|
62356
|
+
|
|
62357
|
+
const right = new Arrow({
|
|
62358
|
+
pages:pages,
|
|
62359
|
+
direction:RIGHT
|
|
62360
|
+
}).pos(50,50,RIGHT,BOTTOM);
|
|
60784
62361
|
END EXAMPLE
|
|
60785
62362
|
|
|
60786
62363
|
PARAMETERS supports DUO - parameters or single object with properties below
|
|
@@ -62243,10 +63820,13 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
|
|
|
62243
63820
|
return that;
|
|
62244
63821
|
};
|
|
62245
63822
|
this.remove = function(obj) {
|
|
62246
|
-
if (
|
|
62247
|
-
|
|
62248
|
-
if (
|
|
62249
|
-
|
|
63823
|
+
if (zot(obj)) that.removeAllChildren();
|
|
63824
|
+
else {
|
|
63825
|
+
if (!Array.isArray(obj)) obj = [obj];
|
|
63826
|
+
zim.loop(obj, function(o) {
|
|
63827
|
+
if (o && o.removeFrom) o.removeFrom();
|
|
63828
|
+
}, true);
|
|
63829
|
+
}
|
|
62250
63830
|
that.resize();
|
|
62251
63831
|
return that;
|
|
62252
63832
|
};
|
|
@@ -63120,7 +64700,7 @@ current2DCols ** - read only array the current order of columns each containing
|
|
|
63120
64700
|
tileNum - this property is added to each object in the tile to give its number in the tile
|
|
63121
64701
|
tileCol - this property is added to each object in the tile to give its column number in the tile
|
|
63122
64702
|
tileRow - this property is added to each object in the tile to give its row number in the tile
|
|
63123
|
-
backgrounds - an array of ZIM Rectangle objects set by the
|
|
64703
|
+
backgrounds - an array of ZIM Rectangle objects set by the backgroundColor parameter
|
|
63124
64704
|
backings - an array of DisplayObjects set by the backing parameter
|
|
63125
64705
|
backdrop - a ZIM Rectangle set by the backdropColor parameter
|
|
63126
64706
|
mat - a DisplayObject set by the mat parameter
|
|
@@ -70666,32 +72246,35 @@ new MotionController({
|
|
|
70666
72246
|
END EXAMPLE
|
|
70667
72247
|
|
|
70668
72248
|
EXAMPLE
|
|
70669
|
-
|
|
70670
|
-
|
|
70671
|
-
const
|
|
70672
|
-
const
|
|
70673
|
-
|
|
70674
|
-
|
|
70675
|
-
|
|
70676
|
-
|
|
70677
|
-
|
|
70678
|
-
|
|
70679
|
-
|
|
70680
|
-
|
|
70681
|
-
|
|
70682
|
-
|
|
70683
|
-
|
|
70684
|
-
|
|
70685
|
-
|
|
70686
|
-
|
|
72249
|
+
F.loadAssets(["beach02.jpg", "playbeachball.png"], "https://zimjs.org/assets/"); // or load in Frame()
|
|
72250
|
+
F.on("complete", ()=>{
|
|
72251
|
+
const background = new Pic("beach02.jpg").scaleTo().center();
|
|
72252
|
+
const ball = new Pic("playbeachball.png").siz(100).centerReg();
|
|
72253
|
+
const scroller = new Scroller(background);
|
|
72254
|
+
const accelerator = new Accelerator(scroller);
|
|
72255
|
+
|
|
72256
|
+
// control speed of Accelerator with MotionController
|
|
72257
|
+
new MotionController({
|
|
72258
|
+
target:accelerator,
|
|
72259
|
+
type:"mousemove", // or "pressmove"
|
|
72260
|
+
axis:HORIZONTAL,
|
|
72261
|
+
// the Scroller makes two backings - backing1 and backing2
|
|
72262
|
+
// allow pressing on both backings and ball to control scroller
|
|
72263
|
+
mousedownIncludes:[scroller.backing1, scroller.backing2, ball],
|
|
72264
|
+
speed:30,
|
|
72265
|
+
minPercentSpeed:-1000,
|
|
72266
|
+
maxPercentSpeed:1000,
|
|
72267
|
+
boundary:new Boundary(0,0,W,0) // setting a boundary and speed will balance the control
|
|
72268
|
+
});
|
|
70687
72269
|
|
|
70688
|
-
// control position of ball with MotionController
|
|
70689
|
-
new MotionController({
|
|
70690
|
-
|
|
70691
|
-
|
|
70692
|
-
|
|
70693
|
-
|
|
70694
|
-
|
|
72270
|
+
// control position of ball with MotionController
|
|
72271
|
+
new MotionController({
|
|
72272
|
+
target:ball,
|
|
72273
|
+
type:"mousemove",
|
|
72274
|
+
// allow press on Scroller backings
|
|
72275
|
+
mousedownIncludes:[scroller.backing1, scroller.backing2],
|
|
72276
|
+
speed:10
|
|
72277
|
+
});
|
|
70695
72278
|
});
|
|
70696
72279
|
END EXAMPLE
|
|
70697
72280
|
|
|
@@ -73390,6 +74973,7 @@ veeObj - an object with ZIM VEE original parameters:value allowing the ZIM VEE v
|
|
|
73390
74973
|
|
|
73391
74974
|
blurX = zik(blurX); // inherits these properties
|
|
73392
74975
|
blurY = zik(blurY);
|
|
74976
|
+
if (blurX === 0 && blurY === 0) blurX = 1;
|
|
73393
74977
|
quality = zik(quality);
|
|
73394
74978
|
|
|
73395
74979
|
color = zik(color); // will convert after setting color getter setter
|
|
@@ -76295,19 +77879,18 @@ and animate and swap the backgrounds when needed.
|
|
|
76295
77879
|
|
|
76296
77880
|
NOTE: A scroller can be added to a Accelerator object
|
|
76297
77881
|
this will allow the percentSpeed to be synched with other Scroller and Dynamo objects
|
|
76298
|
-
See https://zimjs.com/zide/
|
|
76299
|
-
See https://zimjs.com/
|
|
77882
|
+
See https://zimjs.com/zide/ - full scene
|
|
77883
|
+
See https://zimjs.com/zapp/E_EPRSP - Flinstones
|
|
77884
|
+
See https://zimjs.com/zapp/Z_6EEB5 - beach
|
|
77885
|
+
See https://zimjs.com/zapp/Z_ZCDQN - spaceguy
|
|
77886
|
+
See https://zimjs.com/zapp/Z_UC7DN - keyboard
|
|
76300
77887
|
|
|
76301
77888
|
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
76302
77889
|
|
|
76303
77890
|
EXAMPLE
|
|
76304
|
-
const one = new Rectangle(
|
|
77891
|
+
const one = new Rectangle(1100, 400, red).center();
|
|
76305
77892
|
F.makeCircles().center(one);
|
|
76306
|
-
|
|
76307
|
-
|
|
76308
|
-
const scroller = new Scroller(one);
|
|
76309
|
-
|
|
76310
|
-
S.update();
|
|
77893
|
+
const scroller = new Scroller(one,20);
|
|
76311
77894
|
END EXAMPLE
|
|
76312
77895
|
|
|
76313
77896
|
PARAMETERS
|
|
@@ -88415,9 +89998,9 @@ function zimify(obj, a, b, c, d, list) {
|
|
|
88415
89998
|
dragRect:function(boundary) {
|
|
88416
89999
|
return zim.dragBoundary(this, boundary);
|
|
88417
90000
|
},
|
|
88418
|
-
transform:function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container) {
|
|
90001
|
+
transform:function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY) {
|
|
88419
90002
|
if (isDUO(arguments)) {arguments[0].obj = this; return zim.transform(arguments[0]);}
|
|
88420
|
-
else {return zim.transform(this, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container);}
|
|
90003
|
+
else {return zim.transform(this, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY);}
|
|
88421
90004
|
},
|
|
88422
90005
|
setSwipe:function(swipe) {
|
|
88423
90006
|
return zim.setSwipe(this, swipe);
|
|
@@ -93724,16 +95307,16 @@ for (z_i = 0; z_i < globalFunctions.length; z_i++) {
|
|
|
93724
95307
|
["RAD", zim.RAD],
|
|
93725
95308
|
["PHI", zim.PHI],
|
|
93726
95309
|
["IGNORE", zim.ignore]
|
|
93727
|
-
|
|
93728
|
-
|
|
93729
|
-
|
|
95310
|
+
];
|
|
95311
|
+
|
|
95312
|
+
for (z_i = 0; z_i < globalsConstants.length; z_i++) {
|
|
93730
95313
|
var pair = globalsConstants[z_i];
|
|
93731
95314
|
WW[pair[0]] = pair[1];
|
|
93732
|
-
|
|
93733
|
-
|
|
93734
|
-
|
|
95315
|
+
}
|
|
95316
|
+
|
|
95317
|
+
for (z_i = 0; z_i < zim.colors.length; z_i++) {
|
|
93735
95318
|
WW[zim.colors[z_i]] = zim.colorsHex[z_i];
|
|
93736
|
-
|
|
95319
|
+
}
|
|
93737
95320
|
|
|
93738
95321
|
|
|
93739
95322
|
WW.zim = zim;
|
|
@@ -93837,6 +95420,7 @@ export let StageGL = zim.StageGL;
|
|
|
93837
95420
|
export let Container = zim.Container;
|
|
93838
95421
|
export let Shape = zim.Shape;
|
|
93839
95422
|
export let Bitmap = zim.Bitmap;
|
|
95423
|
+
export let SlicedBitmap = zim.SlicedBitmap;
|
|
93840
95424
|
export let Sprite = zim.Sprite;
|
|
93841
95425
|
export let MovieClip = zim.MovieClip;
|
|
93842
95426
|
export let SVGContainer = zim.SVGContainer;
|
|
@@ -93881,6 +95465,8 @@ export let List = zim.List;
|
|
|
93881
95465
|
export let Stepper = zim.Stepper;
|
|
93882
95466
|
export let Slider = zim.Slider;
|
|
93883
95467
|
export let Selector = zim.Selector;
|
|
95468
|
+
export let Slicer = zim.Slicer;
|
|
95469
|
+
export let SlicerTypes = zim.SlicerTypes;
|
|
93884
95470
|
export let Dial = zim.Dial;
|
|
93885
95471
|
export let Tabs = zim.Tabs;
|
|
93886
95472
|
export let Pad = zim.Pad;
|