当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsContext.fillOval方法代码示例

本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.fillOval方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.fillOval方法的具体用法?Java GraphicsContext.fillOval怎么用?Java GraphicsContext.fillOval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.canvas.GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext.fillOval方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintStone

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Paint a black/white stone onto a graphics context with a grid
 * @param gc Graphics context
 * @param startX Start (top left) x coordinate of the grid
 * @param startY Start (top left) y coordinate of the grid
 * @param cellSize Size of the grid cells
 * @param row Row position of the stone
 * @param col Column position of the stone
 * @param index Index of the stone (1 = black, 2 = white)
 * @param transparent Transparency value, 0.5 alpha if true
 */
private static void paintStone(GraphicsContext gc, double startX, double
        startY, double cellSize, int row, int col, int index,
                               boolean transparent) {
    double x = startX + col*cellSize;
    double y = startY + row*cellSize;
    double offset = (cellSize * 0.7) / 2;
    gc.save();
    if(transparent) {
        gc.setGlobalAlpha(0.5);
    }
    switch(index) {
        case 1:
            gc.setFill(blackGradient);
            gc.fillOval(x - offset, y - offset, cellSize * 0.7,
                    cellSize * 0.7);
            break;
        case 2:
            gc.setFill(whiteGradient);
            gc.fillOval(x - offset, y - offset, cellSize * 0.7,
                    cellSize * 0.7);
            break;
    }
    gc.restore();
}
 
开发者ID:haslam22,项目名称:gomoku,代码行数:36,代码来源:BoardPane.java

示例2: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw(GraphicsContext context) {
    final double x = Math.round(posX);
    final double y = Math.round(posY);
    final double xVel = (x - lastPosX) * -5;
    final double yVel = (y - lastPosY) * -5;
    // set the opacity for all drawing of this particle
    context.setGlobalAlpha(Math.random() * this.alpha);
    // draw particle
    context.setFill(color);
    context.fillOval(x-size, y-size, size+size, size+size);
    // draw the arrow triangle from where we were to where we are now
    if (hasTail) {
        context.setFill(Color.rgb(255,255,255,0.3));
        context.fillPolygon(new double[]{posX + 1.5,posX + xVel,posX - 1.5}, 
                new double[]{posY,posY + yVel,posY}, 3);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Fireworks.java

示例3: 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

示例4: render

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(int indexX, int indexY, GraphicsContext gc) {

        if (this == STANDARD) {
            gc.setFill(Color.valueOf("#debf89"));
            gc.fillRoundRect(indexX * 64, indexY * 64, 64, 64, 10, 10);
        }

        if (this == CORK) {
            gc.setFill(Color.valueOf("#debf89").brighter().brighter());
            gc.fillRoundRect(indexX * 64, indexY * 64, 64, 64, 10, 10);
        }

        if (this == HOLE) {
            gc.setFill(Color.GRAY.brighter());
            gc.fillOval(indexX * 64, indexY * 64, 64, 64);
        }
    }
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:18,代码来源:Block.java

示例5: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw() {
    drawGrid();

    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    gc.setStroke(Color.BLACK);
    gc.setLineWidth(5);
    gc.setFill(Color.YELLOW);
    gc.fillRect(300 - 50, 200 - 50, 100, 100);
    gc.strokeRect(300 - 50, 200 - 50, 100, 100);
    gc.setFill(Color.GREEN);
    gc.fillOval(100, 100, 200, 100);
    gc.strokeOval(100, 100, 200, 100);

    // Hometasks:
    // 1. Draw a circle right at the center with radius of 150 pixels
    // 2. Draw 20 concentric circles in the top left box
    // 3. Draw a sun (circle + rays)
    // 4. Draw a regular n-gon (like pentagon)
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:20,代码来源:FXMLDocumentController.java

示例6: drawConner

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * 设置图形节点为选中样式
 */
@Override
public void drawConner() {
    canvas.setMouseTransparent(true);
    isConnerShow = true;

    GraphicsContext gc = canvas.getGraphicsContext2D();
    double whiteR = 12;
    double blueR = 10;

    if (x1 != null) {
        double X = x.doubleValue();
        double Y = y.doubleValue();

        gc.setFill(Color.WHITE);
        gc.fillOval(x1.doubleValue() -6+ X, y1.doubleValue() -6+ Y, whiteR, whiteR);
        gc.fillOval(x2.doubleValue() - 6+ X, y2.doubleValue() - 6 + Y, whiteR, whiteR);

        gc.setFill(Color.color(0.03, 0.43, 0.81));
        gc.fillOval(x1.doubleValue() -5 + X, y1.doubleValue() -5 + Y, blueR, blueR);
        gc.fillOval(x2.doubleValue()-5+ X, y2.doubleValue() - 5 + Y, blueR, blueR);
    }


}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:28,代码来源:DragBoxWithLine.java

示例7: update

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void update(GraphicsContext gc) {
    gc.setFill(Color.LIGHTBLUE);
    gc.fillOval(x - radius, y - radius, radius * 2, radius * 2);

    if (time > 0) {
        time--;
    }
    if (time <= 0) {
        expired = true;
    }
}
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:12,代码来源:PickUp.java

示例8: render

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(Bullet bullet, GraphicsContext gc) {
    gc.save();
    gc.translate(bullet.getX(), bullet.getY());
    gc.transform(new Affine(new Rotate(bullet.getAngle()))); //Rotate the gc to the angle of the bullet's path

    //TODO increase bullet size in general

    if (this == STANDARD) {
        gc.translate(-2, -3); //Move SVG to center of Bullet
        gc.setFill(Color.GRAY);
        gc.beginPath();
        gc.appendSVGPath("M 0 3 Q 0 1 2 0 Q 4 1 4 3 L 4 7 L 0 7 Z"); //SVG PATH OF BULLET
        gc.fill();
        gc.closePath();
    } else if (this == ROCKET) {
        //TODO create rocket SVG
        gc.setFill(Color.GRAY);
        gc.beginPath();
        gc.appendSVGPath("M 0 3 Q 0 1 2 0 Q 4 1 4 3 L 4 7 L 0 7 Z"); //SVG PATH OF BULLET
        gc.fill();
        gc.closePath();
    } else if (this == BOUNCY) {
        gc.setFill(Color.GRAY);
        gc.fillOval(bullet.getX() - bullet.getRadius(), bullet.getY() - bullet.getRadius(), bullet.getRadius() * 2, bullet.getRadius() * 2);
    }

    gc.restore();
}
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:29,代码来源:Bullet.java

示例9: update

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void update(GraphicsContext gc) {
    gc.setFill(Color.YELLOW);
    gc.fillOval(x - radius, y - radius, radius * 2, radius * 2);

    if (time > 0) {
        time--;
    }
}
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:9,代码来源:Mine.java

示例10: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw(int type,GraphicsContext gc){
	if(type == 0) {
		gc.strokeOval(pos[0]-RANGE/2,pos[1]-RANGE/2,RANGE,RANGE);
	}
	else if(type > 0 && type < 5) {
		gc.setFill(Color.BROWN);
		gc.fillOval(pos[0]-RANGE/2,pos[1]-RANGE/2,RANGE/2,RANGE/2);
	}
}
 
开发者ID:clonex10100,项目名称:Dna-replication-game,代码行数:10,代码来源:PrimeZone.java

示例11: task1

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void task1() {
    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();

    double radius = 150;
    gc.setFill(new Color(9 / 255.0, 59 / 255.0, 220 / 255.0, 0.75));
    gc.fillOval(drawingCanvas.getWidth() / 2 - radius, drawingCanvas.getHeight() / 2 - radius, radius * 2, radius * 2);
    gc.setStroke(Color.BLACK);
    gc.strokeOval(drawingCanvas.getWidth() / 2 - radius, drawingCanvas.getHeight() / 2 - radius, radius * 2, radius * 2);
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:10,代码来源:FXMLDocumentController.java

示例12: drawConner

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
     * 设置图形节点为选中样式
     */
    public void drawConner() {
        canvas.setMouseTransparent(false);
        if (node != null) {
            node.setMouseTransparent(true);
        }
        isConnerShow = true;
//        System.out.println("draw conner");
        double height = getPrefHeight();
        double width = getPrefWidth();
        GraphicsContext gc = canvas.getGraphicsContext2D();
        double whiteR = 12;
        double blueR = 10;
        double delta = (whiteR - blueR) / 2;
        double lineStart = whiteR / 2;

        gc.setStroke(Color.GREEN);
        gc.setLineWidth(2);

        gc.strokeLine(lineStart, lineStart, width - lineStart, lineStart);
        gc.strokeLine(lineStart, height - lineStart, width - lineStart, height - lineStart);
        gc.strokeLine(lineStart, lineStart, lineStart, height - lineStart);
        gc.strokeLine(width - lineStart, lineStart, width - lineStart, height - lineStart);


        gc.setFill(Color.WHITE);
        gc.fillOval(0, 0, whiteR, whiteR);
        gc.fillOval(width - whiteR, 0, whiteR, whiteR);
        gc.fillOval(0, height - whiteR, whiteR, whiteR);
        gc.fillOval(width - whiteR, height - whiteR, whiteR, whiteR);

        gc.setFill(Color.color(0.03, 0.43, 0.81));
        gc.fillOval(delta, delta, blueR, blueR);
        gc.fillOval(width - blueR - delta, delta, blueR, blueR);
        gc.fillOval(delta, height - blueR - delta, blueR, blueR);
        gc.fillOval(width - blueR - delta, height - blueR - delta, blueR, blueR);
    }
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:40,代码来源:DragBox.java

示例13: animate

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Renders the animation
 * @param currentTime current song time
 */
public void animate(double currentTime) {
    double ratio = (currentTime - startTime) / (endTime - startTime);
    this.y = (canvas.getHeight() - 25) * ratio - 50;
    GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.setFill(cz.jcu.prf.uai.javamugs.clonehero.gui.CloneHeroColors.COLORARRAY[color]);
    gc.fillOval(225 + 75 * color, y, 50, 50);
    if (currentTime >= endTime + 500) {
        finished = true;
    }
}
 
开发者ID:JavaMugs,项目名称:CloneHero,代码行数:15,代码来源:GameController.java

示例14: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw(GraphicsContext gc, double size){
	gc.fillOval(x-size/2, y-size/2, size, size);
}
 
开发者ID:Brotcrunsher,项目名称:AttractorSimulator,代码行数:4,代码来源:Point.java


注:本文中的javafx.scene.canvas.GraphicsContext.fillOval方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。