@@ -11,63 +11,60 @@ var MinMax2 = new Class({
1111
1212 initialize :
1313
14- function MinMax2 ( min , max )
14+ function MinMax2 ( min , max , steps )
1515 {
16- if ( Array . isArray ( min ) )
17- {
18- max = min [ 1 ] ;
19- min = min [ 0 ] ;
20- }
21- else if ( typeof min === 'object' )
22- {
23- var obj = min ;
16+ this . min = 0 ;
17+ this . max = 0 ;
18+ this . steps = 0 ;
2419
25- min = ( obj . hasOwnProperty ( 'x' ) ) ? obj . x : obj . min ;
26- max = ( obj . hasOwnProperty ( 'y' ) ) ? obj . y : obj . max ;
27- }
20+ this . _current = 0 ;
2821
29- if ( min === undefined ) { min = 0 ; }
30- if ( max === undefined ) { max = min ; }
31-
32- this . min = min ;
33- this . max = max ;
34-
35- this . _current = min ;
22+ if ( min !== undefined )
23+ {
24+ this . set ( min , max , steps ) ;
25+ }
3626 } ,
3727
38- set : function ( min , max )
28+ set : function ( min , max , steps )
3929 {
4030 if ( Array . isArray ( min ) )
4131 {
32+ steps = min [ 2 ] ;
4233 max = min [ 1 ] ;
4334 min = min [ 0 ] ;
4435 }
4536 else if ( typeof min === 'object' )
4637 {
4738 var obj = min ;
4839
49- min = obj . min ;
50- max = obj . max ;
40+ min = ( obj . hasOwnProperty ( 'x' ) ) ? obj . x : obj . min ;
41+ max = ( obj . hasOwnProperty ( 'y' ) ) ? obj . y : obj . max ;
42+ steps = obj . steps ;
5143 }
5244
5345 if ( min === undefined ) { min = 0 ; }
5446 if ( max === undefined ) { max = min ; }
47+ if ( steps === undefined ) { steps = 0 ; }
5548
5649 this . min = min ;
5750 this . max = max ;
51+ this . steps = steps ;
52+
53+ this . _current = min ;
5854
5955 return this ;
6056 } ,
6157
6258 clone : function ( )
6359 {
64- return new MinMax2 ( this . min , this . max ) ;
60+ return new MinMax2 ( this . min , this . max , this . steps ) ;
6561 } ,
6662
6763 copy : function ( dest )
6864 {
6965 dest . min = this . min ;
7066 dest . max = this . max ;
67+ dest . steps = this . steps ;
7168
7269 return this ;
7370 } ,
@@ -110,6 +107,46 @@ var MinMax2 = new Class({
110107 return FloatBetween ( this . min , this . max ) ;
111108 } ,
112109
110+ getNext : function ( )
111+ {
112+ var value ;
113+
114+ if ( this . steps > 0 )
115+ {
116+ value = this . _current ;
117+
118+ var i = value + ( ( this . max - this . min ) / this . steps ) ;
119+
120+ this . _current = Wrap ( i , this . min , this . max ) ;
121+ }
122+ else
123+ {
124+ value = this . getRandom ( ) ;
125+ }
126+
127+ return value ;
128+ } ,
129+
130+ getNextFloat : function ( )
131+ {
132+ var value ;
133+
134+ if ( this . steps > 0 )
135+ {
136+ value = this . _current ;
137+
138+ var i = value + ( ( this . max - this . min ) / this . steps ) ;
139+
140+ this . _current = Wrap ( i , this . min , this . max ) ;
141+ }
142+ else
143+ {
144+ value = this . getRandomFloat ( ) ;
145+ }
146+
147+ return value ;
148+ } ,
149+
113150 current : {
114151
115152 get : function ( )
0 commit comments