Figuring out QuadCurveTo's parameters
Posted
by
Fev
on Stack Overflow
See other posts from Stack Overflow
or by Fev
Published on 2014-08-18T16:03:18Z
Indexed on
2014/08/18
16:21 UTC
Read the original article
Hit count: 165
Could you guys help me figuring out QuadCurveTo
's 4 parameters , I tried to find information on http://docs.oracle.com/javafx/2/api/javafx/scene/shape/QuadCurveTo.html, but it's hard for me to understand without picture , I search on google about 'Quadratic Bezier' but it shows me more than 2 coordinates, I'm confused and blind now. I know those 4 parameters draw 2 lines to control the path , but how we know/count exactly which coordinates the object will throught by only knowing those 2 path-controller. Are there some 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 those coordinates on this new QuadCurveTo(150.0f, 60.0f, 100.0f, 20.0f)
line, and below is the picture of Quadratic Bezier
© Stack Overflow or respective owner