X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FGuiTest.java;h=0d199c238a1c624760c9da6fba4c06fd4e731dbd;hb=adc29b9a70fa1d03ac67b0b3f397fed7a75f4d7b;hp=a8da3517808da720c53de0903a07eac802d2bf92;hpb=242486dc84c4f5b0c1bfad9807099355246f4ee2;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/GuiTest.java b/src/kaka/cakelight/GuiTest.java index a8da351..0d199c2 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(); } @@ -68,7 +68,7 @@ public class GuiTest extends Application { return javafx.scene.paint.Color.rgb(c.r(), c.g(), c.b()); } - private void drawFrame(GraphicsContext gc, Frame frame) { + private void drawFrame(GraphicsContext gc, VideoFrame frame) { if (paused) return; System.out.println("Drawing a frame"); drawCols(gc, frame); @@ -83,20 +83,24 @@ 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(getLedColor(frame, x + config.leds.rows)); + // Top + gc.setFill(getLedColor(frame, config.leds.cols * 2 + config.leds.rows - x - 1)); gc.fillRect(GUTTER + x * colSize, GUTTER - ledLength, colSize, ledLength); - gc.setFill(getLedColor(frame, config.leds.rows * 2 + config.leds.cols * 2 - 1 - x)); + // Bottom + gc.setFill(getLedColor(frame, x)); gc.fillRect(GUTTER + x * colSize, GUTTER + 9 * BLOCK, colSize, ledLength); } for (int y = 0; y < config.leds.rows; y++) { - gc.setFill(getLedColor(frame, config.leds.rows - 1 - y)); + // Left + gc.setFill(getLedColor(frame, config.leds.cols * 2 + config.leds.rows + y)); gc.fillRect(GUTTER - ledLength, GUTTER + y * rowSize, ledLength, rowSize); - gc.setFill(getLedColor(frame, y + config.leds.rows + config.leds.cols)); + // Right + gc.setFill(getLedColor(frame, config.leds.rows + config.leds.cols - y - 1)); gc.fillRect(GUTTER + 16 * BLOCK, GUTTER + y * rowSize, ledLength, rowSize); } } - private void drawVideo(GraphicsContext gc, Frame frame) { + private void drawVideo(GraphicsContext gc, VideoFrame frame) { byte[] rgb = new byte[3]; Mat img = frame.getConvertedImage(); float colSize = 16 * BLOCK / (float)img.cols(); @@ -110,7 +114,7 @@ public class GuiTest extends Application { } } - private void drawCols(GraphicsContext gc, Frame frame) { + private void drawCols(GraphicsContext gc, VideoFrame frame) { byte[] rgb = new byte[3]; for (int x = 0; x < config.leds.cols; x++) { for (int y = 0; y < 9; y++) { @@ -120,7 +124,7 @@ public class GuiTest extends Application { } } - private void drawRows(GraphicsContext gc, Frame frame) { + private void drawRows(GraphicsContext gc, VideoFrame frame) { byte[] rgb = new byte[3]; for (int y = 0; y < config.leds.rows; y++) { for (int x = 0; x < 16; x++) {