java - Figuring out QuadCurveTo's parameters -
could guys me figuring out quadcurveto
's 4 parameters , tried find information on quadcurveto
, it's hard understand without picture. know 4 parameters draw 2 lines
control path , how know/calculate coordinates object pass throught knowing 2 path-controller. there formulas
?
import javafx.animation.pathtransition; import javafx.animation.pathtransition.orientationtype; import javafx.application.application; import static javafx.application.application.launch; import javafx.scene.group; import javafx.scene.scene; import javafx.scene.paint.color; import javafx.scene.shape.moveto; import javafx.scene.shape.path; import javafx.scene.shape.quadcurveto; import javafx.scene.shape.rectangle; import javafx.stage.stage; import javafx.util.duration; public class _6 extends application { public rectangle r; @override public void start(final stage stage) { r = new rectangle(50, 80, 80, 90); r.setfill(javafx.scene.paint.color.orange); r.setstrokewidth(5); r.setstroke(color.antiquewhite); path path = new path(); path.getelements().add(new moveto(100.0f, 400.0f)); path.getelements().add(new quadcurveto(150.0f, 60.0f, 100.0f, 20.0f)); pathtransition pt = new pathtransition(duration.millis(1000), path); pt.setduration(duration.millis(10000)); pt.setnode(r); pt.setpath(path); pt.setorientation(orientationtype.orthogonal_to_tangent); pt.setcyclecount(4000); pt.setautoreverse(true); pt.play(); stage.setscene(new scene(new group(r), 500, 700)); stage.show(); } public static void main(string[] args) { launch(args); } }
you can find coordinates on new quadcurveto(150.0f, 60.0f, 100.0f, 20.0f)
line, , below sample picture of quadratic bezier
.
from wikipedia
b(t)=(1-t)*(1-t)*p0 + 2*(1-t)*t*p1 + t*t*p2, 0<=t<=1
here p0 start point, p1 control point, , p2 end point. note t
might not equal time point of transition, transition has modifiable interpolator; path pass through points defined curve. in example, p0=(100, 400)
, p1=(150, 60)
, , p2=(100, 20)
.
the interpretation take linear interpolation between start point , control point (call q0(t)
) , linear interpolation between control point , end point (q1(t)
); curve linear interpolation between q0(t)
, q1(t)
@ t
: b(t)=(1-t)*q0(t)+t*q1(t)
Comments
Post a Comment