CubicBezierCurve.js 640 B

123456789101112131415161718192021222324252627282930
  1. import { Curve } from '../core/Curve';
  2. import { CubicBezier } from '../core/Interpolations';
  3. import { Vector2 } from '../../math/Vector2';
  4. function CubicBezierCurve( v0, v1, v2, v3 ) {
  5. this.v0 = v0;
  6. this.v1 = v1;
  7. this.v2 = v2;
  8. this.v3 = v3;
  9. }
  10. CubicBezierCurve.prototype = Object.create( Curve.prototype );
  11. CubicBezierCurve.prototype.constructor = CubicBezierCurve;
  12. CubicBezierCurve.prototype.getPoint = function ( t ) {
  13. var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
  14. return new Vector2(
  15. CubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
  16. CubicBezier( t, v0.y, v1.y, v2.y, v3.y )
  17. );
  18. };
  19. export { CubicBezierCurve };