Search in sources :

Example 51 with Mino

use of core.mino.Mino in project solution-finder by knewjade.

the class AllFigGenerator method drawMino.

private void drawMino(Piece piece, Rectangle rectangle) {
    if (piece == null)
        return;
    ColorType colorType = colorConverter.parseToColorType(piece);
    FigColor figColor = FigColor.parse(colorType);
    Color color = getColor(figColor, true);
    graphics.setColor(color);
    Mino mino = minoFactory.create(piece, Rotate.Spawn);
    int maxX = mino.getMaxX();
    int minX = mino.getMinX();
    double mx = (maxX - minX + 1) / 2.0 + minX;
    int minY = -mino.getMaxY();
    int maxY = -mino.getMinY();
    double my = (maxY - minY + 1) / 2.0 + minY;
    int nextBlockSize = setting.getNextBlockSize();
    int nextBlockMargin = setting.getNextBlockMargin();
    int size = nextBlockSize + nextBlockMargin;
    double centerX = rectangle.getX() + rectangle.getWidth() / 2.0;
    double centerY = rectangle.getY() + rectangle.getHeight() / 2.0;
    for (int[] position : mino.getPositions()) {
        int x = (int) (centerX + (position[0] - mx) * size + nextBlockMargin / 2.0);
        int y = (int) (centerY - (position[1] + my) * size + nextBlockMargin / 2.0);
        graphics.fillRect(x, y, nextBlockSize, nextBlockSize);
    }
}
Also used : FigColor(util.fig.FigColor) FigColor(util.fig.FigColor) ColorType(common.tetfu.common.ColorType) Mino(core.mino.Mino)

Example 52 with Mino

use of core.mino.Mino in project solution-finder by knewjade.

the class NoHoldFigGenerator method updateMino.

@Override
public void updateMino(ColorType colorType, Rotate rotate, int xIndex, int yIndex) {
    Piece piece = colorConverter.parseToBlock(colorType);
    Mino mino = minoFactory.create(piece, rotate);
    FigColor figColor = FigColor.parse(colorType);
    Color color = figColor.getStrongColor();
    graphics.setColor(color);
    for (int[] positions : mino.getPositions()) {
        Rectangle rectangle = positionDecider.getInField(xIndex + positions[0], yIndex + positions[1]);
        fillRect(rectangle);
    }
}
Also used : Piece(core.mino.Piece) FigColor(util.fig.FigColor) FigColor(util.fig.FigColor) Rectangle(util.fig.Rectangle) Mino(core.mino.Mino)

Example 53 with Mino

use of core.mino.Mino in project solution-finder by knewjade.

the class NoHoldFigGenerator method drawMino.

private void drawMino(Piece piece, Rectangle rectangle) {
    if (piece == null)
        return;
    ColorType colorType = colorConverter.parseToColorType(piece);
    FigColor figColor = FigColor.parse(colorType);
    Color color = getColor(figColor, true);
    graphics.setColor(color);
    Mino mino = minoFactory.create(piece, Rotate.Spawn);
    int maxX = mino.getMaxX();
    int minX = mino.getMinX();
    double mx = (maxX - minX + 1) / 2.0 + minX;
    int minY = -mino.getMaxY();
    int maxY = -mino.getMinY();
    double my = (maxY - minY + 1) / 2.0 + minY;
    int nextBlockSize = setting.getNextBlockSize();
    int nextBlockMargin = setting.getNextBlockMargin();
    int size = nextBlockSize + nextBlockMargin;
    double centerX = rectangle.getX() + rectangle.getWidth() / 2.0;
    double centerY = rectangle.getY() + rectangle.getHeight() / 2.0;
    for (int[] position : mino.getPositions()) {
        int x = (int) (centerX + (position[0] - mx) * size + nextBlockMargin / 2.0);
        int y = (int) (centerY - (position[1] + my) * size + nextBlockMargin / 2.0);
        graphics.fillRect(x, y, nextBlockSize, nextBlockSize);
    }
}
Also used : FigColor(util.fig.FigColor) FigColor(util.fig.FigColor) ColorType(common.tetfu.common.ColorType) Mino(core.mino.Mino)

Example 54 with Mino

use of core.mino.Mino in project solution-finder by knewjade.

the class PngWriter method write.

@Override
public void write(List<TetfuPage> tetfuPages) throws IOException {
    int page = startPageIndex + 1;
    for (TetfuPage tetfuPage : tetfuPages) {
        String path = String.format("%s_%03d.png", prefix, page);
        // リセット
        figGenerator.reset();
        // 現在のミノを取得
        ColorType colorType = tetfuPage.getColorType();
        Rotate rotate = tetfuPage.getRotate();
        Mino mino = ColorType.isMinoBlock(colorType) ? minoFactory.create(colorConverter.parseToBlock(colorType), rotate) : null;
        int x = tetfuPage.getX();
        int y = tetfuPage.getY();
        // フィールドの更新
        ColoredField field = tetfuPage.getField();
        figGenerator.updateField(field, mino, x, y);
        // ミノを置くかチェック
        if (ColorType.isMinoBlock(colorType)) {
            // 現在のミノの更新
            figGenerator.updateMino(colorType, rotate, x, y);
            // bagの更新
            Piece piece = colorConverter.parseToBlock(colorType);
            bag.use(piece);
        }
        // ネクストの更新
        figGenerator.updateNext(bag.getNext(nextBoxCount));
        // ホールドの更新
        figGenerator.updateHold(bag.getHold());
        // 画像の生成
        BufferedImage image = figGenerator.fix();
        // 画像の出力
        ImageIO.write(image, "png", new File(path));
        page++;
    }
}
Also used : TetfuPage(common.tetfu.TetfuPage) ColoredField(common.tetfu.field.ColoredField) Rotate(core.srs.Rotate) Piece(core.mino.Piece) ColorType(common.tetfu.common.ColorType) Mino(core.mino.Mino) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Example 55 with Mino

use of core.mino.Mino in project solution-finder by knewjade.

the class PositionLimitParser method createI.

private List<PositionLimitedMino> createI(DeltaLimit delta) {
    Mino spawn = minoFactory.create(Piece.I, Rotate.Spawn);
    Mino left = minoFactory.create(Piece.I, Rotate.Left);
    switch(delta) {
        case OddUp:
            return Collections.singletonList(PositionLimitedMino.create(left, PositionLimit.OddX));
        case EvenUp:
            return Collections.singletonList(PositionLimitedMino.create(left, PositionLimit.EvenX));
        case Flat:
            return Arrays.asList(PositionLimitedMino.create(spawn, PositionLimit.OddX), PositionLimitedMino.create(spawn, PositionLimit.EvenX));
    }
    throw new IllegalStateException("No reachable");
}
Also used : DeltaLimitedMino(_implements.parity_based_pack.step1.DeltaLimitedMino) Mino(core.mino.Mino)

Aggregations

Mino (core.mino.Mino)103 Test (org.junit.jupiter.api.Test)46 Rotate (core.srs.Rotate)27 Field (core.field.Field)24 Piece (core.mino.Piece)20 Randoms (lib.Randoms)16 MinoFactory (core.mino.MinoFactory)14 ColorType (common.tetfu.common.ColorType)12 ColoredField (common.tetfu.field.ColoredField)12 ArrayList (java.util.ArrayList)12 FullOperationWithKey (common.datastore.FullOperationWithKey)9 HashSet (java.util.HashSet)9 ColorConverter (common.tetfu.common.ColorConverter)8 OriginalPiece (core.neighbor.OriginalPiece)8 List (java.util.List)8 MinoOperationWithKey (common.datastore.MinoOperationWithKey)7 OperationWithKey (common.datastore.OperationWithKey)7 TetfuPage (common.tetfu.TetfuPage)7 Arrays (java.util.Arrays)7 Collectors (java.util.stream.Collectors)7