本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.strokePolygon方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.strokePolygon方法的具体用法?Java GraphicsContext.strokePolygon怎么用?Java GraphicsContext.strokePolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.strokePolygon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawShapes
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private static void drawShapes(GraphicsContext gc) {
gc.setFill(Color.GREEN);
gc.setStroke(Color.BLUE);
gc.setLineWidth(5);
gc.strokeLine(40, 10, 10, 40);
gc.fillOval(10, 60, 30, 30);
gc.strokeOval(60, 60, 30, 30);
gc.fillRoundRect(110, 60, 30, 30, 10, 10);
gc.strokeRoundRect(160, 60, 30, 30, 10, 10);
gc.fillArc(10, 110, 30, 30, 45, 240, ArcType.OPEN);
gc.fillArc(60, 110, 30, 30, 45, 240, ArcType.CHORD);
gc.fillArc(110, 110, 30, 30, 45, 240, ArcType.ROUND);
gc.strokeArc(10, 160, 30, 30, 45, 240, ArcType.OPEN);
gc.strokeArc(60, 160, 30, 30, 45, 240, ArcType.CHORD);
gc.strokeArc(110, 160, 30, 30, 45, 240, ArcType.ROUND);
gc.fillPolygon(new double[]{10, 40, 10, 40},
new double[]{210, 210, 240, 240}, 4);
gc.strokePolygon(new double[]{60, 90, 60, 90},
new double[]{210, 210, 240, 240}, 4);
gc.strokePolyline(new double[]{110, 140, 110, 140},
new double[]{210, 210, 240, 240}, 4);
}
示例2: drawRegularNGons
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawRegularNGons(int n, boolean isFilled) {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.RED);
gc.setFill(Color.YELLOW);
gc.setLineWidth(5);
double r = 200;
double theta = (360.0 / n) * Math.PI / 180.0;
double w = drawingCanvas.getWidth();
double h = drawingCanvas.getHeight();
double x[] = new double[n];
double y[] = new double[n];
for (int i = 0; i < n; i++) {
double x1 = r * Math.cos(theta * i);
double y1 = r * Math.sin(theta * i);
double x2 = r * Math.cos(theta * (i + 1));
double y2 = r * Math.sin(theta * (i + 1));
x[i] = x1 + w / 2;
y[i] = -y1 + h / 2;
// gc.strokeLine(x1 + w / 2, -y1 + h / 2, x2 + w / 2, -y2 + h / 2);
}
if (isFilled)
gc.fillPolygon(x, y, n);
else gc.strokePolygon(x, y, n);
/*
for (theta = 0; theta <= 360; theta += 360.0 / n) {
double x1 = 0;
double y1 = 0;
double x2 = r * Math.cos(theta * Math.PI / 180.0);
double y2 = r * Math.sin(theta * Math.PI / 180.0);
double w = drawingCanvas.getWidth();
double h = drawingCanvas.getHeight();
gc.strokeLine(x1 + w / 2, -y1 + h / 2, x2 + w / 2, -y2 + h / 2);
}
*/
}