Skip to content

Commit dc9bc40

Browse files
committed
New function curveTangent(),bezierTangent()
1 parent ef57baf commit dc9bc40

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

processing.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ function buildProcessing( curElement ){
17261726

17271727
p.curve = function curve(x1, y1, x2, y2, x3, y3, x4, y4) {
17281728

1729-
p.beginShape();
1729+
p.beginShape();
17301730
p.curveVertex(x1, y1);
17311731
p.curveVertex(x2, y2);
17321732
p.curveVertex(x3, y3);
@@ -1737,11 +1737,16 @@ function buildProcessing( curElement ){
17371737

17381738
p.bezierPoint = function bezierPoint(a,b,c,d,t){
17391739
return (1-t)*(1-t)*(1-t)*a+3*(1-t)*(1-t)*t*b+3*(1-t)*t*t*c+t*t*t*d;
1740+
}
1741+
p.bezierTangent = function bezierTangent(a,b,c,d,t){
1742+
return -3*(1-t)*(1-t)*a+3*(1-2*t)*b+3*(2*t-3*t*t)*c+2*t*d;
17401743
}
17411744
p.curvePoint = function curvePoint(a,b,c,d,t){
17421745
return 0.5*((2*b)+(-a+c)*t+(2*a-5*b+4*c-d)*t*t+(-a+3*b-3*c+d)*t*t*t)
17431746
}
1744-
1747+
p.curveTangent = function curveTangent(a,b,c,d,t){
1748+
return 0.5*((-a+c)+2*(2*a-5*b+4*c-d)*t+3*(-a+3*b-3*c+d)*t*t)
1749+
}
17451750

17461751
//end
17471752

0 commit comments

Comments
 (0)