本文整理汇总了Java中javafx.scene.canvas.Canvas.setBlendMode方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.setBlendMode方法的具体用法?Java Canvas.setBlendMode怎么用?Java Canvas.setBlendMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.setBlendMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SanFranciscoFireworks
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
public SanFranciscoFireworks() {
// create a color palette of 180 colors
colors = new Paint[181];
colors[0] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
new Stop(0, Color.WHITE),
new Stop(0.2, Color.hsb(59, 0.38, 1)),
new Stop(0.6, Color.hsb(59, 0.38, 1,0.1)),
new Stop(1, Color.hsb(59, 0.38, 1,0))
);
for (int h=0;h<360;h+=2) {
colors[1+(h/2)] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
new Stop(0, Color.WHITE),
new Stop(0.2, Color.hsb(h, 1, 1)),
new Stop(0.6, Color.hsb(h, 1, 1,0.1)),
new Stop(1, Color.hsb(h, 1, 1,0))
);
}
// create canvas
canvas = new Canvas(1024, 500);
canvas.setBlendMode(BlendMode.ADD);
canvas.setEffect(new Reflection(0,0.4,0.15,0));
background = new ImageView(getClass().getResource("sf.jpg").toExternalForm());
getChildren().addAll(background,canvas);
// create animation timer that will be called every frame
// final AnimationTimer timer = new AnimationTimer() {
timer = new AnimationTimer() {
@Override public void handle(long now) {
GraphicsContext gc = canvas.getGraphicsContext2D();
// clear area with transparent black
gc.setFill(Color.rgb(0, 0, 0, 0.2));
gc.fillRect(0, 0, 1024, 708);
// draw fireworks
drawFireworks(gc);
// countdown to launching the next firework
if (countDownTillNextFirework == 0) {
countDownTillNextFirework = 10 + (int)(Math.random()*30);
fireParticle();
}
countDownTillNextFirework --;
}
};
}