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


Java GraphicsContext.setGlobalAlpha方法代碼示例

本文整理匯總了Java中javafx.scene.canvas.GraphicsContext.setGlobalAlpha方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsContext.setGlobalAlpha方法的具體用法?Java GraphicsContext.setGlobalAlpha怎麽用?Java GraphicsContext.setGlobalAlpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.canvas.GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext.setGlobalAlpha方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: drawGhostStone

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
public void drawGhostStone(DrawCoords position, StoneColour colour) {
	GraphicsContext context = getGraphicsContext();

	context.setGlobalAlpha(0.5);
	draw(position, colour);
	context.setGlobalAlpha(1);
}
 
開發者ID:GoSuji,項目名稱:Suji,代碼行數:8,代碼來源:StoneDrawer.java

示例4: drawGhostStones

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
public void drawGhostStones(Collection<Coords> stones, StoneColour colour) {
	GraphicsContext context = getGraphicsContext();

	context.setGlobalAlpha(0.5);
	drawStones(stones, colour);
	context.setGlobalAlpha(1);
}
 
開發者ID:GoSuji,項目名稱:Suji,代碼行數:8,代碼來源:StoneDrawer.java


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