本文整理汇总了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();
}
示例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);
}
}
示例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);
}
示例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);
}