22
33var Class = require ( '../utils/Class' ) ;
44var CubicBezierCurve = require ( './curves/cubicbezier/CubicBezierCurve' ) ;
5+ var EllipseCurve = require ( './curves/ellipse/EllipseCurve' ) ;
56var GameObjectFactory = require ( '../scene/plugins/GameObjectFactory' ) ;
67var LineCurve = require ( './curves/line/LineCurve' ) ;
78var SplineCurve = require ( './curves/spline/SplineCurve' ) ;
@@ -81,10 +82,22 @@ var Path = new Class({
8182 } ,
8283
8384 // Creates an ellipse curve positioned at the previous end point, using the given parameters
84- // ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation)
85- // {
86- // function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation)
87- // },
85+ ellipseTo : function ( xRadius , yRadius , startAngle , endAngle , clockwise , rotation )
86+ {
87+ var ellipse = new EllipseCurve ( 0 , 0 , xRadius , yRadius , startAngle , endAngle , clockwise , rotation ) ;
88+
89+ var end = this . getEndPoint ( tmpVec2A ) ;
90+
91+ // Calculate where to center the ellipse
92+ var start = ellipse . getStartPoint ( tmpVec2B ) ;
93+
94+ end . sub ( start ) ;
95+
96+ ellipse . x = end . x ;
97+ ellipse . y = end . y ;
98+
99+ return this . add ( ellipse ) ;
100+ } ,
88101
89102 toJSON : function ( )
90103 {
@@ -101,7 +114,7 @@ var Path = new Class({
101114 y : this . startPoint . y ,
102115 autoClose : this . autoClose ,
103116 curves : out
104- }
117+ } ;
105118 } ,
106119
107120 add : function ( curve )
0 commit comments