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


Java Canvas.setBlendMode方法代碼示例

本文整理匯總了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 --;
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:45,代碼來源:Fireworks.java


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