@@ -506,67 +506,6 @@ this.createjs = this.createjs||{};
506506 return pt ;
507507 } ;
508508
509- /**
510- * Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values
511- * may not match the transform properties you used to generate the matrix, though they will produce the same visual
512- * results.
513- * @method decompose
514- * @param {Object } target The object to apply the transform properties to. If null, then a new object will be returned.
515- * @return {Object } The target, or a new generic object with the transform properties applied.
516- */
517- p . decompose = function ( target ) {
518- // TODO: it would be nice to be able to solve for whether the matrix can be decomposed into only scale/rotation even when scale is negative
519- if ( target == null ) { target = { } ; }
520- target . x = this . tx ;
521- target . y = this . ty ;
522- target . scaleX = Math . sqrt ( this . a * this . a + this . b * this . b ) ;
523- target . scaleY = Math . sqrt ( this . c * this . c + this . d * this . d ) ;
524-
525- var skewX = Math . atan2 ( - this . c , this . d ) ;
526- var skewY = Math . atan2 ( this . b , this . a ) ;
527-
528- var delta = Math . abs ( 1 - skewX / skewY ) ;
529- if ( delta < 0.00001 ) { // effectively identical, can use rotation:
530- target . rotation = skewY / Matrix2D . DEG_TO_RAD ;
531- if ( this . a < 0 && this . d >= 0 ) {
532- target . rotation += ( target . rotation <= 0 ) ? 180 : - 180 ;
533- }
534- target . skewX = target . skewY = 0 ;
535- } else {
536- target . skewX = skewX / Matrix2D . DEG_TO_RAD ;
537- target . skewY = skewY / Matrix2D . DEG_TO_RAD ;
538- }
539- return target ;
540- } ;
541-
542- /**
543- * Copies all properties from the specified matrix to this matrix.
544- * @method copy
545- * @param {Matrix2D } matrix The matrix to copy properties from.
546- * @return {Matrix2D } This matrix. Useful for chaining method calls.
547- */
548- p . copy = function ( matrix ) {
549- return this . setValues ( matrix . a , matrix . b , matrix . c , matrix . d , matrix . tx , matrix . ty ) ;
550- } ;
551-
552- /**
553- * Returns a clone of the Matrix2D instance.
554- * @method clone
555- * @return {Matrix2D } a clone of the Matrix2D instance.
556- **/
557- p . clone = function ( ) {
558- return new Matrix2D ( this . a , this . b , this . c , this . d , this . tx , this . ty ) ;
559- } ;
560-
561- /**
562- * Returns a string representation of this object.
563- * @method toString
564- * @return {String } a string representation of the instance.
565- **/
566- p . toString = function ( ) {
567- return "[Matrix2D (a=" + this . a + " b=" + this . b + " c=" + this . c + " d=" + this . d + " tx=" + this . tx + " ty=" + this . ty + ")]" ;
568- } ;
569-
570509 // this has to be populated after the class is defined:
571510 Matrix2D . identity = new Matrix2D ( ) ;
572511
@@ -2197,58 +2136,6 @@ this.createjs = this.createjs||{};
21972136 return this . beginFill ( ) ;
21982137 } ;
21992138
2200- /**
2201- * Sets the stroke style. Like all drawing methods, this can be chained, so you can define
2202- * the stroke style and color in a single line of code like so:
2203- *
2204- * myGraphics.setStrokeStyle(8,"round").beginStroke("#F00");
2205- *
2206- * A tiny API method "ss" also exists.
2207- * @method setStrokeStyle
2208- * @param {Number } thickness The width of the stroke.
2209- * @param {String | Number } [caps=0] Indicates the type of caps to use at the end of lines. One of butt,
2210- * round, or square. Defaults to "butt". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with
2211- * the tiny API.
2212- * @param {String | Number } [joints=0] Specifies the type of joints that should be used where two lines meet.
2213- * One of bevel, round, or miter. Defaults to "miter". Also accepts the values 0 (miter), 1 (round), and 2 (bevel)
2214- * for use with the tiny API.
2215- * @param {Number } [miterLimit=10] If joints is set to "miter", then you can specify a miter limit ratio which
2216- * controls at what point a mitered joint will be clipped.
2217- * @param {Boolean } [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless
2218- * of active transformations.
2219- * @return {Graphics } The Graphics instance the method is called on (useful for chaining calls.)
2220- * @chainable
2221- **/
2222- p . setStrokeStyle = function ( thickness , caps , joints , miterLimit , ignoreScale ) {
2223- this . _updateInstructions ( true ) ;
2224- this . _strokeStyle = this . command = new G . StrokeStyle ( thickness , caps , joints , miterLimit , ignoreScale ) ;
2225-
2226- // ignoreScale lives on Stroke, not StrokeStyle, so we do a little trickery:
2227- if ( this . _stroke ) { this . _stroke . ignoreScale = ignoreScale ; }
2228- this . _strokeIgnoreScale = ignoreScale ;
2229- return this ;
2230- } ;
2231-
2232- /**
2233- * Sets or clears the stroke dash pattern.
2234- *
2235- * myGraphics.setStrokeDash([20, 10], 0);
2236- *
2237- * A tiny API method `sd` also exists.
2238- * @method setStrokeDash
2239- * @param {Array } [segments] An array specifying the dash pattern, alternating between line and gap.
2240- * For example, `[20,10]` would create a pattern of 20 pixel lines with 10 pixel gaps between them.
2241- * Passing null or an empty array will clear the existing stroke dash.
2242- * @param {Number } [offset=0] The offset of the dash pattern. For example, you could increment this value to create a "marching ants" effect.
2243- * @return {Graphics } The Graphics instance the method is called on (useful for chaining calls.)
2244- * @chainable
2245- **/
2246- p . setStrokeDash = function ( segments , offset ) {
2247- this . _updateInstructions ( true ) ;
2248- this . _strokeDash = this . command = new G . StrokeDash ( segments , offset ) ;
2249- return this ;
2250- } ;
2251-
22522139 /**
22532140 * Begins a stroke with the specified color. This ends the current sub-path. A tiny API method "s" also exists.
22542141 * @method beginStroke
@@ -2261,76 +2148,6 @@ this.createjs = this.createjs||{};
22612148 return this . _setStroke ( color ? new G . Stroke ( color ) : null ) ;
22622149 } ;
22632150
2264- /**
2265- * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For
2266- * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a
2267- * square to display it:
2268- *
2269- * myGraphics.setStrokeStyle(10).
2270- * beginLinearGradientStroke(["#000","#FFF"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);
2271- *
2272- * A tiny API method "ls" also exists.
2273- * @method beginLinearGradientStroke
2274- * @param {Array } colors An array of CSS compatible color values. For example, ["#F00","#00F"] would define
2275- * a gradient drawing from red to blue.
2276- * @param {Array } ratios An array of gradient positions which correspond to the colors. For example, [0.1,
2277- * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
2278- * @param {Number } x0 The position of the first point defining the line that defines the gradient direction and size.
2279- * @param {Number } y0 The position of the first point defining the line that defines the gradient direction and size.
2280- * @param {Number } x1 The position of the second point defining the line that defines the gradient direction and size.
2281- * @param {Number } y1 The position of the second point defining the line that defines the gradient direction and size.
2282- * @return {Graphics } The Graphics instance the method is called on (useful for chaining calls.)
2283- * @chainable
2284- **/
2285- p . beginLinearGradientStroke = function ( colors , ratios , x0 , y0 , x1 , y1 ) {
2286- return this . _setStroke ( new G . Stroke ( ) . linearGradient ( colors , ratios , x0 , y0 , x1 , y1 ) ) ;
2287- } ;
2288-
2289- /**
2290- * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to
2291- * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it:
2292- *
2293- * myGraphics.setStrokeStyle(10)
2294- * .beginRadialGradientStroke(["#F00","#00F"], [0, 1], 100, 100, 0, 100, 100, 50)
2295- * .drawRect(50, 90, 150, 110);
2296- *
2297- * A tiny API method "rs" also exists.
2298- * @method beginRadialGradientStroke
2299- * @param {Array } colors An array of CSS compatible color values. For example, ["#F00","#00F"] would define
2300- * a gradient drawing from red to blue.
2301- * @param {Array } ratios An array of gradient positions which correspond to the colors. For example, [0.1,
2302- * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color
2303- * to 100%.
2304- * @param {Number } x0 Center position of the inner circle that defines the gradient.
2305- * @param {Number } y0 Center position of the inner circle that defines the gradient.
2306- * @param {Number } r0 Radius of the inner circle that defines the gradient.
2307- * @param {Number } x1 Center position of the outer circle that defines the gradient.
2308- * @param {Number } y1 Center position of the outer circle that defines the gradient.
2309- * @param {Number } r1 Radius of the outer circle that defines the gradient.
2310- * @return {Graphics } The Graphics instance the method is called on (useful for chaining calls.)
2311- * @chainable
2312- **/
2313- p . beginRadialGradientStroke = function ( colors , ratios , x0 , y0 , r0 , x1 , y1 , r1 ) {
2314- return this . _setStroke ( new G . Stroke ( ) . radialGradient ( colors , ratios , x0 , y0 , r0 , x1 , y1 , r1 ) ) ;
2315- } ;
2316-
2317- /**
2318- * Begins a pattern fill using the specified image. This ends the current sub-path. Note that unlike bitmap fills,
2319- * strokes do not currently support a matrix parameter due to limitations in the canvas API. A tiny API method "bs"
2320- * also exists.
2321- * @method beginBitmapStroke
2322- * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement } image The Image, Canvas, or Video object to use
2323- * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.
2324- * @param {String } [repetition=repeat] Optional. Indicates whether to repeat the image in the fill area. One of
2325- * "repeat", "repeat-x", "repeat-y", or "no-repeat". Defaults to "repeat".
2326- * @return {Graphics } The Graphics instance the method is called on (useful for chaining calls.)
2327- * @chainable
2328- **/
2329- p . beginBitmapStroke = function ( image , repetition ) {
2330- // NOTE: matrix is not supported for stroke because transforms on strokes also affect the drawn stroke width.
2331- return this . _setStroke ( new G . Stroke ( ) . bitmap ( image , repetition ) ) ;
2332- } ;
2333-
23342151 /**
23352152 * Ends the current sub-path, and begins a new one with no stroke. Functionally identical to <code>beginStroke(null)</code>.
23362153 * A tiny API method "es" also exists.
0 commit comments