I want to move a black point around the edge of another circle.
The move path of this point is edge of circle.
I draw theme in Canvas.
But PathTransition() only receive Shape as parameter.
How can I use this circle in canvas as move path???
btNewCircleClick():in this method,click "new 2 ciecle" will creat point and circle
btRun():in this method,clike run will make this point move around the circle.
Controller.kt:
package sample
import javafx.fxml.FXML
import javafx.scene.canvas.Canvas
class Controller{
@FXML
private lateinit var cv: Canvas
@FXML
fun btNewCircleClick(){
val gc=cv.graphicsContext2D
val c2=gc.fillOval(0.0, 0.0, 3.0, 3.0)
val c1=gc.strokeOval(60.0, 60.0, 60.0, 60.0)
//val pt=PathTransition(Duration.millis(4000.0),Circle(60.0,60.0,30.0),)
}
@FXML
fun btRun(){
}
}
sample.fxml
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.canvas.Canvas?>
<?import javafx.scene.control.Button?>
<GridPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
<Button fx:id="btNewCircle" onMouseClicked="#btNewCircleClick" text="new 2 circle" GridPane.rowIndex="0" GridPane.columnIndex="0"></Button>
<Button fx:id="btRun" onMouseClicked="#btRun" text="run" GridPane.rowIndex="1" GridPane.columnIndex="0"></Button>
<Canvas fx:id="cv" width="200" height="200" GridPane.rowIndex="2" GridPane.columnIndex="0"></Canvas>
</GridPane>
I don't know how to make it move...