X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FGuiTest.java;h=5aaba2fd686f31891223235d75243732da78fbef;hb=f722ee0d05ade1f90b7bc5e51d68b3aed4d65652;hp=b73d37fb33305408faad3dc05e0d2aabab5bf5f2;hpb=01ee91e7622bbdf6a940b2d8ca9efc1f133cbe97;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/GuiTest.java b/src/kaka/cakelight/GuiTest.java index b73d37f..5aaba2f 100644 --- a/src/kaka/cakelight/GuiTest.java +++ b/src/kaka/cakelight/GuiTest.java @@ -37,7 +37,7 @@ public class GuiTest extends Application { Scene scene = new Scene(root); scene.setOnKeyPressed(keyEvent -> { - if (keyEvent.getCode() == KeyCode.ESCAPE) { + if (keyEvent.getCode() == KeyCode.ESCAPE || keyEvent.getCode() == KeyCode.Q) { stage.close(); cakelight.cleanup(); } @@ -63,6 +63,11 @@ public class GuiTest extends Application { mode.onVideoFrame(frame -> drawFrame(canvas.getGraphicsContext2D(), frame)); } + private javafx.scene.paint.Color getLedColor(LedFrame frame, int led) { + kaka.cakelight.Color c = frame.getLedColor(led); + return javafx.scene.paint.Color.rgb(c.r(), c.g(), c.b()); + } + private void drawFrame(GraphicsContext gc, Frame frame) { if (paused) return; System.out.println("Drawing a frame"); @@ -78,15 +83,15 @@ public class GuiTest extends Application { float rowSize = 9f * BLOCK / config.leds.rows; // DropShadow shadow = new DropShadow(BlurType.ONE_PASS_BOX, Color.RED, colSize * 2, colSize, 0, 0); for (int x = 0; x < config.leds.cols; x++) { - gc.setFill(frame.getLedColor(x + config.leds.rows)); + gc.setFill(getLedColor(frame, x + config.leds.rows)); gc.fillRect(GUTTER + x * colSize, GUTTER - ledLength, colSize, ledLength); - gc.setFill(frame.getLedColor(config.leds.rows * 2 + config.leds.cols * 2 - 1 - x)); + gc.setFill(getLedColor(frame, config.leds.rows * 2 + config.leds.cols * 2 - 1 - x)); gc.fillRect(GUTTER + x * colSize, GUTTER + 9 * BLOCK, colSize, ledLength); } for (int y = 0; y < config.leds.rows; y++) { - gc.setFill(frame.getLedColor(config.leds.rows - 1 - y)); + gc.setFill(getLedColor(frame, config.leds.rows - 1 - y)); gc.fillRect(GUTTER - ledLength, GUTTER + y * rowSize, ledLength, rowSize); - gc.setFill(frame.getLedColor(y + config.leds.rows + config.leds.cols)); + gc.setFill(getLedColor(frame, y + config.leds.rows + config.leds.cols)); gc.fillRect(GUTTER + 16 * BLOCK, GUTTER + y * rowSize, ledLength, rowSize); } }