@@ -687,80 +687,7 @@ var ShapeUtils = {
return ShapeUtils.area( pts ) < 0;
- },
-
- // Bezier Curves formulas obtained from
- // http://en.wikipedia.org/wiki/B%C3%A9zier_curve
- // Quad Bezier Functions
- b2: ( function () {
- function b2p0( t, p ) {
- var k = 1 - t;
- return k * k * p;
- }
- function b2p1( t, p ) {
- return 2 * ( 1 - t ) * t * p;
- function b2p2( t, p ) {
- return t * t * p;
- return function b2( t, p0, p1, p2 ) {
- return b2p0( t, p0 ) + b2p1( t, p1 ) + b2p2( t, p2 );
- };
- } )(),
- // Cubic Bezier Functions
- b3: ( function () {
- function b3p0( t, p ) {
- return k * k * k * p;
- function b3p1( t, p ) {
- return 3 * k * k * t * p;
- function b3p2( t, p ) {
- return 3 * k * t * t * p;
- function b3p3( t, p ) {
- return t * t * t * p;
- return function b3( t, p0, p1, p2, p3 ) {
- return b3p0( t, p0 ) + b3p1( t, p1 ) + b3p2( t, p2 ) + b3p3( t, p3 );
- } )()
+ }
};
@@ -0,0 +1,70 @@
+/**
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ *
+ * Bezier Curves formulas obtained from
+ * http://en.wikipedia.org/wiki/Bézier_curve
+ */
+
+// Quad Bezier Functions
+function b2p0( t, p ) {
+ var k = 1 - t;
+ return k * k * p;
+}
+function b2p1( t, p ) {
+ return 2 * ( 1 - t ) * t * p;
+function b2p2( t, p ) {
+ return t * t * p;
+function b2( t, p0, p1, p2 ) {
+ return b2p0( t, p0 ) + b2p1( t, p1 ) + b2p2( t, p2 );
+// Cubic Bezier Functions
+function b3p0( t, p ) {
+ return k * k * k * p;
+function b3p1( t, p ) {
+ return 3 * k * k * t * p;
+function b3p2( t, p ) {
+ return 3 * k * t * t * p;
+function b3p3( t, p ) {
+ return t * t * t * p;
+function b3( t, p0, p1, p2, p3 ) {
+ return b3p0( t, p0 ) + b3p1( t, p1 ) + b3p2( t, p2 ) + b3p3( t, p3 );
+export { b2, b3 };
@@ -1,4 +1,4 @@
-import { ShapeUtils } from '../ShapeUtils';
+import { b2, b3 } from './Bezier';
import { ShapePath } from './ShapePath';
/**
@@ -47,7 +47,7 @@ Object.assign( Font.prototype, {
var path = new ShapePath();
- var pts = [], b2 = ShapeUtils.b2, b3 = ShapeUtils.b3;
+ var pts = [];
var x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, laste;
if ( glyph.o ) {
@@ -1,7 +1,7 @@
+import { b3 } from '../core/Bezier';
import { Curve } from '../core/Curve';
import { Vector2 } from '../../math/Vector2';
import { CurveUtils } from '../CurveUtils';
/**************************************************************
* Cubic Bezier curve
@@ -21,8 +21,6 @@ CubicBezierCurve.prototype.constructor = CubicBezierCurve;
CubicBezierCurve.prototype.getPoint = function ( t ) {
- var b3 = ShapeUtils.b3;
return new Vector2(
b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
@@ -1,6 +1,6 @@
-import { Vector3 } from '../../math/Vector3';
+import { Vector3 } from '../../math/Vector3';
* Cubic Bezier 3D curve
@@ -19,8 +19,6 @@ var CubicBezierCurve3 = Curve.create(
function ( t ) {
return new Vector3(
b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ),
+import { b2 } from '../core/Bezier';
* Quadratic Bezier curve
@@ -22,8 +22,6 @@ QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
QuadraticBezierCurve.prototype.getPoint = function ( t ) {
- var b2 = ShapeUtils.b2;
b2( t, this.v0.x, this.v1.x, this.v2.x ),
b2( t, this.v0.y, this.v1.y, this.v2.y )
* Quadratic Bezier 3D curve
@@ -18,8 +18,6 @@ var QuadraticBezierCurve3 = Curve.create(
b2( t, this.v0.y, this.v1.y, this.v2.y ),