Search in sources :

Example 1 with FigColor

use of util.fig.FigColor in project solution-finder by knewjade.

the class AllFigGenerator method updateField.

@Override
public void updateField(ColoredField field, Mino mino, int x, int y) {
    ColoredField freeze = field.freeze(field.getMaxHeight());
    if (mino != null)
        freeze.putMino(mino, x, y);
    int heightBlock = setting.getFieldHeightBlock();
    int widthBlock = setting.getFieldWidthBlock();
    for (int yIndex = 0; yIndex < heightBlock; yIndex++) {
        boolean isFilledLine = freeze.isFilledLine(yIndex);
        for (int xIndex = 0; xIndex < widthBlock; xIndex++) {
            ColorType type = field.getColorType(xIndex, yIndex);
            FigColor figColor = FigColor.parse(type);
            Color color = getColor(figColor, isFilledLine);
            graphics.setColor(color);
            Rectangle rectangle = positionDecider.getInField(xIndex, yIndex);
            fillRect(rectangle);
        }
    }
}
Also used : ColoredField(common.tetfu.field.ColoredField) FigColor(util.fig.FigColor) FigColor(util.fig.FigColor) Rectangle(util.fig.Rectangle) ColorType(common.tetfu.common.ColorType)

Example 2 with FigColor

use of util.fig.FigColor 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 3 with FigColor

use of util.fig.FigColor 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 4 with FigColor

use of util.fig.FigColor 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 5 with FigColor

use of util.fig.FigColor in project solution-finder by knewjade.

the class AllFigGenerator 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)

Aggregations

FigColor (util.fig.FigColor)8 Rectangle (util.fig.Rectangle)6 ColorType (common.tetfu.common.ColorType)5 Mino (core.mino.Mino)5 ColoredField (common.tetfu.field.ColoredField)3 Piece (core.mino.Piece)3