import { Label, ShapeCircle, ShapeRect, ShapeRectNew } from "./Unit";

export class Letter{
    data;

    images;

    bgColor;

    lineColor;

    scaleX = 1;

    scaleY = 1;

    bg : ShapeRectNew;

    dragLabel : Label;

    init(images, data, bgColor, scaleX = 1, scaleY = 1) {

        this.images = images;

        this.data = data;

        this.bgColor = bgColor;

        this.scaleX = scaleX;

        this.scaleY = scaleY;

        this.initBg();

        let letter = this.initView();

        let w = 128 * this.scaleX

        let h = 90 * this.scaleY;

        this.bg.setSize(w, h, 0);
        letter.x = w / 2;
        letter.y = h / 2;
    }

    initBg(){

        let bg = new ShapeRectNew();
        bg.fillColor = this.bgColor;
        bg.setOutLine(this.lineColor, 6 * this.scaleX)
        this.bg = bg;

    }

    initView(){
        const letter = new Label();
        letter.text = this.data.val;
        letter.textAlign = 'center';
        letter.fontSize = 52;
        letter.fontName = "FUTURAB";
        letter.fontColor = "#2b292e";
        letter.setScaleXY(this.scaleX);
        letter.refreshSize();
        this.bg.addChild(letter);
        

        const dragLabel = new Label();
        dragLabel.text = this.data.val;
        dragLabel.textAlign = 'center';
        dragLabel.fontSize = 52;
        dragLabel.fontName = "FUTURAB";
        dragLabel.fontColor = "#c8161d";
        dragLabel.setScaleXY(this.scaleX);

        this.dragLabel = dragLabel;

        return letter;
    }
}