Bläddra i källkod

ShapePath: support chaining

WestLangley 5 år sedan
förälder
incheckning
4a42c02327
3 ändrade filer med 20 tillägg och 10 borttagningar
  1. 5 5
      docs/api/en/extras/core/ShapePath.html
  2. 5 5
      src/extras/core/ShapePath.d.ts
  3. 10 0
      src/extras/core/ShapePath.js

+ 5 - 5
docs/api/en/extras/core/ShapePath.html

@@ -49,27 +49,27 @@
 
 		<h2>Methods</h2>
 
-		<h3>[method:null moveTo]( [param:Float x], [param:Float y] )</h3>
+		<h3>[method:this moveTo]( [param:Float x], [param:Float y] )</h3>
 		<p>
 		Starts a new [page:Path] and calls [page:Path.moveTo]( x, y ) on that [page:Path].
 		Also points [page:ShapePath.currentPath currentPath] to that [page:Path].
 		</p>
 
-		<h3>[method:null lineTo]( [param:Float x], [param:Float y] )</h3>
+		<h3>[method:this lineTo]( [param:Float x], [param:Float y] )</h3>
 		<p>This creates a line from the [page:ShapePath.currentPath currentPath]'s
 			offset to X and Y and updates the offset to X and Y.</p>
 
-		<h3>[method:null quadraticCurveTo]( [param:Float cpX], [param:Float cpY], [param:Float x], [param:Float y] )</h3>
+		<h3>[method:this quadraticCurveTo]( [param:Float cpX], [param:Float cpY], [param:Float x], [param:Float y] )</h3>
 		<p>This creates a quadratic curve from the [page:ShapePath.currentPath currentPath]'s
 			offset to x and y with cpX and cpY as control point and updates the [page:ShapePath.currentPath currentPath]'s
 			offset to x and y.</p>
 
-		<h3>[method:null bezierCurveTo]( [param:Float cp1X], [param:Float cp1Y], [param:Float cp2X], [param:Float cp2Y], [param:Float x], [param:Float y] )</h3>
+		<h3>[method:this bezierCurveTo]( [param:Float cp1X], [param:Float cp1Y], [param:Float cp2X], [param:Float cp2Y], [param:Float x], [param:Float y] )</h3>
 		<p>This creates a bezier curve from the [page:ShapePath.currentPath currentPath]'s
 			 offset to x and y with cp1X, cp1Y and cp1X, cp1Y as control points and updates the
 			 [page:ShapePath.currentPath currentPath]'s offset to x and y.</p>
 
-		<h3>[method:null splineThru] ( [param:Array points] ) </h3>
+		<h3>[method:this splineThru] ( [param:Array points] ) </h3>
 		<p>points - An array of [page:Vector2]s</p>
 		<p>Connects a new [page:SplineCurve] onto the [page:ShapePath.currentPath currentPath].</p>
 

+ 5 - 5
src/extras/core/ShapePath.d.ts

@@ -8,9 +8,9 @@ export class ShapePath {
 	subPaths: any[];
 	currentPath: any;
 
-	moveTo( x: number, y: number ): void;
-	lineTo( x: number, y: number ): void;
-	quadraticCurveTo( aCPx: number, aCPy: number, aX: number, aY: number ): void;
+	moveTo( x: number, y: number ): this;
+	lineTo( x: number, y: number ): this;
+	quadraticCurveTo( aCPx: number, aCPy: number, aX: number, aY: number ): this;
 	bezierCurveTo(
 		aCP1x: number,
 		aCP1y: number,
@@ -18,8 +18,8 @@ export class ShapePath {
 		aCP2y: number,
 		aX: number,
 		aY: number
-	): void;
-	splineThru( pts: Vector2[] ): void;
+	): this;
+	splineThru( pts: Vector2[] ): this;
 	toShapes( isCCW: boolean, noHoles?: boolean ): Shape[];
 
 }

+ 10 - 0
src/extras/core/ShapePath.js

@@ -27,30 +27,40 @@ Object.assign( ShapePath.prototype, {
 		this.subPaths.push( this.currentPath );
 		this.currentPath.moveTo( x, y );
 
+		return this;
+
 	},
 
 	lineTo: function ( x, y ) {
 
 		this.currentPath.lineTo( x, y );
 
+		return this;
+
 	},
 
 	quadraticCurveTo: function ( aCPx, aCPy, aX, aY ) {
 
 		this.currentPath.quadraticCurveTo( aCPx, aCPy, aX, aY );
 
+		return this;
+
 	},
 
 	bezierCurveTo: function ( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {
 
 		this.currentPath.bezierCurveTo( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY );
 
+		return this;
+
 	},
 
 	splineThru: function ( pts ) {
 
 		this.currentPath.splineThru( pts );
 
+		return this;
+
 	},
 
 	toShapes: function ( isCCW, noHoles ) {