當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphicsContext.strokePolygon方法代碼示例

本文整理匯總了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);
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:23,代碼來源:ExampleCanvas.java

示例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);
         }
         */
    }
 
開發者ID:kmhasan-class,項目名稱:spring2017java,代碼行數:40,代碼來源:FXMLDocumentController.java


注:本文中的javafx.scene.canvas.GraphicsContext.strokePolygon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。