@@ -220,63 +220,6 @@ this.createjs = this.createjs||{};
220220 return this ;
221221 } ;
222222
223- /**
224- * Prepends the specified matrix properties to this matrix.
225- * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.
226- * All parameters are required.
227- * @method prepend
228- * @param {Number } a
229- * @param {Number } b
230- * @param {Number } c
231- * @param {Number } d
232- * @param {Number } tx
233- * @param {Number } ty
234- * @return {Matrix2D } This matrix. Useful for chaining method calls.
235- **/
236- p . prepend = function ( a , b , c , d , tx , ty ) {
237- var a1 = this . a ;
238- var c1 = this . c ;
239- var tx1 = this . tx ;
240-
241- this . a = a * a1 + c * this . b ;
242- this . b = b * a1 + d * this . b ;
243- this . c = a * c1 + c * this . d ;
244- this . d = b * c1 + d * this . d ;
245- this . tx = a * tx1 + c * this . ty + tx ;
246- this . ty = b * tx1 + d * this . ty + ty ;
247- return this ;
248- } ;
249-
250- /**
251- * Appends the specified matrix to this matrix.
252- * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.
253- * @method appendMatrix
254- * @param {Matrix2D } matrix
255- * @return {Matrix2D } This matrix. Useful for chaining method calls.
256- **/
257- p . appendMatrix = function ( matrix ) {
258- return this . append ( matrix . a , matrix . b , matrix . c , matrix . d , matrix . tx , matrix . ty ) ;
259- } ;
260-
261- /**
262- * Prepends the specified matrix to this matrix.
263- * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.
264- * For example, you could calculate the combined transformation for a child object using:
265- *
266- * var o = myDisplayObject;
267- * var mtx = o.getMatrix();
268- * while (o = o.parent) {
269- * // prepend each parent's transformation in turn:
270- * o.prependMatrix(o.getMatrix());
271- * }
272- * @method prependMatrix
273- * @param {Matrix2D } matrix
274- * @return {Matrix2D } This matrix. Useful for chaining method calls.
275- **/
276- p . prependMatrix = function ( matrix ) {
277- return this . prepend ( matrix . a , matrix . b , matrix . c , matrix . d , matrix . tx , matrix . ty ) ;
278- } ;
279-
280223 /**
281224 * Generates matrix properties from the specified display object transform properties, and appends them to this matrix.
282225 * For example, you can use this to generate a matrix representing the transformations of a display object:
@@ -323,122 +266,6 @@ this.createjs = this.createjs||{};
323266 return this ;
324267 } ;
325268
326- /**
327- * Generates matrix properties from the specified display object transform properties, and prepends them to this matrix.
328- * For example, you could calculate the combined transformation for a child object using:
329- *
330- * var o = myDisplayObject;
331- * var mtx = new createjs.Matrix2D();
332- * do {
333- * // prepend each parent's transformation in turn:
334- * mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
335- * } while (o = o.parent);
336- *
337- * Note that the above example would not account for {{#crossLink "DisplayObject/transformMatrix:property"}}{{/crossLink}}
338- * values. See {{#crossLink "Matrix2D/prependMatrix"}}{{/crossLink}} for an example that does.
339- * @method prependTransform
340- * @param {Number } x
341- * @param {Number } y
342- * @param {Number } scaleX
343- * @param {Number } scaleY
344- * @param {Number } rotation
345- * @param {Number } skewX
346- * @param {Number } skewY
347- * @param {Number } regX Optional.
348- * @param {Number } regY Optional.
349- * @return {Matrix2D } This matrix. Useful for chaining method calls.
350- **/
351- p . prependTransform = function ( x , y , scaleX , scaleY , rotation , skewX , skewY , regX , regY ) {
352- if ( rotation % 360 ) {
353- var r = rotation * Matrix2D . DEG_TO_RAD ;
354- var cos = Math . cos ( r ) ;
355- var sin = Math . sin ( r ) ;
356- } else {
357- cos = 1 ;
358- sin = 0 ;
359- }
360-
361- if ( regX || regY ) {
362- // prepend the registration offset:
363- this . tx -= regX ; this . ty -= regY ;
364- }
365- if ( skewX || skewY ) {
366- // TODO: can this be combined into a single prepend operation?
367- skewX *= Matrix2D . DEG_TO_RAD ;
368- skewY *= Matrix2D . DEG_TO_RAD ;
369- this . prepend ( cos * scaleX , sin * scaleX , - sin * scaleY , cos * scaleY , 0 , 0 ) ;
370- this . prepend ( Math . cos ( skewY ) , Math . sin ( skewY ) , - Math . sin ( skewX ) , Math . cos ( skewX ) , x , y ) ;
371- } else {
372- this . prepend ( cos * scaleX , sin * scaleX , - sin * scaleY , cos * scaleY , x , y ) ;
373- }
374- return this ;
375- } ;
376-
377- /**
378- * Applies a clockwise rotation transformation to the matrix.
379- * @method rotate
380- * @param {Number } angle The angle to rotate by, in degrees. To use a value in radians, multiply it by `180/Math.PI`.
381- * @return {Matrix2D } This matrix. Useful for chaining method calls.
382- **/
383- p . rotate = function ( angle ) {
384- angle = angle * Matrix2D . DEG_TO_RAD ;
385- var cos = Math . cos ( angle ) ;
386- var sin = Math . sin ( angle ) ;
387-
388- var a1 = this . a ;
389- var b1 = this . b ;
390-
391- this . a = a1 * cos + this . c * sin ;
392- this . b = b1 * cos + this . d * sin ;
393- this . c = - a1 * sin + this . c * cos ;
394- this . d = - b1 * sin + this . d * cos ;
395- return this ;
396- } ;
397-
398- /**
399- * Applies a skew transformation to the matrix.
400- * @method skew
401- * @param {Number } skewX The amount to skew horizontally in degrees. To use a value in radians, multiply it by `180/Math.PI`.
402- * @param {Number } skewY The amount to skew vertically in degrees.
403- * @return {Matrix2D } This matrix. Useful for chaining method calls.
404- */
405- p . skew = function ( skewX , skewY ) {
406- skewX = skewX * Matrix2D . DEG_TO_RAD ;
407- skewY = skewY * Matrix2D . DEG_TO_RAD ;
408- this . append ( Math . cos ( skewY ) , Math . sin ( skewY ) , - Math . sin ( skewX ) , Math . cos ( skewX ) , 0 , 0 ) ;
409- return this ;
410- } ;
411-
412- /**
413- * Applies a scale transformation to the matrix.
414- * @method scale
415- * @param {Number } x The amount to scale horizontally. E.G. a value of 2 will double the size in the X direction, and 0.5 will halve it.
416- * @param {Number } y The amount to scale vertically.
417- * @return {Matrix2D } This matrix. Useful for chaining method calls.
418- **/
419- p . scale = function ( x , y ) {
420- this . a *= x ;
421- this . b *= x ;
422- this . c *= y ;
423- this . d *= y ;
424- //this.tx *= x;
425- //this.ty *= y;
426- return this ;
427- } ;
428-
429- /**
430- * Translates the matrix on the x and y axes.
431- * @method translate
432- * @param {Number } x
433- * @param {Number } y
434- * @return {Matrix2D } This matrix. Useful for chaining method calls.
435- **/
436- p . translate = function ( x , y ) {
437- this . tx += this . a * x + this . c * y ;
438- this . ty += this . b * x + this . d * y ;
439- return this ;
440- } ;
441-
442269 /**
443270 * Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).
444271 * @method identity
@@ -450,62 +277,6 @@ this.createjs = this.createjs||{};
450277 return this ;
451278 } ;
452279
453- /**
454- * Inverts the matrix, causing it to perform the opposite transformation.
455- * @method invert
456- * @return {Matrix2D } This matrix. Useful for chaining method calls.
457- **/
458- p . invert = function ( ) {
459- var a1 = this . a ;
460- var b1 = this . b ;
461- var c1 = this . c ;
462- var d1 = this . d ;
463- var tx1 = this . tx ;
464- var n = a1 * d1 - b1 * c1 ;
465-
466- this . a = d1 / n ;
467- this . b = - b1 / n ;
468- this . c = - c1 / n ;
469- this . d = a1 / n ;
470- this . tx = ( c1 * this . ty - d1 * tx1 ) / n ;
471- this . ty = - ( a1 * this . ty - b1 * tx1 ) / n ;
472- return this ;
473- } ;
474-
475- /**
476- * Returns true if the matrix is an identity matrix.
477- * @method isIdentity
478- * @return {Boolean }
479- **/
480- p . isIdentity = function ( ) {
481- return this . tx === 0 && this . ty === 0 && this . a === 1 && this . b === 0 && this . c === 0 && this . d === 1 ;
482- } ;
483-
484- /**
485- * Returns true if this matrix is equal to the specified matrix (all property values are equal).
486- * @method equals
487- * @param {Matrix2D } matrix The matrix to compare.
488- * @return {Boolean }
489- **/
490- p . equals = function ( matrix ) {
491- return this . tx === matrix . tx && this . ty === matrix . ty && this . a === matrix . a && this . b === matrix . b && this . c === matrix . c && this . d === matrix . d ;
492- } ;
493-
494- /**
495- * Transforms a point according to this matrix.
496- * @method transformPoint
497- * @param {Number } x The x component of the point to transform.
498- * @param {Number } y The y component of the point to transform.
499- * @param {Point | Object } [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
500- * @return {Point } This matrix. Useful for chaining method calls.
501- **/
502- p . transformPoint = function ( x , y , pt ) {
503- pt = pt || { } ;
504- pt . x = x * this . a + y * this . c + this . tx ;
505- pt . y = x * this . b + y * this . d + this . ty ;
506- return pt ;
507- } ;
508-
509280 // this has to be populated after the class is defined:
510281 Matrix2D . identity = new Matrix2D ( ) ;
511282
@@ -1369,7 +1140,6 @@ this.createjs = this.createjs||{};
13691140 this . _spacing = o . spacing || 0 ;
13701141 this . _margin = o . margin || 0 ;
13711142 this . _numFrames = o . count ;
1372- if ( this . _loadCount == 0 ) { this . _calculateFrames ( ) ; }
13731143 }
13741144
13751145 // parse animations:
@@ -1407,71 +1177,6 @@ this.createjs = this.createjs||{};
14071177 }
14081178 } ;
14091179
1410- /**
1411- * @method _handleImageLoad
1412- * @protected
1413- **/
1414- p . _handleImageLoad = function ( src ) {
1415- if ( -- this . _loadCount == 0 ) {
1416- this . _calculateFrames ( ) ;
1417- this . complete = true ;
1418- this . dispatchEvent ( "complete" ) ;
1419- }
1420- } ;
1421-
1422- /**
1423- * @method _handleImageError
1424- * @protected
1425- */
1426- p . _handleImageError = function ( src ) {
1427- var errorEvent = new createjs . Event ( "error" ) ;
1428- errorEvent . src = src ;
1429- this . dispatchEvent ( errorEvent ) ;
1430-
1431- // Complete is still dispatched.
1432- if ( -- this . _loadCount == 0 ) {
1433- this . dispatchEvent ( "complete" ) ;
1434- }
1435- } ;
1436-
1437- /**
1438- * @method _calculateFrames
1439- * @protected
1440- **/
1441- p . _calculateFrames = function ( ) {
1442- if ( this . _frames || this . _frameWidth == 0 ) { return ; }
1443-
1444- this . _frames = [ ] ;
1445-
1446- var maxFrames = this . _numFrames || 100000 ; // if we go over this, something is wrong.
1447- var frameCount = 0 , frameWidth = this . _frameWidth , frameHeight = this . _frameHeight ;
1448- var spacing = this . _spacing , margin = this . _margin ;
1449-
1450- imgLoop:
1451- for ( var i = 0 , imgs = this . _images ; i < imgs . length ; i ++ ) {
1452- var img = imgs [ i ] , imgW = ( img . width || img . naturalWidth ) , imgH = ( img . height || img . naturalHeight ) ;
1453-
1454- var y = margin ;
1455- while ( y <= imgH - margin - frameHeight ) {
1456- var x = margin ;
1457- while ( x <= imgW - margin - frameWidth ) {
1458- if ( frameCount >= maxFrames ) { break imgLoop; }
1459- frameCount ++ ;
1460- this . _frames . push ( {
1461- image : img ,
1462- rect : new createjs . Rectangle ( x , y , frameWidth , frameHeight ) ,
1463- regX : this . _regX ,
1464- regY : this . _regY
1465- } ) ;
1466- x += frameWidth + spacing ;
1467- }
1468- y += frameHeight + spacing ;
1469- }
1470- }
1471- this . _numFrames = frameCount ;
1472- } ;
1473-
1474-
14751180 createjs . SpriteSheet = createjs . promote ( SpriteSheet , "EventDispatcher" ) ;
14761181} ( ) ) ;
14771182
@@ -1696,68 +1401,6 @@ this.createjs = this.createjs||{};
16961401 var p = Graphics . prototype ;
16971402 var G = Graphics ; // shortcut
16981403
1699- // static public methods:
1700- /**
1701- * Returns a CSS compatible color string based on the specified RGB numeric color values in the format
1702- * "rgba(255,255,255,1.0)", or if alpha is null then in the format "rgb(255,255,255)". For example,
1703- *
1704- * createjs.Graphics.getRGB(50, 100, 150, 0.5);
1705- * // Returns "rgba(50,100,150,0.5)"
1706- *
1707- * It also supports passing a single hex color value as the first param, and an optional alpha value as the second
1708- * param. For example,
1709- *
1710- * createjs.Graphics.getRGB(0xFF00FF, 0.2);
1711- * // Returns "rgba(255,0,255,0.2)"
1712- *
1713- * @method getRGB
1714- * @static
1715- * @param {Number } r The red component for the color, between 0 and 0xFF (255).
1716- * @param {Number } g The green component for the color, between 0 and 0xFF (255).
1717- * @param {Number } b The blue component for the color, between 0 and 0xFF (255).
1718- * @param {Number } [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.
1719- * @return {String } A CSS compatible color string based on the specified RGB numeric color values in the format
1720- * "rgba(255,255,255,1.0)", or if alpha is null then in the format "rgb(255,255,255)".
1721- **/
1722- Graphics . getRGB = function ( r , g , b , alpha ) {
1723- if ( r != null && b == null ) {
1724- alpha = g ;
1725- b = r & 0xFF ;
1726- g = r >> 8 & 0xFF ;
1727- r = r >> 16 & 0xFF ;
1728- }
1729- if ( alpha == null ) {
1730- return "rgb(" + r + "," + g + "," + b + ")" ;
1731- } else {
1732- return "rgba(" + r + "," + g + "," + b + "," + alpha + ")" ;
1733- }
1734- } ;
1735-
1736- /**
1737- * Returns a CSS compatible color string based on the specified HSL numeric color values in the format "hsla(360,100,100,1.0)",
1738- * or if alpha is null then in the format "hsl(360,100,100)".
1739- *
1740- * createjs.Graphics.getHSL(150, 100, 70);
1741- * // Returns "hsl(150,100,70)"
1742- *
1743- * @method getHSL
1744- * @static
1745- * @param {Number } hue The hue component for the color, between 0 and 360.
1746- * @param {Number } saturation The saturation component for the color, between 0 and 100.
1747- * @param {Number } lightness The lightness component for the color, between 0 and 100.
1748- * @param {Number } [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.
1749- * @return {String } A CSS compatible color string based on the specified HSL numeric color values in the format
1750- * "hsla(360,100,100,1.0)", or if alpha is null then in the format "hsl(360,100,100)".
1751- **/
1752- Graphics . getHSL = function ( hue , saturation , lightness , alpha ) {
1753- if ( alpha == null ) {
1754- return "hsl(" + ( hue % 360 ) + "," + saturation + "%," + lightness + "%)" ;
1755- } else {
1756- return "hsla(" + ( hue % 360 ) + "," + saturation + "%," + lightness + "%," + alpha + ")" ;
1757- }
1758- } ;
1759-
1760-
17611404// static properties:
17621405 /**
17631406 * A reusable instance of {{#crossLink "Graphics/BeginPath"}}{{/crossLink}} to avoid
0 commit comments