- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以将 Pane
的原点设置为左下角(而不是左上角)?我在我的 Canvas 上添加了许多形状,这些形状是在“数学坐标系”中定义的。
我想也许有一种比总是从 y 坐标中减去高度更简单的方法。另一个优势是我不必负责调整 Pane 的大小。
最佳答案
如果您所做的只是使用形状,则可以对 Pane 应用反射。您可以将反射表示为 Scale
x=1
和 y=-1
。唯一棘手的部分是您必须将比例尺的轴心保持在垂直中心,这需要绑定(bind)以防 Pane 大小发生变化。
如果您在 Pane 中放置控件或文本,那么它们也会被反射(reflect)出来,因此它们看起来不正确。但如果您所做的只是使用形状,这将有效。
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.transform.Scale;
import javafx.stage.Stage;
public class ReflectedPaneTest extends Application {
@Override
public void start(Stage primaryStage) {
Pane pane = new Pane();
Scale scale = new Scale();
scale.setX(1);
scale.setY(-1);
scale.pivotYProperty().bind(Bindings.createDoubleBinding(() ->
pane.getBoundsInLocal().getMinY() + pane.getBoundsInLocal().getHeight() /2,
pane.boundsInLocalProperty()));
pane.getTransforms().add(scale);
pane.setOnMouseClicked(e ->
System.out.printf("Mouse clicked at [%.1f, %.1f]%n", e.getX(), e.getY()));
primaryStage.setScene(new Scene(pane, 600, 400));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
关于java - 是否可以将 javaFX Pane 原点设置为左下角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30695887/
我是 CSS 转换样式的新手。所以我没弄清楚这件事。我玩过这段代码。但它在右侧有一个 Angular 。但我需要左侧的 Angular 形状。像这样。我该如何创建它?或针对这种情况的任何其他方法? d
阅读代码 https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js有许多对 bottomleft 的引用(我认为与通
所以,我一直在尝试将 放到 的底部。在代码中,您可以看到我尝试使用相对位置和 bottom :0 来执行此操作,但它什么也没做。我可以向右浮动,所以我只需要将它放到底部即可。现在它只是一直放在文本的正
我有一个 div,我想在 div 的右下角放一张图片,在左下角放一些图片。它们的高度不同,所以我想确保它们都与 div 的底部对齐。 首先,我使用以下方法使右下角对齐: position: ab
我是一名优秀的程序员,十分优秀!