Javafx根据它的父级缩放控件

时间:2018-04-10 11:19:33

标签: javafx-8

我正在Javafx中用掩码编写一个新的Imageview。 面具可以根据鼠标的方向显示。 使用时间轴使其运作良好。但是当面具离开时,面具仍然可见。 我想要隐藏屏幕的一部分,它不在图像中。我该如何扩展呢?

鼠标输入时: enter image description here 鼠标离开时: enter image description here

我的动画代码

private void leftOut() {
    KeyFrame k1 = new KeyFrame(Duration.ZERO, new KeyValue(mask.translateXProperty(), 0));
    KeyFrame k2 = new KeyFrame(time, new KeyValue(mask.translateXProperty(), control.getWidth()*-1.0));
    timeline = new Timeline();
    timeline.getKeyFrames().addAll(k1,k2);
    timeline.play();
}

其他方向就是这样。

1 个答案:

答案 0 :(得分:0)

根本不需要调整面具的大小。只需将剪辑应用于与图像大小相同的剪辑:

<!DOCTYPE html>
<html>
<head>
    <title>Start</title>
</head>
<body>

    <h1>Start</h1>

</body>
</html>