我试图通过使用节点的半径r及其旋转来将javafx四元曲线的startxproperty绑定到节点的旋转。这个想法是,如果我这样做的Y属性以及我可以让曲线'附加'自己到一个旋转对象的结束。
现在我知道可以使用 x = r à cos( θ ) 是的。
x = r à cos( θ )
但我很难用绑定数学来表示这一点:
curve.startXProperty().bind(getRod().rotateProperty().//Something);
我在想一个组合 .multiply() 我是说, .divide() 我是说, .add() 和 .subtract() 我有货。这不像绑定有一个我可以轻松使用的.cos()方法。
.multiply()
.divide()
.add()
.subtract()
如果有人能帮我解决这个头巾的问题,我会很高兴的。
这个 add 我是说, multiply ,等等。方法只是为了方便。
add
multiply
幸运的是 Bindings 类允许您指定可以用作绑定参数的任意绑定:
Bindings
DoubleBinding binding = Bindings.createDoubleBinding( () -> Math.cos(Math.toRadians(getRod().getRotate())) * radiusProperty.get(), getRod().rotateProperty(), radiusProperty); curve.startXProperty().bind(binding);
不过,您最好使用侦听器 rotate 属性,应用 localToParent 作为转换和设置 curve 对所提供的结果。
rotate
localToParent
curve