【发布时间】:2016-12-01 15:44:14
【问题描述】:
我的旋转方法有问题。我想围绕它的中心旋转一个绘图,但我不想旋转 Canvas 对象,只是它里面的绘图。 artHorizon 是画布对象(400,400) 还是将坐标系移动到 convas 对象的中心会更好?
这里是绘制方法:
public void drawHorizon(GraphicsContext gc, double degrees, double translate) {
gc.translate(0, translate);
gc.rotate(degrees);
gc.setFill(Color.rgb(0, 61, 144));
gc.fillRect(0, 0, artHorizon.getWidth() * 2, 150);
gc.setFill(Color.rgb(59, 41, 39));
gc.fillRect(0, 150, 400, 150);
}
并初始化:
@Override
public void initialize(URL location, ResourceBundle resources) {
GraphicsContext gc = artHorizon.getGraphicsContext2D();
gc.rotate(20);//here I want to rotate gc around center
drawHorizon(gc, 0, 0);
}
【问题讨论】:
-
您想动态旋转它还是只在您初始化程序时旋转它?
-
程序期间动态。